feat: Add Be and tbd skill, also added Roadmap file

This commit is contained in:
2026-05-10 16:32:12 -04:00
parent 3500ade13f
commit 0bb8885802
29587 changed files with 10611695 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
{
"logUncaughtExceptions": true,
"logUnhandledRejections": true,
"stackTraceLimit": 30,
"outputs": {
"console": {
"outputFileAndLine": false
},
"syslog": {
"port": 514,
"target": "127.0.0.1",
"outputFileAndLine": false
},
"file": {
"filename": null,
"size": "10M",
"compress": true,
"outputFileAndLine": false
}
},
"namespaces": {
"": {
"console": "info",
"syslog": "info",
"file": "none"
}
}
}

View File

View File

@@ -0,0 +1,58 @@
/**
* @class ServiceError
* @param platformErrorKey {string} Platform error key expected by platform error services
* @param value {ErrorValue} Value of error for platform key. See expected format below.
* @description Format of error expected by errors service
*/
export declare class ServiceError {
key: string;
value: ErrorValue;
constructor(platformErrorKey: string, value: ErrorValue);
}
/**
* @typedef ErrorType
* @property UNKNOWN {number} Unknown error type.
* @property EVENT {number} Event error type.
* @property RECOVERABLE {number} Recoverable error type.
* @description Types of errors to be reported
*/
export declare enum ErrorType {
UNKNOWN = 0,
EVENT = 1,
RECOVERABLE = 2,
}
/**
* @typedef ErrorStatus
* @property UNKNOWN {number} Unknown status.
* @property BROKEN {number} Broken status.
* @property FIXED {number} Fixed status.
* @description Status of errors to be reported.
*/
export declare enum ErrorStatus {
UNKNOWN = 0,
BROKEN = 1,
FIXED = 2,
}
/**
* @class ErrorValue
* @param error {ErrorValue} an error to copy into this instance of ErrorValue
* @description Value for each error expected by errors service
*/
export declare class ErrorValue {
name: string;
type: ErrorType;
status: ErrorStatus;
count: number;
oldest: number[];
newest: number[];
constructor(name: string, type: ErrorType, status: ErrorStatus, count: number, oldest: number[], newest: number[]);
}
/**
* @interface ServiceErrors
* @description Format by which platform errors service expects an
* array of errors to be reported.
*/
export declare class ServiceErrors {
entries: ServiceError[];
constructor(errors?: ServiceError[]);
}

View File

@@ -0,0 +1,40 @@
/// <reference types="node" />
import { ServiceOptions, JiboServerRequest, JiboServerResponse } from './index';
import * as connect from 'connect';
import * as http from 'http';
import Router = require('router');
import { EventEmitter } from 'events';
import { RegistrationRecord } from 'jibo-client-framework';
export default class HTTPService extends EventEmitter {
app: connect.Server;
server: http.Server;
staticDir: string;
router: Router;
record: RegistrationRecord;
name: string;
options: ServiceOptions;
rootDir: string;
private _intervalId;
static getPort(firstPortToTry?: number): Promise<number>;
private static _testPort(port);
private static readonly _onRobot;
constructor(name: string, options: ServiceOptions, rootDir?: string);
init(callback: (err?: Error) => void): void;
refresh(): void;
port: number;
enableDebug(): void;
parseQueryString(req: JiboServerRequest, res: any, next: any): void;
parseBody<T = any>(req: JiboServerRequest, cb: (err?: string | Error, data?: T) => void): void;
routes(url: Router): void;
finish(res: JiboServerResponse, err?: Error | string, data?: any, contentType?: string, statusCode?: number): void;
finishNoContent(res: JiboServerResponse, status?: number, err?: Error | string): void;
sendFile(res: JiboServerResponse, filename: string, contentType?: string): void;
sendJson(res: JiboServerResponse, json: Object | string, statusCode?: number): void;
destroy(callback?: (err?: Error | string) => void): void;
protected onErrors(req: JiboServerRequest, res: JiboServerResponse): void;
protected onHealth(req: JiboServerRequest, res: JiboServerResponse): void;
protected onBackupRequest(req: JiboServerRequest, res: JiboServerResponse): void;
protected onWipeRequest(req: JiboServerRequest, res: JiboServerResponse): void;
protected onRestoreRequest(req: JiboServerRequest, res: JiboServerResponse): void;
private _register(callback);
}

View File

@@ -0,0 +1,8 @@
import HTTPService from './HTTPService';
import { ServiceOptions } from './index';
import Router = require('router');
declare class HTTPServiceDebug extends HTTPService {
constructor(options: ServiceOptions, rootDir: string);
routes(url: Router): void;
}
export default HTTPServiceDebug;

View File

@@ -0,0 +1,27 @@
/// <reference types="ws" />
/// <reference types="node" />
import HTTPService from './HTTPService';
import { ServiceOptions } from './index';
import http = require('http');
import WebSocket = require('ws');
export declare type WebSocketWithUrl = WebSocket & {
url: string;
};
declare abstract class HTTPWSService extends HTTPService {
wsServer: WebSocket.Server;
connections: Array<WebSocket>;
constructor(name: string, options: ServiceOptions, staticDir: string);
init(callback: (err?) => void): void;
onConnection(client: WebSocketWithUrl, request: http.IncomingMessage): void;
protected onClose(client: WebSocket): void;
protected abstract onMessage(command: any, client: WebSocketWithUrl): void;
sendWsJson(client: WebSocket, json: Object | string): Promise<boolean>;
/**
* Broadcast a message to all connected WebSocket clients
* @method HTTPWSService#broadcast
* @param {any} message JSON message to broadcast
*/
broadcast(message: any): void;
private closeClient(client);
}
export default HTTPWSService;

View File

@@ -0,0 +1,15 @@
/// <reference types="ws" />
/// <reference types="node" />
import HTTPWSService, { WebSocketWithUrl } from './HTTPWSService';
import { ServiceOptions } from './index';
import Router = require("router");
import WebSocket = require('ws');
import http = require('http');
declare class HTTPSWSServiceDebug extends HTTPWSService {
constructor(options: ServiceOptions, rootDir: string);
protected onMessage(command: any, client: WebSocketWithUrl): void;
protected onClose(client: WebSocket): void;
onConnection(client: WebSocketWithUrl, request: http.IncomingMessage): void;
routes(url: Router): void;
}
export default HTTPSWSServiceDebug;

View File

@@ -0,0 +1,68 @@
/// <reference types="ws" />
import WebSocket = require('ws');
import { CacheManager } from 'jibo-cai-utils';
import ServiceRemoteObject from './ServiceRemoteObject';
import HTTPWSService from './HTTPWSService';
import { ServiceOptions } from './index';
export declare type CallbackHandler = (data: any) => void;
export declare type RejectionHandler = (err) => void;
export declare class RemoteObjectCache extends CacheManager<ServiceRemoteObject, number, WebSocket> {
}
declare abstract class RemoteService extends HTTPWSService {
/** Maps a callback handle to a callback */
callbackHandlers: Map<number, CallbackHandler>;
rejectionHandlers: Map<number, RejectionHandler>;
cache: RemoteObjectCache;
protected lazyInitCheck: RejectionHandler;
/** Maps incoming message type to a specific message type handler */
private _messageMap;
/**
* @param {string} name Name of the service in the registry
* @param {ServiceOptions} options
* @param {string} staticDir Path to a static wenpage directory
*/
constructor(name: string, options: ServiceOptions, staticDir: string);
/**
* When a client requests a remote instance be created the server
* wants to associate that instance with the owner for cleanup
* purposes. Called from the constructor of ServiceRemoteObject if
* it's instantiated with an owner.
* @param {WebSocket} owner The client that owns the instance.
* @param {ServiceRemoteObject} instance The remote object instance
*/
addInstance(owner: WebSocket, instance: ServiceRemoteObject): void;
/**
* When a websocket disconnects destory all instances that are associated
* with this connection.
* @param {WebSocket} client The client that disconnected.
*/
protected onClose(client: WebSocket): void;
/**
* Called when a websocket message is received
* @param {any} command [description]
* @param {WebSocket} ws [description]
*/
protected onMessage(command: any, ws: WebSocket): void;
/**
* Called when the client sends a message reply. Finds the appropriate
* callback handle and calls it with the results/
* @param {WebSocket} ws Client that responded
* @param {Reply} message The results
*/
private onReply(ws, message);
/**
* Called when the client sends an error. This happens when a remote
* call threw an error or had an unhandled promise rejection.
* @param {WebSocket} ws Client that responded
* @param {MessageError} message The results
*/
private onError(ws, message);
/**
* Called when the client makes an RPC request on an instance
* @param {WebSocket} ws The client making the request
* @param {Request} message Contains the instance id, method and args
*/
private onRequest(ws, message);
private doOnRequest(ws, message);
}
export default RemoteService;

View File

@@ -0,0 +1,55 @@
/// <reference types="ws" />
import RemoteService from './RemoteService';
import WebSocket = require('ws');
export declare type CallbackHandler = (data: any) => void;
export interface Options {
instanceId?: number;
base: RemoteService;
owner?: WebSocket;
}
declare abstract class ServiceRemoteObject {
static singeltonId: number;
private static _messageId;
private static GLOBAL_COUNTER;
base: RemoteService;
owner: WebSocket;
name: string;
callee: WebSocket;
protected _callbackHandlers: Map<number, CallbackHandler>;
isDestroyed: boolean;
private _instanceId;
constructor(options: Options);
readonly instanceId: number;
/**
* Emits an event to the client object
* @param {string} event Event name
* @param {any[]} ...args
* @return {Promise<void>}
*/
emit(event: string, ...args: any[]): void;
/**
* Send a message to the client version of this object. Returns the result
* of the RPC.
* @param {string} methodName
* @param {any[]} args
*/
sendMessage<T>(methodName: string, args: any[], sendAndForget?: boolean): Promise<T>;
/**
* Called when client that owns this object disconnects
*/
abstract destroy(): any;
/**
* Removes this remote object from the remote service cache
*/
protected remove(): void;
/**
* When called with a specific messageId, this function will return
* a Promise that resolves when a
* @param messageId The message handle
* @returns Promise that resolves to the return value
*/
private waitForReply<T>(messageId);
private getMessageId();
private _sendMessage(ws, eventMessage);
}
export default ServiceRemoteObject;

View File

@@ -0,0 +1,3 @@
declare function promisify(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
declare function promisify_4(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>): any;
export { promisify, promisify_4 };

View File

@@ -0,0 +1,31 @@
/// <reference types="node" />
import * as http from 'http';
export { default as HTTPService } from './HTTPService';
export { default as HTTPServiceDebug } from './HTTPServiceDebug';
export { default as HTTPWSService } from './HTTPWSService';
export { default as HTTPWSServiceDebug } from './HTTPWSServiceDebug';
export * from 'jibo-client-framework';
export { default as RemoteService, RejectionHandler } from './RemoteService';
export { ServiceErrors, ServiceError, ErrorStatus, ErrorType, ErrorValue } from './DataTypes';
export { default as ServiceRemoteObject } from './ServiceRemoteObject';
export { WebSocketWithUrl as WebSocket } from './HTTPWSService';
export declare type HandlerFunction = (req: http.IncomingMessage, res: JiboServerResponse, next: Function) => void;
export interface JiboServerRequest extends http.ServerRequest {
params: any;
query: any;
body: any;
}
export interface JiboServerResponse extends http.ServerResponse {
}
export interface RegistrationRecord {
name: string;
host: string;
port: number;
path: string;
ttl?: number;
tls?: string;
}
export interface ServiceOptions {
port: number;
register?: boolean;
}

View File

@@ -0,0 +1,3 @@
import { Log } from 'jibo-log';
declare const _default: Log;
export default _default;

View File

@@ -0,0 +1,13 @@
/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Lookup the MIME type for a file path/extension.
*
* @param {string} path
* @return {boolean|string}
*/
export declare function lookup(path: any): any;

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,54 @@
{
"name": "jibo-service-framework",
"version": "5.0.4",
"description": "Base Module for Service framework",
"main": "lib/jibo-service-framework.js",
"typings": "lib/dts/index.d.ts",
"scripts": {
"test": "gulp test && istanbul report && yarn coverage:check",
"test:report": "gulp test-report",
"build": "gulp debug",
"build:release": "gulp",
"clean": "gulp clean-all",
"coverage:check": "istanbul check-coverage --statements 30 --branches 20 --functions 30 --lines 30",
"coverage:report": "istanbul report && open coverage/lcov-report/index.html",
"coverage:remap": "remap-istanbul --input ./coverage/coverage-final.json --output ./coverage/coverage-final.json -b jibo-service-framework/",
"watch": "gulp watch"
},
"repository": {
"type": "git",
"url": "git@github.jibo.com:sdk/sdk.git"
},
"publishConfig": {
"registry": "http://npm.jibo.media.mit.edu:8081/repository/private/"
},
"author": "",
"license": "UNLICENSED",
"distribution": "PROPRIETARY AND CONFIDENTIAL - NOT FOR DISTRIBUTION",
"copyright": "Copyright (c) 2014-2018 Jibo, Inc. All Rights Reserved",
"engines": {
"node": ">=6.0"
},
"dependencies": {
"body-parser": "^1.15.1",
"connect": "^3.4.1",
"jibo-cai-utils": "^7.0.0",
"jibo-client-framework": "^5.0.0",
"jibo-log": "^6.0.0",
"router": "^1.1.4",
"serve-static": "^1.10.2",
"ws": "^3.0.0"
},
"files": [
"lib",
"registry.json"
],
"devDependencies": {
"@types/node": "6.0.94",
"@types/ws": "^3.0.0",
"gulp": "^3.9.1",
"istanbul": "^0.4.5",
"jibo-gulp": "^9.0.0",
"should": "^8.3.1"
}
}

View File

@@ -0,0 +1,60 @@
{
"records": [
{
"name": "asr",
"host": "10.10.1.196",
"port": 8088,
"path": "/",
"ttl": 14722,
"tls": ""
},
{
"name": "audio",
"host": "10.10.1.196",
"port": 8383,
"path": "/",
"ttl": 221,
"tls": ""
},
{
"name": "body",
"host": "10.10.1.196",
"port": 8282,
"path": "/",
"ttl": 221,
"tls": ""
},
{
"name": "lps",
"host": "10.10.1.196",
"port": 8484,
"path": "/",
"ttl": 228,
"tls": ""
},
{
"name": "nlu",
"host": "10.10.1.196",
"port": 8787,
"path": "/",
"ttl": 299984722,
"tls": ""
},
{
"name": "system-manager",
"host": "10.10.1.196",
"port": 8585,
"path": "/",
"ttl": 221,
"tls": ""
},
{
"name": "tts",
"host": "10.10.1.196",
"port": 8089,
"path": "/",
"ttl": 29984723,
"tls": ""
}
]
}

View File

@@ -0,0 +1,17 @@
{
"compilerOptions": {
"target": "es6",
"allowJs": false,
"module": "commonjs",
"moduleResolution": "node",
"noUnusedLocals": true,
"experimentalDecorators": true,
"typeRoots": ["../../node_modules/@types", "node_modules/@types"],
"types": ["node", "ws"]
},
"compileOnSave": false,
"include": [
"src/**/*.ts",
"typings/index.d.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "../../tslint_base.json"
}