neoctl 0.2.2 → 0.2.4

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.
Files changed (72) hide show
  1. package/dist/app/app-prompt.d.ts +32 -0
  2. package/dist/app/app-prompt.js +42 -0
  3. package/dist/app/app-prompt.js.map +1 -0
  4. package/dist/context/context-manager.d.ts +12 -0
  5. package/dist/context/context-manager.js +32 -0
  6. package/dist/context/context-manager.js.map +1 -1
  7. package/dist/core/query-engine.d.ts +7 -0
  8. package/dist/core/query-engine.js +26 -3
  9. package/dist/core/query-engine.js.map +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/repl/index.js +2 -2
  14. package/dist/repl/index.js.map +1 -1
  15. package/dist/session/session-export.d.ts +1 -0
  16. package/dist/session/session-export.js +1 -0
  17. package/dist/session/session-export.js.map +1 -1
  18. package/dist/session/session-store.d.ts +11 -0
  19. package/dist/session/session-store.js +21 -0
  20. package/dist/session/session-store.js.map +1 -1
  21. package/dist/web/index.d.ts +18 -0
  22. package/dist/web/index.js +33 -0
  23. package/dist/web/index.js.map +1 -1
  24. package/package.json +3 -2
  25. package/dist/core/commands.d.ts +0 -66
  26. package/dist/core/commands.js +0 -151
  27. package/dist/core/commands.js.map +0 -1
  28. package/dist/core/runtime.d.ts +0 -59
  29. package/dist/core/runtime.js +0 -161
  30. package/dist/core/runtime.js.map +0 -1
  31. package/dist/repl/render.d.ts +0 -2
  32. package/dist/repl/render.js +0 -45
  33. package/dist/repl/render.js.map +0 -1
  34. package/dist/repl/status-line.d.ts +0 -19
  35. package/dist/repl/status-line.js +0 -160
  36. package/dist/repl/status-line.js.map +0 -1
  37. package/dist/repl/transcript-flush.d.ts +0 -6
  38. package/dist/repl/transcript-flush.js +0 -54
  39. package/dist/repl/transcript-flush.js.map +0 -1
  40. package/dist/repl/transcript-format.d.ts +0 -16
  41. package/dist/repl/transcript-format.js +0 -199
  42. package/dist/repl/transcript-format.js.map +0 -1
  43. package/dist/server/agent-manager.d.ts +0 -56
  44. package/dist/server/agent-manager.js +0 -171
  45. package/dist/server/agent-manager.js.map +0 -1
  46. package/dist/server/connection-manager.d.ts +0 -18
  47. package/dist/server/connection-manager.js +0 -52
  48. package/dist/server/connection-manager.js.map +0 -1
  49. package/dist/server/event-mapper.d.ts +0 -4
  50. package/dist/server/event-mapper.js +0 -31
  51. package/dist/server/event-mapper.js.map +0 -1
  52. package/dist/server/query-runtime.d.ts +0 -29
  53. package/dist/server/query-runtime.js +0 -61
  54. package/dist/server/query-runtime.js.map +0 -1
  55. package/dist/server/rpc-router.d.ts +0 -24
  56. package/dist/server/rpc-router.js +0 -165
  57. package/dist/server/rpc-router.js.map +0 -1
  58. package/dist/server/rpc-types.d.ts +0 -92
  59. package/dist/server/rpc-types.js +0 -2
  60. package/dist/server/rpc-types.js.map +0 -1
  61. package/dist/server/ws-server.d.ts +0 -22
  62. package/dist/server/ws-server.js +0 -84
  63. package/dist/server/ws-server.js.map +0 -1
  64. package/dist/tasks/task-record.d.ts +0 -50
  65. package/dist/tasks/task-record.js +0 -50
  66. package/dist/tasks/task-record.js.map +0 -1
  67. package/dist/tools/builtins/echo-tool.d.ts +0 -4
  68. package/dist/tools/builtins/echo-tool.js +0 -26
  69. package/dist/tools/builtins/echo-tool.js.map +0 -1
  70. package/dist/tools/builtins/vision-tool.d.ts +0 -38
  71. package/dist/tools/builtins/vision-tool.js +0 -351
  72. package/dist/tools/builtins/vision-tool.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"event-mapper.js","sourceRoot":"","sources":["../../src/server/event-mapper.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,mBAAmB,CAAC,KAAiB;IACnD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC3B,OAAO;YACL,GAAG,KAAK;YACR,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC;SACnC,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO;YACL,GAAG,KAAK;YACR,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC;SACnC,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAe,EAAE,GAAW,EAAE,KAAiB;IACtF,OAAO;QACL,OAAO;QACP,GAAG;QACH,KAAK,EAAE,mBAAmB,CAAC,KAAK,CAAC;QACjC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAY;IAClC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC;AACJ,CAAC"}
@@ -1,29 +0,0 @@
1
- import type { QueryEngine } from "../core/query-engine.js";
2
- import type { RpcQueryEventEnvelope } from "./rpc-types.js";
3
- export interface QueryRunOptions {
4
- queryId: string;
5
- text: string;
6
- displayText?: string;
7
- disconnectPolicy?: "continue" | "cancel";
8
- onEvent?: (event: RpcQueryEventEnvelope) => void;
9
- }
10
- export type QueryRunState = "running" | "completed" | "cancelled" | "failed";
11
- export declare class QueryRun {
12
- private readonly engine;
13
- private readonly options;
14
- readonly queryId: string;
15
- readonly startedAt: Date;
16
- readonly disconnectPolicy: "continue" | "cancel";
17
- private readonly controller;
18
- private readonly buffer;
19
- private state;
20
- private seq;
21
- private completion?;
22
- constructor(engine: QueryEngine, options: QueryRunOptions);
23
- start(): Promise<void>;
24
- cancel(): void;
25
- getState(): QueryRunState;
26
- getBufferedEvents(afterSeq?: number): RpcQueryEventEnvelope[];
27
- private run;
28
- private pushEvent;
29
- }
@@ -1,61 +0,0 @@
1
- import { createQueryEventEnvelope } from "./event-mapper.js";
2
- export class QueryRun {
3
- engine;
4
- options;
5
- queryId;
6
- startedAt = new Date();
7
- disconnectPolicy;
8
- controller = new AbortController();
9
- buffer = [];
10
- state = "running";
11
- seq = 0;
12
- completion;
13
- constructor(engine, options) {
14
- this.engine = engine;
15
- this.options = options;
16
- this.queryId = options.queryId;
17
- this.disconnectPolicy = options.disconnectPolicy ?? "continue";
18
- }
19
- start() {
20
- if (this.completion)
21
- return this.completion;
22
- this.completion = this.run();
23
- return this.completion;
24
- }
25
- cancel() {
26
- if (this.state !== "running")
27
- return;
28
- this.state = "cancelled";
29
- this.controller.abort();
30
- }
31
- getState() {
32
- return this.state;
33
- }
34
- getBufferedEvents(afterSeq = 0) {
35
- return this.buffer.filter((entry) => entry.seq > afterSeq);
36
- }
37
- async run() {
38
- try {
39
- for await (const event of this.engine.sendUserText(this.options.text, {
40
- abortSignal: this.controller.signal,
41
- displayText: this.options.displayText,
42
- })) {
43
- this.pushEvent(event);
44
- }
45
- if (this.state === "running")
46
- this.state = this.controller.signal.aborted ? "cancelled" : "completed";
47
- }
48
- catch (error) {
49
- this.state = this.controller.signal.aborted ? "cancelled" : "failed";
50
- const normalized = error instanceof Error ? error : new Error(String(error));
51
- this.pushEvent({ type: "error", error: normalized });
52
- throw normalized;
53
- }
54
- }
55
- pushEvent(event) {
56
- const envelope = createQueryEventEnvelope(this.queryId, ++this.seq, event);
57
- this.buffer.push(envelope);
58
- this.options.onEvent?.(envelope);
59
- }
60
- }
61
- //# sourceMappingURL=query-runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-runtime.js","sourceRoot":"","sources":["../../src/server/query-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAa7D,MAAM,OAAO,QAAQ;IAUU;IAAsC;IAT1D,OAAO,CAAS;IAChB,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,gBAAgB,CAAwB;IAChC,UAAU,GAAG,IAAI,eAAe,EAAE,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,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;YACD,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;gBAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;QACxG,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;YACrE,MAAM,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7E,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YACrD,MAAM,UAAU,CAAC;QACnB,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,KAAiB;QACjC,MAAM,QAAQ,GAAG,wBAAwB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF"}
@@ -1,24 +0,0 @@
1
- import type { AgentManager } from "./agent-manager.js";
2
- import type { ConnectionManager } from "./connection-manager.js";
3
- import type { JsonRpcError, JsonRpcRequest, JsonRpcSuccess } from "./rpc-types.js";
4
- export interface RpcRouterOptions {
5
- agentManager: AgentManager;
6
- connectionManager: ConnectionManager;
7
- emitNotification: (connectionId: string, method: string, params: unknown) => void;
8
- }
9
- export declare class RpcRouter {
10
- private readonly options;
11
- constructor(options: RpcRouterOptions);
12
- handle(connectionId: string, request: JsonRpcRequest): Promise<JsonRpcSuccess | JsonRpcError | null>;
13
- private attach;
14
- private detach;
15
- private listSessions;
16
- private deleteSession;
17
- private startQuery;
18
- private cancelQuery;
19
- private resume;
20
- private requireAttachedIdentity;
21
- private requireAttachedIdentitySync;
22
- private ok;
23
- private error;
24
- }
@@ -1,165 +0,0 @@
1
- export class RpcRouter {
2
- options;
3
- constructor(options) {
4
- this.options = options;
5
- }
6
- async handle(connectionId, request) {
7
- try {
8
- switch (request.method) {
9
- case "agent.attach":
10
- return this.ok(request.id, await this.attach(connectionId, request.params));
11
- case "agent.detach":
12
- return this.ok(request.id, this.detach(connectionId, request.params));
13
- case "session.list":
14
- return this.ok(request.id, await this.listSessions(connectionId, request.params));
15
- case "session.delete":
16
- return this.ok(request.id, await this.deleteSession(connectionId, request.params));
17
- case "query.start":
18
- return this.ok(request.id, await this.startQuery(connectionId, request.params));
19
- case "query.cancel":
20
- return this.ok(request.id, this.cancelQuery(connectionId, request.params));
21
- case "connection.resume":
22
- return this.ok(request.id, await this.resume(connectionId, request.params));
23
- case "agent.list":
24
- return this.ok(request.id, this.options.agentManager.listSnapshots());
25
- default:
26
- return this.error(request.id, -32601, `method not found: ${request.method}`);
27
- }
28
- }
29
- catch (error) {
30
- const normalized = error instanceof Error ? error : new Error(String(error));
31
- return this.error(request.id, -32000, normalized.message, { stack: normalized.stack });
32
- }
33
- }
34
- async attach(connectionId, params) {
35
- const identity = normalizeIdentity(params);
36
- const agent = await this.options.agentManager.attach(connectionId, identity, {
37
- create: params?.create,
38
- resume: params?.resume,
39
- });
40
- this.options.connectionManager.attachAgent(connectionId, identity);
41
- return { key: agent.key, state: agent.state, snapshot: agent.engine.snapshot() };
42
- }
43
- detach(connectionId, params) {
44
- const identity = normalizeIdentity(params);
45
- const agent = this.options.agentManager.detach(connectionId, identity);
46
- this.options.connectionManager.detachAgent(connectionId, identity);
47
- return { detached: Boolean(agent), state: agent?.state };
48
- }
49
- async listSessions(connectionId, params) {
50
- const identity = await this.requireAttachedIdentity(connectionId, params);
51
- const agent = this.options.agentManager.get(identity);
52
- if (!agent)
53
- throw new Error(`agent not found: ${identity.agentId}`);
54
- return {
55
- current: agent.engine.snapshot().session,
56
- available: await agent.engine.listSessions(params?.limit ?? 10),
57
- };
58
- }
59
- async deleteSession(connectionId, params) {
60
- const identity = await this.requireAttachedIdentity(connectionId, params);
61
- const agent = this.options.agentManager.get(identity);
62
- if (!agent)
63
- throw new Error(`agent not found: ${identity.agentId}`);
64
- return {
65
- deleted: await agent.engine.deleteSession(required(params?.targetSessionId, "targetSessionId")),
66
- };
67
- }
68
- async startQuery(connectionId, params) {
69
- const identity = await this.requireAttachedIdentity(connectionId, params);
70
- const queryId = params?.queryId?.trim() || createId("query");
71
- const run = await this.options.agentManager.startQuery(identity, {
72
- queryId,
73
- text: required(params?.text, "text"),
74
- displayText: params?.displayText,
75
- disconnectPolicy: params?.disconnectPolicy,
76
- onEvent: (event) => {
77
- for (const target of this.options.connectionManager.listConnectionIdsForAgent(identity)) {
78
- this.options.emitNotification(target, "query.event", event);
79
- }
80
- },
81
- });
82
- return { queryId: run.queryId, state: run.getState() };
83
- }
84
- cancelQuery(connectionId, params) {
85
- const identity = this.requireAttachedIdentitySync(connectionId, params);
86
- return {
87
- cancelled: this.options.agentManager.cancelQuery(identity, required(params?.queryId, "queryId")),
88
- };
89
- }
90
- async resume(connectionId, params) {
91
- const agents = params?.agents ?? [];
92
- const queries = params?.queries ?? [];
93
- const attached = [];
94
- for (const locator of agents) {
95
- const identity = normalizeIdentity(locator);
96
- const agent = await this.options.agentManager.attach(connectionId, identity, { create: true, resume: true });
97
- this.options.connectionManager.attachAgent(connectionId, identity);
98
- attached.push({ key: agent.key, state: agent.state });
99
- }
100
- for (const query of queries) {
101
- for (const identity of this.options.connectionManager.listAttachedAgents(connectionId)) {
102
- const agent = this.options.agentManager.get(identity);
103
- if (!agent?.activeQuery || agent.activeQuery.queryId !== query.queryId)
104
- continue;
105
- for (const event of agent.activeQuery.getBufferedEvents(query.afterSeq ?? 0)) {
106
- this.options.emitNotification(connectionId, "query.event", event);
107
- }
108
- }
109
- }
110
- return { attached, replayedQueries: queries.map((item) => item.queryId) };
111
- }
112
- async requireAttachedIdentity(connectionId, params) {
113
- return this.requireAttachedIdentitySync(connectionId, params);
114
- }
115
- requireAttachedIdentitySync(connectionId, params) {
116
- const record = this.options.connectionManager.get(connectionId);
117
- if (!record)
118
- throw new Error(`connection not found: ${connectionId}`);
119
- const requested = params?.userId ? normalizeIdentity(params) : undefined;
120
- if (requested) {
121
- const match = record.attachedAgents.get(locatorKey(requested));
122
- if (match)
123
- return match;
124
- throw new Error(`agent is not attached to connection: ${locatorKey(requested)}`);
125
- }
126
- const first = record.attachedAgents.values().next().value;
127
- if (!first)
128
- throw new Error("no agent attached to connection");
129
- return first;
130
- }
131
- ok(id, result) {
132
- return {
133
- jsonrpc: "2.0",
134
- id: id ?? null,
135
- result,
136
- };
137
- }
138
- error(id, code, message, data) {
139
- return {
140
- jsonrpc: "2.0",
141
- id: id ?? null,
142
- error: { code, message, data },
143
- };
144
- }
145
- }
146
- function normalizeIdentity(params) {
147
- return {
148
- userId: required(params?.userId, "userId"),
149
- agentId: params?.agentId?.trim() || "main",
150
- sessionId: params?.sessionId?.trim() || undefined,
151
- };
152
- }
153
- function required(value, field) {
154
- const normalized = value?.trim();
155
- if (!normalized)
156
- throw new Error(`missing required field: ${field}`);
157
- return normalized;
158
- }
159
- function locatorKey(identity) {
160
- return `${identity.userId}:${identity.sessionId ?? "default"}:${identity.agentId}`;
161
- }
162
- function createId(prefix) {
163
- return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
164
- }
165
- //# sourceMappingURL=rpc-router.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc-router.js","sourceRoot":"","sources":["../../src/server/rpc-router.ts"],"names":[],"mappings":"AAqBA,MAAM,OAAO,SAAS;IACS;IAA7B,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,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC1F,CAAC"}
@@ -1,92 +0,0 @@
1
- import type { AgentEvent } from "../types/events.js";
2
- import type { SessionStoreSnapshot, SessionSummary } from "../session/session-store.js";
3
- export interface JsonRpcRequest<T = unknown> {
4
- jsonrpc: "2.0";
5
- id?: string | number | null;
6
- method: string;
7
- params?: T;
8
- }
9
- export interface JsonRpcSuccess<T = unknown> {
10
- jsonrpc: "2.0";
11
- id: string | number | null;
12
- result: T;
13
- }
14
- export interface JsonRpcError {
15
- jsonrpc: "2.0";
16
- id: string | number | null;
17
- error: {
18
- code: number;
19
- message: string;
20
- data?: unknown;
21
- };
22
- }
23
- export interface RpcAgentLocator {
24
- userId: string;
25
- agentId?: string;
26
- sessionId?: string;
27
- }
28
- export interface AgentAttachParams extends RpcAgentLocator {
29
- create?: boolean;
30
- resume?: boolean;
31
- }
32
- export interface AgentDetachParams extends RpcAgentLocator {
33
- }
34
- export interface SessionListParams extends RpcAgentLocator {
35
- limit?: number;
36
- }
37
- export interface SessionDeleteParams extends RpcAgentLocator {
38
- targetSessionId: string;
39
- }
40
- export interface QueryStartParams extends RpcAgentLocator {
41
- queryId?: string;
42
- text: string;
43
- displayText?: string;
44
- disconnectPolicy?: "continue" | "cancel";
45
- }
46
- export interface QueryCancelParams extends RpcAgentLocator {
47
- queryId: string;
48
- }
49
- export interface QueryResumeItem {
50
- queryId: string;
51
- afterSeq?: number;
52
- }
53
- export interface ConnectionResumeParams {
54
- agents?: RpcAgentLocator[];
55
- queries?: QueryResumeItem[];
56
- }
57
- export interface RpcSessionInfo {
58
- current?: SessionStoreSnapshot;
59
- available?: SessionSummary[];
60
- }
61
- export interface RpcAgentSnapshot {
62
- key: string;
63
- userId: string;
64
- agentId: string;
65
- state: string;
66
- attachedConnections: number;
67
- activeQueryId?: string;
68
- snapshot: ReturnType<import("../core/query-engine.js").QueryEngine["snapshot"]>;
69
- }
70
- export interface RpcQueryEventEnvelope {
71
- queryId: string;
72
- seq: number;
73
- event: SerializedAgentEvent;
74
- createdAt: string;
75
- }
76
- export type SerializedAgentEvent = AgentEvent | ({
77
- type: "retrying";
78
- attempt: number;
79
- delayMs: number;
80
- error: {
81
- name: string;
82
- message: string;
83
- stack?: string;
84
- };
85
- }) | ({
86
- type: "error";
87
- error: {
88
- name: string;
89
- message: string;
90
- stack?: string;
91
- };
92
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=rpc-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rpc-types.js","sourceRoot":"","sources":["../../src/server/rpc-types.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- import http from "node:http";
2
- import { WebSocketServer } from "ws";
3
- import { AgentManager, type AgentManagerOptions } from "./agent-manager.js";
4
- import { ConnectionManager } from "./connection-manager.js";
5
- import { RpcRouter } from "./rpc-router.js";
6
- export interface JsonRpcWebSocketServerOptions extends AgentManagerOptions {
7
- server?: http.Server;
8
- path?: string;
9
- sweepIntervalMs?: number;
10
- }
11
- export declare class JsonRpcWebSocketServer {
12
- readonly agentManager: AgentManager;
13
- readonly connectionManager: ConnectionManager;
14
- readonly websocketServer: WebSocketServer;
15
- readonly router: RpcRouter;
16
- private readonly sweepTimer;
17
- constructor(options?: JsonRpcWebSocketServerOptions);
18
- close(): Promise<void>;
19
- private handleConnection;
20
- private findSocket;
21
- }
22
- export declare function startJsonRpcWebSocketServer(options?: JsonRpcWebSocketServerOptions): Promise<JsonRpcWebSocketServer>;
@@ -1,84 +0,0 @@
1
- import { WebSocketServer } from "ws";
2
- import { AgentManager } from "./agent-manager.js";
3
- import { ConnectionManager } from "./connection-manager.js";
4
- import { RpcRouter } from "./rpc-router.js";
5
- export class JsonRpcWebSocketServer {
6
- agentManager;
7
- connectionManager = new ConnectionManager();
8
- websocketServer;
9
- router;
10
- sweepTimer;
11
- constructor(options = {}) {
12
- this.agentManager = new AgentManager(options);
13
- this.websocketServer = new WebSocketServer({ noServer: !options.server, server: options.server, path: options.path });
14
- this.router = new RpcRouter({
15
- agentManager: this.agentManager,
16
- connectionManager: this.connectionManager,
17
- emitNotification: (connectionId, method, params) => {
18
- const socket = this.findSocket(connectionId);
19
- if (!socket || socket.readyState !== socket.OPEN)
20
- return;
21
- socket.send(JSON.stringify({ jsonrpc: "2.0", method, params }));
22
- },
23
- });
24
- this.websocketServer.on("connection", (socket) => this.handleConnection(socket));
25
- this.sweepTimer = setInterval(() => {
26
- this.agentManager.sweep();
27
- }, options.sweepIntervalMs ?? 30_000);
28
- this.sweepTimer.unref?.();
29
- }
30
- close() {
31
- clearInterval(this.sweepTimer);
32
- return new Promise((resolve, reject) => {
33
- this.websocketServer.close((error) => {
34
- if (error)
35
- reject(error);
36
- else
37
- resolve();
38
- });
39
- });
40
- }
41
- handleConnection(socket) {
42
- const connectionId = createConnectionId();
43
- this.connectionManager.open(connectionId);
44
- socket.__connectionId = connectionId;
45
- socket.on("message", async (data) => {
46
- const text = typeof data === "string" ? data : data.toString("utf8");
47
- let request;
48
- try {
49
- request = JSON.parse(text);
50
- }
51
- catch {
52
- socket.send(JSON.stringify({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "parse error" } }));
53
- return;
54
- }
55
- const response = await this.router.handle(connectionId, request);
56
- if (response && request.id !== undefined)
57
- socket.send(JSON.stringify(response));
58
- });
59
- socket.on("close", () => {
60
- const detached = this.connectionManager.close(connectionId);
61
- for (const identity of detached) {
62
- const agent = this.agentManager.detach(connectionId, identity);
63
- if (agent?.activeQuery?.disconnectPolicy === "cancel")
64
- agent.activeQuery.cancel();
65
- }
66
- this.agentManager.detachConnectionFromAll(connectionId);
67
- });
68
- }
69
- findSocket(connectionId) {
70
- for (const client of this.websocketServer.clients) {
71
- const socket = client;
72
- if (socket.__connectionId === connectionId)
73
- return socket;
74
- }
75
- return undefined;
76
- }
77
- }
78
- export async function startJsonRpcWebSocketServer(options = {}) {
79
- return new JsonRpcWebSocketServer(options);
80
- }
81
- function createConnectionId() {
82
- return `conn_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
83
- }
84
- //# sourceMappingURL=ws-server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ws-server.js","sourceRoot":"","sources":["../../src/server/ws-server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAkB,MAAM,IAAI,CAAC;AACrD,OAAO,EAAE,YAAY,EAA4B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,sBAAsB;IACxB,YAAY,CAAe;IAC3B,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC5C,eAAe,CAAkB;IACjC,MAAM,CAAY;IACV,UAAU,CAAiC;IAE5D,YAAY,UAAyC,EAAE;QACrD,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACtH,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC;YAC1B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACjD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;gBAC7C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,IAAI;oBAAE,OAAO;gBACzD,MAAM,CAAC,IAAI,CAAC,I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C;YACjE,IAAI,MAAM,CAAC,cAAc,KAAK,YAAY;gBAAE,OAAO,MAAM,CAAC;QAC5D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,UAAyC,EAAE;IAC3F,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACrF,CAAC"}
@@ -1,50 +0,0 @@
1
- import type { Message } from "../types/messages.js";
2
- export type LocalTaskStatus = "pending" | "running" | "completed" | "failed" | "killed";
3
- export type LocalTaskType = "exec";
4
- export interface TaskProgressSnapshot {
5
- totalEvents: number;
6
- totalToolUseCount: number;
7
- lastActivity?: string;
8
- lastText?: string;
9
- }
10
- export interface LocalTask {
11
- id: string;
12
- taskId: string;
13
- agentId: string;
14
- type: LocalTaskType;
15
- status: LocalTaskStatus;
16
- description: string;
17
- prompt: string;
18
- messages: Message[];
19
- progress: TaskProgressSnapshot;
20
- outputFile: string;
21
- result?: TaskResult;
22
- error?: string;
23
- notified: boolean;
24
- retain: boolean;
25
- abortController?: AbortController;
26
- createdAt: string;
27
- updatedAt: string;
28
- completedAt?: string;
29
- }
30
- export interface TaskResult {
31
- agent_id: string;
32
- agent_type: string;
33
- content: string;
34
- total_duration_ms: number;
35
- total_tokens?: number;
36
- total_tool_use_count: number;
37
- usage?: unknown;
38
- }
39
- export declare function createLocalTask(input: {
40
- taskId: string;
41
- agentId: string;
42
- description: string;
43
- prompt: string;
44
- type?: LocalTaskType;
45
- outputFile?: string;
46
- abortController?: AbortController;
47
- retain?: boolean;
48
- }): LocalTask;
49
- export declare function writeLocalTaskOutput(task: LocalTask): void;
50
- export declare function renderLocalTaskOutput(task: LocalTask): string;
@@ -1,50 +0,0 @@
1
- import { mkdirSync, writeFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
- import { getNeoctlHome } from "../paths.js";
4
- export function createLocalTask(input) {
5
- const now = new Date().toISOString();
6
- return {
7
- id: input.taskId,
8
- taskId: input.taskId,
9
- agentId: input.agentId,
10
- type: input.type ?? "exec",
11
- status: "pending",
12
- description: input.description,
13
- prompt: input.prompt,
14
- messages: [],
15
- progress: { totalEvents: 0, totalToolUseCount: 0 },
16
- outputFile: input.outputFile ?? defaultTaskOutputFile(input.taskId),
17
- notified: false,
18
- retain: input.retain ?? true,
19
- abortController: input.abortController,
20
- createdAt: now,
21
- updatedAt: now,
22
- };
23
- }
24
- export function writeLocalTaskOutput(task) {
25
- const content = renderLocalTaskOutput(task);
26
- mkdirSync(resolve(task.outputFile, ".."), { recursive: true });
27
- writeFileSync(task.outputFile, content, "utf8");
28
- }
29
- export function renderLocalTaskOutput(task) {
30
- return [
31
- `task_id: ${task.taskId}`,
32
- `agent_id: ${task.agentId}`,
33
- `status: ${task.status}`,
34
- `description: ${task.description}`,
35
- `created_at: ${task.createdAt}`,
36
- `updated_at: ${task.updatedAt}`,
37
- task.completedAt ? `completed_at: ${task.completedAt}` : undefined,
38
- "",
39
- "prompt:",
40
- task.prompt,
41
- "",
42
- "result:",
43
- task.result?.content ?? "",
44
- task.error ? `\nerror:\n${task.error}` : undefined,
45
- ].filter((line) => line !== undefined).join("\n");
46
- }
47
- function defaultTaskOutputFile(taskId) {
48
- return resolve(getNeoctlHome(), "tasks", `${taskId}.txt`);
49
- }
50
- //# sourceMappingURL=task-record.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"task-record.js","sourceRoot":"","sources":["../../src/tasks/task-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAA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C,MAAM,EAAE;QACxB,gBAAgB,IAAI,CAAC,WAAW,EAAE;QAClC,eAAe,IAAI,CAAC,SAAS,EAAE;QAC/B,eAAe,IAAI,CAAC,SAAS,EAAE;QAC/B,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QAClE,EAAE;QACF,SAAS;QACT,IAAI,CAAC,MAAM;QACX,EAAE;QACF,SAAS;QACT,IAAI,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE;QAC1B,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS;KACnD,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAc;IAC3C,OAAO,OAAO,CAAC,aAAa,EAAE,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { Tool } from "../tool.js";
2
- export declare const echoTool: Tool<{
3
- text: string;
4
- }>;
@@ -1,26 +0,0 @@
1
- export const echoTool = {
2
- name: "echo",
3
- aliases: ["say"],
4
- description: "Return the provided text. Useful for wiring tests before real tools exist.",
5
- inputSchema: {
6
- type: "object",
7
- properties: { text: { type: "string", description: "Text to return." } },
8
- required: ["text"],
9
- additionalProperties: false,
10
- },
11
- metadata: { readOnly: true, concurrent: true, visible: true, maxResultSizeChars: 4096, searchHint: "echo text" },
12
- validate(input) {
13
- return { text: input.text };
14
- },
15
- validateInput(input) {
16
- return input.text.length > 0 ? { ok: true, value: input } : { ok: false, message: "echo.text cannot be empty" };
17
- },
18
- isConcurrencySafe() {
19
- return true;
20
- },
21
- async call(input, _context, options) {
22
- options.onProgress?.({ toolName: "echo", message: "Echo text prepared" });
23
- return { ok: true, output: input.text };
24
- },
25
- };
26
- //# sourceMappingURL=echo-tool.js.map