pi-fabric 0.92.4 → 0.92.5
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/agents/service-provider.d.ts.map +1 -1
- package/dist/agents/service-schema.d.ts.map +1 -1
- package/dist/agents/service-types.d.ts +66 -3
- package/dist/agents/service-types.d.ts.map +1 -1
- package/dist/agents/service.d.ts +14 -3
- package/dist/agents/service.d.ts.map +1 -1
- package/dist/agents.js +149 -9
- package/dist/agents.js.map +2 -2
- package/dist/ui/conversation-queue.d.ts +2 -0
- package/dist/ui/conversation-queue.d.ts.map +1 -1
- package/dist/ui/conversation.js +16 -6
- package/dist/ui/conversation.js.map +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../../src/agents/service-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAsB,wBAAwB,EAAE,kBAAkB,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../../src/agents/service-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAsB,wBAAwB,EAAE,kBAAkB,EAAE,sBAAsB,EAA8D,MAAM,oBAAoB,CAAC;AAE/L,0FAA0F;AAC1F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAuBzG;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,sBAAsB,EAAE,YAAY,GAAE,wBAA6B,GAAG,kBAAkB,CAqB1I;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,cAAc,CAc/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-schema.d.ts","sourceRoot":"","sources":["../../src/agents/service-schema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-schema.d.ts","sourceRoot":"","sources":["../../src/agents/service-schema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAG7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAyB5G,wBAAgB,uBAAuB,CAAC,YAAY,GAAE,wBAA6B,GAAG,sBAAsB,EAAE,CAsB7G;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASpH;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAS5F"}
|
|
@@ -4,6 +4,7 @@ export type AgentServiceRequest = Pick<AgentRunRequest, "task" | "name" | "model
|
|
|
4
4
|
kernel?: "typescript" | "inherit";
|
|
5
5
|
extensions?: true;
|
|
6
6
|
worktree?: false;
|
|
7
|
+
residency?: "session" | "durable";
|
|
7
8
|
};
|
|
8
9
|
export type AgentServiceStatus = AgentRunRecord["status"] | "paused";
|
|
9
10
|
export type AgentServiceRecord = Omit<AgentRunRecord, "status" | "transport" | "cwd"> & {
|
|
@@ -66,23 +67,73 @@ export interface AgentExecutionPort {
|
|
|
66
67
|
steer?(request: AgentControlRequest & {
|
|
67
68
|
message: string;
|
|
68
69
|
}): Promise<void>;
|
|
70
|
+
followUp?(request: AgentControlRequest & {
|
|
71
|
+
message: string;
|
|
72
|
+
}): Promise<void>;
|
|
69
73
|
compact?(request: AgentControlRequest & {
|
|
70
74
|
instructions?: string;
|
|
71
75
|
}): Promise<void>;
|
|
72
76
|
cleanup?(request: AgentControlRequest): Promise<void>;
|
|
73
77
|
}
|
|
74
|
-
|
|
78
|
+
/** Host-authored session/peer identity. Same shape the native mesh publishes for roots. */
|
|
79
|
+
export type AgentSessionKind = "root" | "agent" | "actor";
|
|
80
|
+
export type AgentSessionCapability = "steer" | "followUp" | "stop" | "ask";
|
|
81
|
+
export interface AgentSessionRecord {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
kind: AgentSessionKind;
|
|
85
|
+
status: string;
|
|
86
|
+
capabilities: AgentSessionCapability[];
|
|
87
|
+
}
|
|
88
|
+
export interface AgentTopologyDeliverRequest {
|
|
89
|
+
callerId: string;
|
|
90
|
+
id: string;
|
|
91
|
+
operation: "steer" | "followUp";
|
|
92
|
+
message: string;
|
|
93
|
+
signal?: AbortSignal;
|
|
94
|
+
}
|
|
95
|
+
export interface AgentTopologyCreateRequest {
|
|
96
|
+
callerId: string;
|
|
97
|
+
name: string;
|
|
98
|
+
instructions?: string;
|
|
99
|
+
task?: string;
|
|
100
|
+
signal?: AbortSignal;
|
|
101
|
+
}
|
|
102
|
+
export interface AgentTopologyRemoveRequest {
|
|
103
|
+
callerId: string;
|
|
104
|
+
id: string;
|
|
105
|
+
name?: string;
|
|
106
|
+
signal?: AbortSignal;
|
|
107
|
+
}
|
|
108
|
+
export interface AgentTopologyDispatchRequest {
|
|
109
|
+
callerId: string;
|
|
110
|
+
request: AgentServiceRequest;
|
|
111
|
+
signal?: AbortSignal;
|
|
112
|
+
}
|
|
113
|
+
/** Host directory of live session agents and peers. Child one-shots stay on AgentExecutionPort. */
|
|
114
|
+
export interface AgentTopologyPort {
|
|
115
|
+
self(callerId: string): AgentSessionRecord | Promise<AgentSessionRecord>;
|
|
116
|
+
sessions(): AgentSessionRecord[] | Promise<AgentSessionRecord[]>;
|
|
117
|
+
peers(callerId: string): AgentSessionRecord[] | Promise<AgentSessionRecord[]>;
|
|
118
|
+
deliver(request: AgentTopologyDeliverRequest): Promise<AgentSessionRecord>;
|
|
119
|
+
create?(request: AgentTopologyCreateRequest): Promise<AgentSessionRecord>;
|
|
120
|
+
remove?(request: AgentTopologyRemoveRequest): Promise<AgentSessionRecord>;
|
|
121
|
+
dispatch?(request: AgentTopologyDispatchRequest): Promise<AgentSessionRecord>;
|
|
122
|
+
}
|
|
123
|
+
export type AgentServiceAction = "run" | "spawn" | "wait" | "status" | "list" | "stop" | "steer" | "compact" | "resume" | "followUp" | "sessions" | "peers" | "self" | "members" | "create" | "remove";
|
|
75
124
|
export interface AgentServiceCapabilities {
|
|
76
125
|
steer?: boolean;
|
|
77
126
|
compact?: boolean;
|
|
78
127
|
resume?: boolean;
|
|
128
|
+
followUp?: boolean;
|
|
129
|
+
topology?: boolean;
|
|
79
130
|
}
|
|
80
131
|
export interface AgentServiceEvent {
|
|
81
132
|
version: 1;
|
|
82
133
|
sequence: number;
|
|
83
134
|
type: "admitted" | "running" | "progress" | "checkpoint" | "settled" | "control";
|
|
84
135
|
record: AgentServiceRecord;
|
|
85
|
-
control?: "stop" | "steer" | "compact";
|
|
136
|
+
control?: "stop" | "steer" | "compact" | "followUp";
|
|
86
137
|
}
|
|
87
138
|
export interface AgentServiceSnapshot {
|
|
88
139
|
version: 1;
|
|
@@ -107,6 +158,7 @@ export interface AgentServiceOptions {
|
|
|
107
158
|
assertAuthority?(callerId: string, boundary?: AgentAuthorityBoundary): void | Promise<void>;
|
|
108
159
|
onEvent?(event: AgentServiceEvent): void | Promise<void>;
|
|
109
160
|
snapshot?: AgentServiceSnapshot;
|
|
161
|
+
topology?: AgentTopologyPort;
|
|
110
162
|
/** Trusted host only: a new root turn rebases lineage and resets admission, never generations. */
|
|
111
163
|
restorePolicy?: "preserve" | "new-root";
|
|
112
164
|
}
|
|
@@ -120,8 +172,19 @@ export interface AgentServiceClient {
|
|
|
120
172
|
status(id: string): Promise<AgentPublicRecord>;
|
|
121
173
|
list(): Promise<AgentPublicRecord[]>;
|
|
122
174
|
stop(id: string): Promise<AgentPublicRecord>;
|
|
123
|
-
steer(id: string, message: string): Promise<AgentPublicRecord>;
|
|
175
|
+
steer(id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord>;
|
|
124
176
|
compact(id: string, instructions?: string): Promise<AgentPublicRecord>;
|
|
125
177
|
resume(id: string, task?: string, signal?: AbortSignal): Promise<AgentPublicRecord>;
|
|
178
|
+
followUp(id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord>;
|
|
179
|
+
sessions(): Promise<AgentSessionRecord[]>;
|
|
180
|
+
peers(): Promise<AgentSessionRecord[]>;
|
|
181
|
+
self(): Promise<AgentSessionRecord>;
|
|
182
|
+
members(): Promise<AgentSessionRecord[]>;
|
|
183
|
+
create(request: {
|
|
184
|
+
name: string;
|
|
185
|
+
instructions?: string;
|
|
186
|
+
task?: string;
|
|
187
|
+
}, signal?: AbortSignal): Promise<AgentSessionRecord>;
|
|
188
|
+
remove(id: string, name?: string, signal?: AbortSignal): Promise<AgentSessionRecord>;
|
|
126
189
|
}
|
|
127
190
|
//# sourceMappingURL=service-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../src/agents/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,eAAe,EACpD,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,cAAc,GAAG,WAAW,GAAG,KAAK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GED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentPublicRecord, AgentServiceCapabilities, AgentServiceOptions, AgentServiceRequest, AgentServiceSnapshot } from "./service-types.js";
|
|
1
|
+
import type { AgentPublicRecord, AgentServiceCapabilities, AgentServiceOptions, AgentServiceRequest, AgentSessionRecord, AgentServiceSnapshot } from "./service-types.js";
|
|
2
2
|
/** Portable one-shot agent authority. The execution port runs one participant, never a tree. */
|
|
3
3
|
export declare class AgentService {
|
|
4
4
|
#private;
|
|
@@ -6,12 +6,23 @@ export declare class AgentService {
|
|
|
6
6
|
constructor(options: AgentServiceOptions);
|
|
7
7
|
snapshot(): AgentServiceSnapshot;
|
|
8
8
|
run(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord>;
|
|
9
|
-
spawn(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord>;
|
|
9
|
+
spawn(callerId: string, request: AgentServiceRequest, signal?: AbortSignal): Promise<AgentPublicRecord | AgentSessionRecord>;
|
|
10
10
|
wait(callerId: string, id: string, signal?: AbortSignal): Promise<AgentPublicRecord>;
|
|
11
11
|
status(callerId: string, id: string): Promise<AgentPublicRecord>;
|
|
12
12
|
list(callerId: string): Promise<AgentPublicRecord[]>;
|
|
13
13
|
stop(callerId: string, id: string): Promise<AgentPublicRecord>;
|
|
14
|
-
steer(callerId: string, id: string, message: string): Promise<AgentPublicRecord>;
|
|
14
|
+
steer(callerId: string, id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord>;
|
|
15
|
+
followUp(callerId: string, id: string, message: string): Promise<AgentPublicRecord | AgentSessionRecord>;
|
|
16
|
+
sessions(callerId: string): Promise<AgentSessionRecord[]>;
|
|
17
|
+
peers(callerId: string): Promise<AgentSessionRecord[]>;
|
|
18
|
+
self(callerId: string): Promise<AgentSessionRecord>;
|
|
19
|
+
create(callerId: string, request: {
|
|
20
|
+
name: string;
|
|
21
|
+
instructions?: string;
|
|
22
|
+
task?: string;
|
|
23
|
+
}, signal?: AbortSignal): Promise<AgentSessionRecord>;
|
|
24
|
+
remove(callerId: string, id: string, name?: string, signal?: AbortSignal): Promise<AgentSessionRecord>;
|
|
25
|
+
members(callerId: string): Promise<AgentSessionRecord[]>;
|
|
15
26
|
compact(callerId: string, id: string, instructions?: string): Promise<AgentPublicRecord>;
|
|
16
27
|
resume(callerId: string, id: string, task?: string, signal?: AbortSignal): Promise<AgentPublicRecord>;
|
|
17
28
|
/** Natural root completion waits for all background descendants without fencing live parents. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/agents/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA0B,iBAAiB,EAAoE,wBAAwB,EAAqB,mBAAmB,EAAsB,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/agents/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAA0B,iBAAiB,EAAoE,wBAAwB,EAAqB,mBAAmB,EAAsB,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAyB3S,gGAAgG;AAChG,qBAAa,YAAY;;IAWvB,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAC;gBAEpC,OAAO,EAAE,mBAAmB;IAiBxC,QAAQ,IAAI,oBAAoB;IAK1B,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKrG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,GAAG,kBAAkB,CAAC;IAa5H,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MA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Q,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAkBxD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKxF,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAa3G,iGAAiG;IAC3F,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAW5B,8FAA8F;IAC9F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAqCxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAwSvB"}
|
package/dist/agents.js
CHANGED
|
@@ -42,18 +42,30 @@ Object.assign(properties, {
|
|
|
42
42
|
systemPrompt: { type: "string" }
|
|
43
43
|
});
|
|
44
44
|
var runSchema = { type: "object", properties, required: ["task"], additionalProperties: false };
|
|
45
|
+
var spawnSchema = { type: "object", properties: { ...properties, residency: { type: "string", enum: ["session", "durable"] } }, required: ["task"], additionalProperties: false };
|
|
45
46
|
var id = { type: "string", minLength: 1 };
|
|
46
47
|
var object = (properties2, required = []) => ({ type: "object", properties: properties2, required, additionalProperties: false });
|
|
47
48
|
function agentServiceDescriptors(capabilities = {}) {
|
|
48
49
|
const descriptors2 = [
|
|
49
50
|
{ ...run, description: "Run one host-authorized Pi child and wait for its result or pause", inputSchema: runSchema },
|
|
50
|
-
{ ...native("spawn"), description: "Admit one host-authorized Pi child
|
|
51
|
+
{ ...native("spawn"), description: "Admit one host-authorized Pi child, or residency durable for an independent host worker", inputSchema: spawnSchema },
|
|
51
52
|
...["wait", "status", "stop"].map((name) => ({ ...native(name), inputSchema: object({ id }, ["id"]) })),
|
|
52
53
|
{ ...native("list"), description: "List only the authenticated caller's direct children", inputSchema: object({}) }
|
|
53
54
|
];
|
|
54
55
|
if (capabilities.steer) descriptors2.push({ ...native("steer"), inputSchema: object({ id, message: { type: "string", minLength: 1 } }, ["id", "message"]) });
|
|
56
|
+
if (capabilities.followUp) descriptors2.push({ ...native("followUp"), inputSchema: object({ id, message: { type: "string", minLength: 1 } }, ["id", "message"]) });
|
|
55
57
|
if (capabilities.compact) descriptors2.push({ ...native("compact"), inputSchema: object({ id, instructions: { type: "string" } }, ["id"]) });
|
|
56
58
|
if (capabilities.resume) descriptors2.push({ name: "resume", description: "Continue a paused, completed or failed direct child from its host checkpoint and wait for result or pause", risk: "agent", inputSchema: object({ id, task: { type: "string", minLength: 1 } }, ["id"]) });
|
|
59
|
+
if (capabilities.topology) {
|
|
60
|
+
descriptors2.push(
|
|
61
|
+
{ ...native("sessions"), inputSchema: object({}) },
|
|
62
|
+
{ ...native("peers"), inputSchema: object({}) },
|
|
63
|
+
{ ...native("self"), inputSchema: object({}) },
|
|
64
|
+
{ ...native("members"), inputSchema: object({}) },
|
|
65
|
+
{ ...native("create"), description: "Create a lasting session peer in this project", inputSchema: object({ name: { type: "string", minLength: 1 }, instructions: { type: "string" }, task: { type: "string" } }, ["name"]) },
|
|
66
|
+
{ ...native("remove"), description: "Stop and remove a lasting session peer created in this project", inputSchema: object({ id: { type: "string", minLength: 1 }, name: { type: "string" } }, ["id"]) }
|
|
67
|
+
);
|
|
68
|
+
}
|
|
57
69
|
return descriptors2;
|
|
58
70
|
}
|
|
59
71
|
var descriptors = agentServiceDescriptors({ steer: true, compact: true, resume: true });
|
|
@@ -69,10 +81,12 @@ function agentServiceArgs(action, input) {
|
|
|
69
81
|
return args;
|
|
70
82
|
}
|
|
71
83
|
function normalizeAgentServiceRequest(input) {
|
|
72
|
-
const
|
|
84
|
+
const { residency, ...rest } = input;
|
|
85
|
+
const args = agentServiceArgs("run", rest);
|
|
73
86
|
const request = normalizeAgentRunRequest(args, { runner: "pi", timeoutMs: 0 });
|
|
74
87
|
if (args.images !== void 0) request.images = structuredClone(args.images);
|
|
75
88
|
if (args.systemPrompt !== void 0) request.systemPrompt = args.systemPrompt;
|
|
89
|
+
if (residency === "session" || residency === "durable") request.residency = residency;
|
|
76
90
|
assertAgentTask(request);
|
|
77
91
|
return structuredClone(request);
|
|
78
92
|
}
|
|
@@ -105,7 +119,13 @@ var AgentService = class {
|
|
|
105
119
|
}
|
|
106
120
|
this.#options = { ...options, port: options.port };
|
|
107
121
|
this.#admission = new AgentAdmission(options.maxConcurrent ?? 4, options.maxStarts ?? 8, options.maxDepth ?? 3);
|
|
108
|
-
this.capabilities = Object.freeze({
|
|
122
|
+
this.capabilities = Object.freeze({
|
|
123
|
+
steer: Boolean(options.port.steer || options.topology),
|
|
124
|
+
compact: Boolean(options.port.compact),
|
|
125
|
+
resume: Boolean(options.port.resume),
|
|
126
|
+
followUp: Boolean(options.port.followUp || options.topology),
|
|
127
|
+
topology: Boolean(options.topology)
|
|
128
|
+
});
|
|
109
129
|
if (options.snapshot) this.#restore(options.snapshot);
|
|
110
130
|
}
|
|
111
131
|
snapshot() {
|
|
@@ -122,7 +142,16 @@ var AgentService = class {
|
|
|
122
142
|
return this.wait(callerId, handle.id, signal);
|
|
123
143
|
}
|
|
124
144
|
async spawn(callerId, request, signal) {
|
|
125
|
-
|
|
145
|
+
const normalized = normalizeAgentServiceRequest(request);
|
|
146
|
+
if (normalized.residency === "durable") {
|
|
147
|
+
await this.#authorize(callerId);
|
|
148
|
+
const dispatch = this.#topology().dispatch;
|
|
149
|
+
if (!dispatch) throw new Error("Durable hosted spawn is unavailable");
|
|
150
|
+
const record = await dispatch({ callerId, request: normalized, ...signal ? { signal } : {} });
|
|
151
|
+
await this.#authorize(callerId);
|
|
152
|
+
return copy(record);
|
|
153
|
+
}
|
|
154
|
+
return this.#start(callerId, normalized, void 0, signal);
|
|
126
155
|
}
|
|
127
156
|
async wait(callerId, id2, signal) {
|
|
128
157
|
await this.#authorize(callerId);
|
|
@@ -147,9 +176,83 @@ var AgentService = class {
|
|
|
147
176
|
return publicRecord(result);
|
|
148
177
|
}
|
|
149
178
|
async steer(callerId, id2, message) {
|
|
150
|
-
if (!this.#options.port.steer) throw new Error("Hosted agents.steer is unsupported");
|
|
151
179
|
if (!message.trim()) throw new Error("Steering message must not be empty");
|
|
152
|
-
|
|
180
|
+
const child = this.#ownedChild(callerId, id2);
|
|
181
|
+
if (child) {
|
|
182
|
+
if (!this.#options.port.steer) throw new Error("Hosted agents.steer is unsupported");
|
|
183
|
+
return this.#control(callerId, child.record.id, "steer", (request) => this.#options.port.steer({ ...request, message }));
|
|
184
|
+
}
|
|
185
|
+
return this.#deliver(callerId, id2, "steer", message);
|
|
186
|
+
}
|
|
187
|
+
async followUp(callerId, id2, message) {
|
|
188
|
+
if (!message.trim()) throw new Error("Follow-up message must not be empty");
|
|
189
|
+
const child = this.#ownedChild(callerId, id2);
|
|
190
|
+
if (child) {
|
|
191
|
+
if (!this.#options.port.followUp) throw new Error("Hosted agents.followUp is unsupported");
|
|
192
|
+
if (child.record.status === "running" && !child.stopping) {
|
|
193
|
+
return this.#control(callerId, child.record.id, "followUp", (request) => this.#options.port.followUp({ ...request, message }));
|
|
194
|
+
}
|
|
195
|
+
await this.#authorize(callerId);
|
|
196
|
+
await this.#options.port.followUp({ ...this.#identity(child), message });
|
|
197
|
+
await this.#authorize(callerId);
|
|
198
|
+
return publicRecord(child.record);
|
|
199
|
+
}
|
|
200
|
+
return this.#deliver(callerId, id2, "followUp", message);
|
|
201
|
+
}
|
|
202
|
+
async sessions(callerId) {
|
|
203
|
+
await this.#authorize(callerId);
|
|
204
|
+
return copy(await this.#topology().sessions());
|
|
205
|
+
}
|
|
206
|
+
async peers(callerId) {
|
|
207
|
+
await this.#authorize(callerId);
|
|
208
|
+
return copy(await this.#topology().peers(callerId));
|
|
209
|
+
}
|
|
210
|
+
async self(callerId) {
|
|
211
|
+
await this.#authorize(callerId);
|
|
212
|
+
if (this.#options.topology) return copy(await this.#options.topology.self(callerId));
|
|
213
|
+
const child = callerId === this.#options.rootId ? void 0 : this.#entries.get(callerId);
|
|
214
|
+
return {
|
|
215
|
+
id: callerId,
|
|
216
|
+
name: child?.record.name ?? "main",
|
|
217
|
+
kind: callerId === this.#options.rootId ? "root" : "agent",
|
|
218
|
+
status: child?.record.status ?? "running",
|
|
219
|
+
capabilities: callerId === this.#options.rootId ? ["steer", "followUp", "stop"] : ["steer", "followUp", "stop"]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
async create(callerId, request, signal) {
|
|
223
|
+
if (!request.name.trim()) throw new Error("Peer name is required");
|
|
224
|
+
await this.#authorize(callerId);
|
|
225
|
+
const create = this.#topology().create;
|
|
226
|
+
if (!create) throw new Error("Hosted agents.create is unavailable");
|
|
227
|
+
const record = await create({ callerId, name: request.name.trim(), ...request.instructions ? { instructions: request.instructions } : {}, ...request.task ? { task: request.task } : {}, ...signal ? { signal } : {} });
|
|
228
|
+
await this.#authorize(callerId);
|
|
229
|
+
return copy(record);
|
|
230
|
+
}
|
|
231
|
+
async remove(callerId, id2, name, signal) {
|
|
232
|
+
if (!id2.trim()) throw new Error("Peer id is required");
|
|
233
|
+
await this.#authorize(callerId);
|
|
234
|
+
const remove = this.#topology().remove;
|
|
235
|
+
if (!remove) throw new Error("Hosted agents.remove is unavailable");
|
|
236
|
+
const record = await remove({ callerId, id: id2, ...name ? { name } : {}, ...signal ? { signal } : {} });
|
|
237
|
+
await this.#authorize(callerId);
|
|
238
|
+
return copy(record);
|
|
239
|
+
}
|
|
240
|
+
async members(callerId) {
|
|
241
|
+
await this.#authorize(callerId);
|
|
242
|
+
const sessions = this.#options.topology ? copy(await this.#options.topology.sessions()) : [];
|
|
243
|
+
const seen = new Set(sessions.map((item) => item.id));
|
|
244
|
+
const children = [];
|
|
245
|
+
for (const entry of this.#entries.values()) {
|
|
246
|
+
if (seen.has(entry.record.id)) continue;
|
|
247
|
+
children.push({
|
|
248
|
+
id: entry.record.id,
|
|
249
|
+
name: entry.record.name,
|
|
250
|
+
kind: "agent",
|
|
251
|
+
status: entry.record.status,
|
|
252
|
+
capabilities: ["steer", "followUp", "stop"]
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return [...sessions, ...children];
|
|
153
256
|
}
|
|
154
257
|
async compact(callerId, id2, instructions) {
|
|
155
258
|
if (!this.#options.port.compact) throw new Error("Hosted agents.compact is unsupported");
|
|
@@ -477,10 +580,26 @@ var AgentService = class {
|
|
|
477
580
|
if (this.#suspended && !boundary?.checkpoint) throw new Error("Agent service is paused");
|
|
478
581
|
}
|
|
479
582
|
#child(callerId, id2) {
|
|
480
|
-
const entry = this.#
|
|
481
|
-
if (!entry
|
|
583
|
+
const entry = this.#ownedChild(callerId, id2);
|
|
584
|
+
if (!entry) throw new Error(`Unknown direct child agent: ${id2}`);
|
|
482
585
|
return entry;
|
|
483
586
|
}
|
|
587
|
+
#ownedChild(callerId, id2) {
|
|
588
|
+
const entry = this.#entries.get(id2);
|
|
589
|
+
return entry && entry.record.parentId === callerId ? entry : void 0;
|
|
590
|
+
}
|
|
591
|
+
#topology() {
|
|
592
|
+
if (!this.#options.topology) throw new Error("Hosted agent topology is unavailable");
|
|
593
|
+
return this.#options.topology;
|
|
594
|
+
}
|
|
595
|
+
async #deliver(callerId, id2, operation, message) {
|
|
596
|
+
const topology = this.#topology();
|
|
597
|
+
await this.#authorize(callerId);
|
|
598
|
+
const target = id2 === "main" ? this.#options.rootId : id2;
|
|
599
|
+
const record = await topology.deliver({ callerId, id: target, operation, message });
|
|
600
|
+
await this.#authorize(callerId);
|
|
601
|
+
return copy(record);
|
|
602
|
+
}
|
|
484
603
|
#depth(callerId) {
|
|
485
604
|
if (this.#closing.signal.aborted) throw new Error("Agent service is closed");
|
|
486
605
|
if (this.#suspended) throw new Error("Agent service is paused");
|
|
@@ -560,10 +679,24 @@ function createAgentServiceHandler(service, callerId) {
|
|
|
560
679
|
return service.stop(callerId, args.id);
|
|
561
680
|
case "steer":
|
|
562
681
|
return service.steer(callerId, args.id, args.message);
|
|
682
|
+
case "followUp":
|
|
683
|
+
return service.followUp(callerId, args.id, args.message);
|
|
563
684
|
case "compact":
|
|
564
685
|
return service.compact(callerId, args.id, args.instructions);
|
|
565
686
|
case "resume":
|
|
566
687
|
return service.resume(callerId, args.id, args.task, signal);
|
|
688
|
+
case "sessions":
|
|
689
|
+
return service.sessions(callerId);
|
|
690
|
+
case "peers":
|
|
691
|
+
return service.peers(callerId);
|
|
692
|
+
case "self":
|
|
693
|
+
return service.self(callerId);
|
|
694
|
+
case "members":
|
|
695
|
+
return service.members(callerId);
|
|
696
|
+
case "create":
|
|
697
|
+
return service.create(callerId, args, signal);
|
|
698
|
+
case "remove":
|
|
699
|
+
return service.remove(callerId, args.id, args.name, signal);
|
|
567
700
|
default:
|
|
568
701
|
throw new Error(`Unsupported hosted agents action: ${String(action)}`);
|
|
569
702
|
}
|
|
@@ -582,7 +715,14 @@ function createAgentServiceClient(dispatch, capabilities = {}) {
|
|
|
582
715
|
stop: (id2) => record("stop", { id: id2 }),
|
|
583
716
|
steer: (id2, message) => record("steer", { id: id2, message }),
|
|
584
717
|
compact: (id2, instructions) => record("compact", { id: id2, ...instructions !== void 0 ? { instructions } : {} }),
|
|
585
|
-
resume: (id2, task, signal) => record("resume", { id: id2, ...task !== void 0 ? { task } : {} }, signal)
|
|
718
|
+
resume: (id2, task, signal) => record("resume", { id: id2, ...task !== void 0 ? { task } : {} }, signal),
|
|
719
|
+
followUp: (id2, message) => record("followUp", { id: id2, message }),
|
|
720
|
+
sessions: () => dispatch("sessions", {}),
|
|
721
|
+
peers: () => dispatch("peers", {}),
|
|
722
|
+
self: () => dispatch("self", {}),
|
|
723
|
+
members: () => dispatch("members", {}),
|
|
724
|
+
create: (request, signal) => dispatch("create", request, signal),
|
|
725
|
+
remove: (id2, name, signal) => dispatch("remove", { id: id2, ...name !== void 0 ? { name } : {} }, signal)
|
|
586
726
|
};
|
|
587
727
|
}
|
|
588
728
|
function createAgentsProvider(client) {
|