@locusai/locus-gateway 0.22.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands.d.ts +14 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/executor.d.ts +44 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/formatter.d.ts +14 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/gateway.d.ts +50 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/index.cjs +592 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +550 -0
- package/dist/router.d.ts +14 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/tracker.d.ts +25 -0
- package/dist/tracker.d.ts.map +1 -0
- package/dist/types.d.ts +180 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command registry — defines all available commands and their properties.
|
|
3
|
+
*
|
|
4
|
+
* This is the single source of truth for command→CLI argument mapping,
|
|
5
|
+
* streaming behavior, and argument requirements.
|
|
6
|
+
*/
|
|
7
|
+
import type { CommandDefinition } from "./types.js";
|
|
8
|
+
/** All known Locus CLI commands. */
|
|
9
|
+
export declare const COMMAND_REGISTRY: Record<string, CommandDefinition>;
|
|
10
|
+
/** Commands that produce streaming (long-running) output. */
|
|
11
|
+
export declare const STREAMING_COMMANDS: Set<string>;
|
|
12
|
+
/** Get the command definition for a command name, or null if not found. */
|
|
13
|
+
export declare function getCommandDefinition(command: string): CommandDefinition | null;
|
|
14
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,oCAAoC;AACpC,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAwB9D,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,aAI9B,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAE1B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommandExecutor — executes Locus CLI commands and git operations,
|
|
3
|
+
* producing output that the gateway can route back to any platform.
|
|
4
|
+
*
|
|
5
|
+
* Handles both streaming (long-running, real-time output) and
|
|
6
|
+
* buffered (collect-all-then-respond) command execution.
|
|
7
|
+
*/
|
|
8
|
+
import { CommandTracker } from "./tracker.js";
|
|
9
|
+
import type { CommandResult } from "./types.js";
|
|
10
|
+
/** Callback for streaming updates. */
|
|
11
|
+
export interface StreamCallbacks {
|
|
12
|
+
/** Called when a streaming message should be sent (initial). */
|
|
13
|
+
onStart(text: string): Promise<string | undefined>;
|
|
14
|
+
/** Called periodically as new output arrives. messageId is from onStart. */
|
|
15
|
+
onUpdate(messageId: string, text: string): Promise<void>;
|
|
16
|
+
/** Called when the command is complete. */
|
|
17
|
+
onComplete(messageId: string, text: string, exitCode: number): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare class CommandExecutor {
|
|
20
|
+
private tracker;
|
|
21
|
+
constructor(tracker: CommandTracker);
|
|
22
|
+
/** Get the tracker instance. */
|
|
23
|
+
getTracker(): CommandTracker;
|
|
24
|
+
/**
|
|
25
|
+
* Execute a Locus CLI command.
|
|
26
|
+
*
|
|
27
|
+
* For streaming commands, uses callbacks to push incremental output.
|
|
28
|
+
* For buffered commands, collects all output and returns it.
|
|
29
|
+
*/
|
|
30
|
+
executeLocusCommand(sessionId: string, command: string, args: string[], callbacks?: StreamCallbacks): Promise<CommandResult & {
|
|
31
|
+
exitCode: number;
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Execute a git command directly (not via the Locus CLI).
|
|
35
|
+
*/
|
|
36
|
+
executeGit(sessionId: string, command: string, args: string[], gitArgs: string): Promise<CommandResult & {
|
|
37
|
+
exitCode: number;
|
|
38
|
+
}>;
|
|
39
|
+
/** Execute a streaming command with real-time output updates. */
|
|
40
|
+
private executeStreaming;
|
|
41
|
+
/** Execute a buffered command — collect all output, then return. */
|
|
42
|
+
private executeBuffered;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,YAAY,CAAC;AAOhE,sCAAsC;AACtC,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACnD,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,2CAA2C;IAC3C,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAiB;gBAEpB,OAAO,EAAE,cAAc;IAInC,gCAAgC;IAChC,UAAU,IAAI,cAAc;IAI5B;;;;;OAKG;IACG,mBAAmB,CACvB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,SAAS,CAAC,EAAE,eAAe,GAC1B,OAAO,CAAC,aAAa,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IA4ChD;;OAEG;IACG,UAAU,CACd,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAgChD,iEAAiE;YACnD,gBAAgB;IAsE9B,oEAAoE;YACtD,eAAe;CAgC9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MessageFormatter — adapts gateway output to each platform's capabilities.
|
|
3
|
+
*
|
|
4
|
+
* Handles format conversion (plain/markdown/html) and message splitting
|
|
5
|
+
* based on platform constraints.
|
|
6
|
+
*/
|
|
7
|
+
import type { PlatformCapabilities } from "./types.js";
|
|
8
|
+
/** Determine the best output format for a platform. */
|
|
9
|
+
export declare function bestFormat(capabilities: PlatformCapabilities): "plain" | "markdown" | "html";
|
|
10
|
+
/** Split long text into chunks respecting platform message limits. */
|
|
11
|
+
export declare function splitMessage(text: string, maxLength: number): string[];
|
|
12
|
+
/** Truncate text to a max length, appending indicator if truncated. */
|
|
13
|
+
export declare function truncate(text: string, maxLength: number): string;
|
|
14
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,uDAAuD;AACvD,wBAAgB,UAAU,CACxB,YAAY,EAAE,oBAAoB,GACjC,OAAO,GAAG,UAAU,GAAG,MAAM,CAI/B;AAED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBtE;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGhE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway — the central orchestrator that connects platform adapters
|
|
3
|
+
* to the command execution pipeline.
|
|
4
|
+
*
|
|
5
|
+
* Adapters push inbound messages into the gateway. The gateway parses,
|
|
6
|
+
* routes, executes, and sends responses back through the originating adapter.
|
|
7
|
+
*/
|
|
8
|
+
import { CommandExecutor } from "./executor.js";
|
|
9
|
+
import { CommandRouter } from "./router.js";
|
|
10
|
+
import { CommandTracker } from "./tracker.js";
|
|
11
|
+
import type { GatewayEvent, InboundMessage, PlatformAdapter } from "./types.js";
|
|
12
|
+
export type GatewayEventHandler = (event: GatewayEvent) => void;
|
|
13
|
+
export interface GatewayOptions {
|
|
14
|
+
/** Event handler for gateway events (optional). */
|
|
15
|
+
onEvent?: GatewayEventHandler;
|
|
16
|
+
}
|
|
17
|
+
export declare class Gateway {
|
|
18
|
+
private adapters;
|
|
19
|
+
private router;
|
|
20
|
+
private executor;
|
|
21
|
+
private tracker;
|
|
22
|
+
private onEvent?;
|
|
23
|
+
constructor(options?: GatewayOptions);
|
|
24
|
+
/** Register a platform adapter with the gateway. */
|
|
25
|
+
register(adapter: PlatformAdapter): void;
|
|
26
|
+
/** Get a registered adapter by platform name. */
|
|
27
|
+
getAdapter(platform: string): PlatformAdapter | undefined;
|
|
28
|
+
/** Get the command router. */
|
|
29
|
+
getRouter(): CommandRouter;
|
|
30
|
+
/** Get the command executor. */
|
|
31
|
+
getExecutor(): CommandExecutor;
|
|
32
|
+
/** Get the command tracker. */
|
|
33
|
+
getTracker(): CommandTracker;
|
|
34
|
+
/**
|
|
35
|
+
* Handle an inbound message from any platform.
|
|
36
|
+
*
|
|
37
|
+
* This is the main entry point — adapters call this when they
|
|
38
|
+
* receive a message from their platform.
|
|
39
|
+
*/
|
|
40
|
+
handleMessage(message: InboundMessage): Promise<void>;
|
|
41
|
+
/** Start all registered adapters. */
|
|
42
|
+
start(): Promise<void>;
|
|
43
|
+
/** Stop all adapters gracefully. */
|
|
44
|
+
stop(): Promise<void>;
|
|
45
|
+
/** Execute a command and send the response through the adapter. */
|
|
46
|
+
private executeCommand;
|
|
47
|
+
/** Emit a gateway event. */
|
|
48
|
+
private emit;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,eAAe,EAAwB,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIhF,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAEhE,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAC,CAAsB;gBAE1B,OAAO,GAAE,cAAmB;IAOxC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAUxC,iDAAiD;IACjD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIzD,8BAA8B;IAC9B,SAAS,IAAI,aAAa;IAI1B,gCAAgC;IAChC,WAAW,IAAI,eAAe;IAI9B,+BAA+B;IAC/B,UAAU,IAAI,cAAc;IAI5B;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC3D,qCAAqC;IAC/B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB5B,oCAAoC;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B,mEAAmE;YACrD,cAAc;IA+E5B,4BAA4B;IAC5B,OAAO,CAAC,IAAI;CASb"}
|