@xenosystem/acp-agent 0.1.1 → 0.2.1
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/acpAgentServer.d.ts.map +1 -1
- package/dist/acpAgentServer.js +56 -0
- package/dist/acpAgentServer.js.map +1 -1
- package/dist/cli.js +28 -1
- package/dist/cli.js.map +1 -1
- package/dist/fixtureProvider.d.ts +13 -0
- package/dist/fixtureProvider.d.ts.map +1 -0
- package/dist/fixtureProvider.js +86 -0
- package/dist/fixtureProvider.js.map +1 -0
- package/dist/hosted/xeno-agents-client.d.ts +306 -0
- package/dist/hosted/xeno-agents-client.d.ts.map +1 -0
- package/dist/hosted/xeno-agents-client.js +520 -0
- package/dist/hosted/xeno-agents-client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/fixtureProvider.d.ts.map +1 -1
- package/dist/providers/fixtureProvider.js +20 -0
- package/dist/providers/fixtureProvider.js.map +1 -1
- package/dist/providers/providerRegistry.d.ts.map +1 -1
- package/dist/providers/providerRegistry.js +2 -0
- package/dist/providers/providerRegistry.js.map +1 -1
- package/dist/providers/providerTypes.d.ts +25 -0
- package/dist/providers/providerTypes.d.ts.map +1 -1
- package/dist/providers/xenoAgentsApiEventMapper.d.ts +52 -0
- package/dist/providers/xenoAgentsApiEventMapper.d.ts.map +1 -0
- package/dist/providers/xenoAgentsApiEventMapper.js +152 -0
- package/dist/providers/xenoAgentsApiEventMapper.js.map +1 -0
- package/dist/providers/xenoAgentsApiProvider.d.ts +60 -0
- package/dist/providers/xenoAgentsApiProvider.d.ts.map +1 -0
- package/dist/providers/xenoAgentsApiProvider.js +302 -0
- package/dist/providers/xenoAgentsApiProvider.js.map +1 -0
- package/dist/providers/xenoSdkAdapterProcess.d.ts +50 -0
- package/dist/providers/xenoSdkAdapterProcess.d.ts.map +1 -0
- package/dist/providers/xenoSdkAdapterProcess.js +65 -0
- package/dist/providers/xenoSdkAdapterProcess.js.map +1 -0
- package/dist/providers/xenoSdkProvider.d.ts +85 -0
- package/dist/providers/xenoSdkProvider.d.ts.map +1 -0
- package/dist/providers/xenoSdkProvider.js +212 -0
- package/dist/providers/xenoSdkProvider.js.map +1 -0
- package/dist/version.d.ts +9 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +9 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `xeno-agents-api` — drive a XENO **hosted agent run** through the ACP provider contract.
|
|
3
|
+
*
|
|
4
|
+
* Unlike every other provider in this package, this one does NOT spawn a local CLI/process. It
|
|
5
|
+
* maps the frozen v1 provider-runtime contract (definition → session → prompt → cancel) onto the
|
|
6
|
+
* hosted-runs wire client (`../hosted/xeno-agents-client.ts`, the vendored `@xeno/agents-client`):
|
|
7
|
+
*
|
|
8
|
+
* - `createSession()` → allocates an ACP-local session id; run creation is deferred to prompt.
|
|
9
|
+
* - `prompt(request, ctx)` → `client.createRun({ prompt })` + `client.attach(runId)`, translating
|
|
10
|
+
* each hosted `RunEvent` to `ProviderEvent`s (see
|
|
11
|
+
* `xenoAgentsApiEventMapper.ts`) which the ACP server maps to
|
|
12
|
+
* `session/update` notifications. Token usage is returned in the result.
|
|
13
|
+
* - `cancel(sessionId)` → `client.stopRun(runId)` (graceful) + the prompt AbortSignal breaks attach.
|
|
14
|
+
*
|
|
15
|
+
* The run executes in the CLOUD (api.xenostudio.ai); this provider is a thin, streaming bridge. It
|
|
16
|
+
* therefore truthfully declares `authRequirement`/`networkRequirement: required` and carries no
|
|
17
|
+
* LOCAL filesystem/terminal authority (the hosted run does its own I/O server-side). Consequently
|
|
18
|
+
* the capability gate classifies it `requires_approval` — it never runs "just because it exists";
|
|
19
|
+
* the CLI's `resolveProviderStatus` (policy + approval) is the authoritative run-gate, exactly like
|
|
20
|
+
* `claude-local`.
|
|
21
|
+
*
|
|
22
|
+
* AUTH/CONFIG INTEGRATION POINT (xeno-acp has NO account layer): the platform bearer token + base
|
|
23
|
+
* URL are supplied via provider `options` — `{ token, baseUrl?, workspace?, fetchImpl?, client? }` —
|
|
24
|
+
* or, as a fallback, the `XENO_AGENTS_API_TOKEN` / `XENO_AGENTS_API_BASE_URL` /
|
|
25
|
+
* `XENO_AGENTS_API_WORKSPACE` environment variables. An embedder (e.g. XENO Hub) that already holds
|
|
26
|
+
* a token injects it directly through `options.token`; tests inject a mock `options.client`.
|
|
27
|
+
*/
|
|
28
|
+
import { createAgentsClient, isAgentsApiError } from "../hosted/xeno-agents-client.js";
|
|
29
|
+
import { createEventFactory } from "./providerEvents.js";
|
|
30
|
+
import { ProviderConfigurationError, ProviderInternalError } from "./providerErrors.js";
|
|
31
|
+
import { renderPromptText } from "./claudeLocalProvider.js";
|
|
32
|
+
import { extractRunUsage, mapRunEventToProviderPayloads, terminalDispositionFor, } from "./xenoAgentsApiEventMapper.js";
|
|
33
|
+
export const XENO_AGENTS_API_ID = "xeno-agents-api";
|
|
34
|
+
export const XENO_AGENTS_API_DEFAULT_HOST = "api.xenostudio.ai";
|
|
35
|
+
/** Truthful capability declaration: streams text + tool calls, needs auth + network, no LOCAL I/O. */
|
|
36
|
+
export const XENO_AGENTS_API_CAPABILITIES = {
|
|
37
|
+
streamsText: true,
|
|
38
|
+
emitsPlan: false,
|
|
39
|
+
emitsToolCalls: true,
|
|
40
|
+
emitsUsage: true,
|
|
41
|
+
supportsCancel: true,
|
|
42
|
+
supportsMultipleSessions: true,
|
|
43
|
+
requiresAuth: true, // a platform bearer token
|
|
44
|
+
usesNetwork: true, // calls api.xenostudio.ai
|
|
45
|
+
canReadFiles: false, // the hosted run does its own I/O in the cloud, not on this machine
|
|
46
|
+
canWriteFiles: false,
|
|
47
|
+
canRunTerminal: false,
|
|
48
|
+
};
|
|
49
|
+
/** Env fallbacks used only when the corresponding option is not supplied. */
|
|
50
|
+
export const XENO_AGENTS_API_TOKEN_ENV = "XENO_AGENTS_API_TOKEN";
|
|
51
|
+
export const XENO_AGENTS_API_BASE_URL_ENV = "XENO_AGENTS_API_BASE_URL";
|
|
52
|
+
export const XENO_AGENTS_API_WORKSPACE_ENV = "XENO_AGENTS_API_WORKSPACE";
|
|
53
|
+
class XenoAgentsApiRuntime {
|
|
54
|
+
definition;
|
|
55
|
+
options;
|
|
56
|
+
client;
|
|
57
|
+
sessionSeq = 0;
|
|
58
|
+
promptCount = 0;
|
|
59
|
+
/** Active hosted run id per ACP session, so `cancel` can stop the right run. */
|
|
60
|
+
activeRuns = new Map();
|
|
61
|
+
constructor(definition, config) {
|
|
62
|
+
this.definition = definition;
|
|
63
|
+
this.options = (config?.options ?? {});
|
|
64
|
+
}
|
|
65
|
+
initialize() { }
|
|
66
|
+
createSession() {
|
|
67
|
+
this.sessionSeq += 1;
|
|
68
|
+
return { sessionId: `${XENO_AGENTS_API_ID}-session-${this.sessionSeq}`, createdAt: new Date().toISOString() };
|
|
69
|
+
}
|
|
70
|
+
cancel(sessionId) {
|
|
71
|
+
const runId = this.activeRuns.get(sessionId);
|
|
72
|
+
if (!runId)
|
|
73
|
+
return;
|
|
74
|
+
// Fire-and-forget graceful stop; the prompt's AbortSignal also breaks the attach loop.
|
|
75
|
+
const client = this.client;
|
|
76
|
+
if (client) {
|
|
77
|
+
void client.stopRun(runId).catch(() => {
|
|
78
|
+
/* best-effort; the run may already be terminal */
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
dispose() {
|
|
83
|
+
this.activeRuns.clear();
|
|
84
|
+
}
|
|
85
|
+
diagnostics() {
|
|
86
|
+
return {
|
|
87
|
+
provider: this.definition.id,
|
|
88
|
+
sessionsCreated: this.sessionSeq,
|
|
89
|
+
promptsRun: this.promptCount,
|
|
90
|
+
activeRuns: this.activeRuns.size,
|
|
91
|
+
baseUrl: this.client?.baseUrl,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Resolve (once) the hosted-runs client from an injected client, options, or env. */
|
|
95
|
+
resolveClient() {
|
|
96
|
+
if (this.client)
|
|
97
|
+
return this.client;
|
|
98
|
+
if (this.options.client) {
|
|
99
|
+
this.client = this.options.client;
|
|
100
|
+
return this.client;
|
|
101
|
+
}
|
|
102
|
+
const token = this.options.token ?? envToken();
|
|
103
|
+
if (!token) {
|
|
104
|
+
throw new ProviderConfigurationError({
|
|
105
|
+
safeMessage: `${XENO_AGENTS_API_ID} requires a platform token (options.token or ${XENO_AGENTS_API_TOKEN_ENV})`,
|
|
106
|
+
providerId: this.definition.id,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const baseUrl = this.options.baseUrl ?? envString(XENO_AGENTS_API_BASE_URL_ENV);
|
|
110
|
+
const workspace = this.options.workspace ?? envString(XENO_AGENTS_API_WORKSPACE_ENV);
|
|
111
|
+
this.client = createAgentsClient({
|
|
112
|
+
token,
|
|
113
|
+
...(baseUrl ? { baseUrl } : {}),
|
|
114
|
+
...(workspace ? { workspace } : {}),
|
|
115
|
+
...(this.options.fetchImpl ? { fetchImpl: this.options.fetchImpl } : {}),
|
|
116
|
+
});
|
|
117
|
+
return this.client;
|
|
118
|
+
}
|
|
119
|
+
async prompt(request, ctx) {
|
|
120
|
+
this.promptCount += 1;
|
|
121
|
+
let client;
|
|
122
|
+
try {
|
|
123
|
+
client = this.resolveClient();
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
const error = err instanceof ProviderConfigurationError
|
|
127
|
+
? err
|
|
128
|
+
: new ProviderConfigurationError({ safeMessage: "failed to configure hosted client", providerId: this.definition.id });
|
|
129
|
+
ctx.emit(factoryFor(this.definition.id, request).next("failed", { disposition: "failed", message: error.safeMessage }));
|
|
130
|
+
return { disposition: "failed", error };
|
|
131
|
+
}
|
|
132
|
+
const promptText = renderPromptText(request.prompt, request.systemPrompt) || "Reply concisely.";
|
|
133
|
+
const factory = factoryFor(this.definition.id, request);
|
|
134
|
+
const emit = (kind, payload) => ctx.emit(factory.next(kind, payload));
|
|
135
|
+
const model = request.model ?? this.options.model;
|
|
136
|
+
const createInput = {
|
|
137
|
+
prompt: promptText,
|
|
138
|
+
...(model ? { model } : {}),
|
|
139
|
+
...(request.cwd ? { cwd: request.cwd } : {}),
|
|
140
|
+
// This provider forwards `cwd`: an ACP client asks it to work IN a
|
|
141
|
+
// directory, so file work is the expected outcome, not an edge case.
|
|
142
|
+
// The server ENFORCES permissionMode and reads an omitted one as
|
|
143
|
+
// `default` — Read/Glob/Grep allowed, Write/Edit REFUSED — which would
|
|
144
|
+
// leave this provider able to read files it can never change, and fail
|
|
145
|
+
// silently at that. Say what we need explicitly.
|
|
146
|
+
//
|
|
147
|
+
// `acceptEdits` is the NARROWEST mode that permits edits inside the run's
|
|
148
|
+
// jail. `bypassPermissions` would also work and is deliberately NOT used:
|
|
149
|
+
// it is blanket autonomy that ignores deny rules, which is more authority
|
|
150
|
+
// than "edit the workspace you were pointed at" requires.
|
|
151
|
+
//
|
|
152
|
+
// Overridable: `runDefaults` spreads last, so an embedder can still pin
|
|
153
|
+
// this to `plan`/`default` for a read-only deployment.
|
|
154
|
+
permissionMode: "acceptEdits",
|
|
155
|
+
...(this.options.runDefaults ?? {}),
|
|
156
|
+
};
|
|
157
|
+
let usage;
|
|
158
|
+
let disposition = "completed";
|
|
159
|
+
let saw = false;
|
|
160
|
+
try {
|
|
161
|
+
const run = await client.createRun(createInput, { signal: ctx.signal });
|
|
162
|
+
this.activeRuns.set(request.sessionId, run.runId);
|
|
163
|
+
ctx.log(`hosted run created: ${run.runId} (status=${run.status})`);
|
|
164
|
+
for await (const ev of client.attach(run.runId, { signal: ctx.signal, reconnect: true })) {
|
|
165
|
+
const u = extractRunUsage(ev);
|
|
166
|
+
if (u)
|
|
167
|
+
usage = u;
|
|
168
|
+
for (const mapped of mapRunEventToProviderPayloads(ev)) {
|
|
169
|
+
emit(mapped.kind, mapped.payload);
|
|
170
|
+
}
|
|
171
|
+
const terminal = terminalDispositionFor(ev.type);
|
|
172
|
+
if (terminal) {
|
|
173
|
+
disposition = terminal;
|
|
174
|
+
saw = true;
|
|
175
|
+
if (terminal === "failed") {
|
|
176
|
+
const message = ev.error ?? ev.reason ?? "hosted run failed";
|
|
177
|
+
emit("failed", { disposition: "failed", message });
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
// A caller-driven abort surfaces as an aborted signal → treat as cancelled, not failed.
|
|
185
|
+
if (ctx.signal.aborted) {
|
|
186
|
+
emit("cancelled", { disposition: "cancelled" });
|
|
187
|
+
return { disposition: "cancelled", ...(usage ? { usage } : {}) };
|
|
188
|
+
}
|
|
189
|
+
const safeMessage = isAgentsApiError(err)
|
|
190
|
+
? `hosted run error: ${err.code} (HTTP ${err.status})`
|
|
191
|
+
: `hosted run error: ${err?.message ?? String(err)}`;
|
|
192
|
+
const error = new ProviderInternalError({ safeMessage, providerId: this.definition.id });
|
|
193
|
+
emit("failed", { disposition: "failed", message: safeMessage });
|
|
194
|
+
return { disposition: "failed", error, ...(usage ? { usage } : {}) };
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
this.activeRuns.delete(request.sessionId);
|
|
198
|
+
}
|
|
199
|
+
if (ctx.signal.aborted && !saw) {
|
|
200
|
+
emit("cancelled", { disposition: "cancelled" });
|
|
201
|
+
return { disposition: "cancelled", ...(usage ? { usage } : {}) };
|
|
202
|
+
}
|
|
203
|
+
if (disposition === "cancelled") {
|
|
204
|
+
emit("cancelled", { disposition: "cancelled" });
|
|
205
|
+
}
|
|
206
|
+
else if (disposition === "completed") {
|
|
207
|
+
emit("completed", { disposition: "completed" });
|
|
208
|
+
}
|
|
209
|
+
return { disposition, ...(usage ? { usage } : {}) };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function factoryFor(providerId, request) {
|
|
213
|
+
return createEventFactory({
|
|
214
|
+
providerId,
|
|
215
|
+
sessionId: request.sessionId,
|
|
216
|
+
requestId: request.requestId,
|
|
217
|
+
now: () => new Date().toISOString(),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function envToken() {
|
|
221
|
+
return envString(XENO_AGENTS_API_TOKEN_ENV);
|
|
222
|
+
}
|
|
223
|
+
function envString(key) {
|
|
224
|
+
const v = typeof process !== "undefined" && process.env ? process.env[key] : undefined;
|
|
225
|
+
return typeof v === "string" && v.trim() ? v : undefined;
|
|
226
|
+
}
|
|
227
|
+
/** Default auth policy: a single required platform-token secret reference (metadata only). */
|
|
228
|
+
function defaultAuthPolicy() {
|
|
229
|
+
return {
|
|
230
|
+
requirement: "required",
|
|
231
|
+
allowedSecretRefs: [
|
|
232
|
+
{ id: XENO_AGENTS_API_TOKEN_ENV, kind: "manual", label: "XENO platform token (OIDC JWT / platform API key)", required: true, redactionHint: "credential" },
|
|
233
|
+
],
|
|
234
|
+
allowPlainEnv: false,
|
|
235
|
+
allowProcessEnv: false,
|
|
236
|
+
allowCredentialFiles: false,
|
|
237
|
+
allowInteractiveLogin: false,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/** Default egress policy: HTTPS to the XENO agents-api host only (metadata only). */
|
|
241
|
+
function defaultEgressPolicy() {
|
|
242
|
+
return {
|
|
243
|
+
mode: "allowlist",
|
|
244
|
+
allowedHosts: [XENO_AGENTS_API_DEFAULT_HOST],
|
|
245
|
+
blockedHosts: [],
|
|
246
|
+
allowLocalhost: false,
|
|
247
|
+
allowPrivateNetwork: false,
|
|
248
|
+
allowHttp: false,
|
|
249
|
+
allowHttps: true,
|
|
250
|
+
maxRedirects: 0,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The `xeno-agents-api` provider definition: a REAL, enabled, XENO-owned, **approval-gated**
|
|
255
|
+
* hosted bridge. `authRequirement`/`networkRequirement` are `required` (truthful), so the capability
|
|
256
|
+
* gate returns `requires_approval` — never runnable without a current policy + approval.
|
|
257
|
+
*/
|
|
258
|
+
export function createXenoAgentsApiDefinition() {
|
|
259
|
+
const definition = {
|
|
260
|
+
id: XENO_AGENTS_API_ID,
|
|
261
|
+
displayName: "XENO Hosted Agents API",
|
|
262
|
+
description: "Drives a XENO hosted agent run (api.xenostudio.ai/v1/agents) through the ACP provider contract — no local process. XENO-owned, approval-gated; needs a platform token + network; no local filesystem or terminal authority.",
|
|
263
|
+
kind: "gateway",
|
|
264
|
+
trustClass: "xeno-owned",
|
|
265
|
+
authRequirement: "required",
|
|
266
|
+
networkRequirement: "required",
|
|
267
|
+
ioAuthority: { filesystem: "none", terminal: "none" },
|
|
268
|
+
capabilities: XENO_AGENTS_API_CAPABILITIES,
|
|
269
|
+
enabled: true,
|
|
270
|
+
authPolicy: defaultAuthPolicy(),
|
|
271
|
+
egressPolicy: defaultEgressPolicy(),
|
|
272
|
+
metadata: {
|
|
273
|
+
acpEntrypoint: "none",
|
|
274
|
+
installedLocally: false,
|
|
275
|
+
displayAlias: "XENO Hosted Agents",
|
|
276
|
+
note: "Hosted-runs bridge: maps createRun/attach/stopRun onto the ACP provider-runtime contract. Executes in the cloud.",
|
|
277
|
+
streaming: {
|
|
278
|
+
mode: "streaming",
|
|
279
|
+
safeMessage: "Streams the hosted run's model text + tool events as ACP updates over the attach channel.",
|
|
280
|
+
},
|
|
281
|
+
setupHints: [
|
|
282
|
+
`Provide a platform token via options.token or ${XENO_AGENTS_API_TOKEN_ENV}.`,
|
|
283
|
+
"Review policy.",
|
|
284
|
+
"Approve provider.",
|
|
285
|
+
"Run providers test.",
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
modelDiscovery: {
|
|
289
|
+
status: "available",
|
|
290
|
+
source: "operator_config",
|
|
291
|
+
defaultModelId: null,
|
|
292
|
+
allowCustomModel: true, // the hosted API accepts any model id it recognizes (e.g. gpt-5.5)
|
|
293
|
+
models: [],
|
|
294
|
+
safeMessage: "Model selection is passed through to the hosted run; any model id the server accepts is allowed.",
|
|
295
|
+
},
|
|
296
|
+
createRuntime(config) {
|
|
297
|
+
return new XenoAgentsApiRuntime(definition, config);
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
return definition;
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=xenoAgentsApiProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xenoAgentsApiProvider.js","sourceRoot":"","sources":["../../src/providers/xenoAgentsApiProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAA8D,MAAM,iCAAiC,CAAC;AACnJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AAcvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAEhE,sGAAsG;AACtG,MAAM,CAAC,MAAM,4BAA4B,GAA0B;IACjE,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,KAAK;IAChB,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,wBAAwB,EAAE,IAAI;IAC9B,YAAY,EAAE,IAAI,EAAE,0BAA0B;IAC9C,WAAW,EAAE,IAAI,EAAE,0BAA0B;IAC7C,YAAY,EAAE,KAAK,EAAE,oEAAoE;IACzF,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;CACtB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CA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C;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B;IAC3C,MAAM,UAAU,GAAuB;QACrC,EAAE,EAAE,kBAAkB;QACtB,WAAW,EAAE,wBAAwB;QACrC,WAAW,EACT,6NAA6N;QAC/N,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,YAAY;QACxB,eAAe,EAAE,UAAU;QAC3B,kBAAkB,EAAE,UAAU;QAC9B,WAAW,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;QACrD,YAAY,EAAE,4BAA4B;QAC1C,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,iBAAiB,EAAE;QAC/B,YAAY,EAAE,mBAAmB,EAAE;QACnC,QAAQ,EAAE;YACR,aAAa,EAAE,MAAM;YACrB,gBAAgB,EAAE,KAAK;YACvB,YAAY,EAAE,oBAAoB;YAClC,IAAI,EAAE,kHAAkH;YACxH,SAAS,EAAE;gBACT,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,2FAA2F;aACzG;YACD,UAAU,EAAE;gBACV,iDAAiD,yBAAyB,GAAG;gBAC7E,gBAAgB;gBAChB,mBAAmB;gBACnB,qBAAqB;aACtB;SACF;QACD,cAAc,EAAE;YACd,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,iBAAiB;YACzB,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,IAAI,EAAE,mEAAmE;YAC3F,MAAM,EAAE,EAAE;YACV,WAAW,EAAE,kGAAkG;SAChH;QACD,aAAa,CAAC,MAA8B;YAC1C,OAAO,IAAI,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `xeno-sdk` ADAPTER PROCESS — where the XENO Agent SDK actually runs.
|
|
3
|
+
*
|
|
4
|
+
* This module is loaded only inside the supervised child (`cli.js adapter
|
|
5
|
+
* --provider xeno-sdk`). It is deliberately NOT imported by the ACP endpoint:
|
|
6
|
+
* `@xenosystem/acp-agent` keeps zero I/O authority, and the SDK brings network, tools
|
|
7
|
+
* and credentials with it.
|
|
8
|
+
*
|
|
9
|
+
* ## Credentials never travel through env
|
|
10
|
+
*
|
|
11
|
+
* The supervisor's env allowlist forbids `*_API_KEY` / `*_TOKEN` / `*_SECRET` by
|
|
12
|
+
* policy. The SDK does not need them to: `readXenoApiKey()` resolves the
|
|
13
|
+
* operator's own credential from `~/.xeno/credentials.json`, exactly as the
|
|
14
|
+
* Claude CLI resolves its own local session for `claude-local`. So the adapter
|
|
15
|
+
* self-authenticates, the policy holds unmodified, and no secret is forwarded by
|
|
16
|
+
* this process or visible in its environment.
|
|
17
|
+
*
|
|
18
|
+
* If no credential is present the adapter FAILS BY NAME rather than running a
|
|
19
|
+
* degraded turn — an agent that silently produces nothing is indistinguishable
|
|
20
|
+
* from one that had nothing to say.
|
|
21
|
+
*/
|
|
22
|
+
import { type XenoSdkEmit } from "./xenoSdkProvider.js";
|
|
23
|
+
export interface XenoSdkAdapterRunOptions {
|
|
24
|
+
model: string;
|
|
25
|
+
promptText: string;
|
|
26
|
+
emit: XenoSdkEmit;
|
|
27
|
+
/** Injected for tests; defaults to the real SDK. */
|
|
28
|
+
loadSdk?: () => Promise<XenoSdkModule>;
|
|
29
|
+
maxIterations?: number;
|
|
30
|
+
maxTokens?: number;
|
|
31
|
+
systemPrompt?: string;
|
|
32
|
+
}
|
|
33
|
+
/** The narrow slice of `@xenosystem/agent-sdk` this adapter depends on. */
|
|
34
|
+
export interface XenoSdkModule {
|
|
35
|
+
AgentLoop: new (config: Record<string, unknown>) => {
|
|
36
|
+
run: (prompt: string) => Promise<unknown>;
|
|
37
|
+
};
|
|
38
|
+
PermissionEngine: new (config?: Record<string, unknown>) => unknown;
|
|
39
|
+
readXenoApiKey: () => string | undefined;
|
|
40
|
+
XENO_API_BASE: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Runs one turn and emits the v1 adapter protocol on the supplied writer.
|
|
44
|
+
*
|
|
45
|
+
* Resolves once the turn is finished. It never throws: a failure is a `failed`
|
|
46
|
+
* protocol event, because the supervisor reads stdout and an exception would
|
|
47
|
+
* reach the host as a dead process rather than a described failure.
|
|
48
|
+
*/
|
|
49
|
+
export declare function runXenoSdkAdapterTurn(options: XenoSdkAdapterRunOptions): Promise<void>;
|
|
50
|
+
//# sourceMappingURL=xenoSdkAdapterProcess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xenoSdkAdapterProcess.d.ts","sourceRoot":"","sources":["../../src/providers/xenoSdkAdapterProcess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEhF,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,2EAA2E;AAC3E,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;QAAE,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;IAClG,gBAAgB,EAAE,KAAK,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;IACpE,cAAc,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC;CACvB;AAKD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC5F"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `xeno-sdk` ADAPTER PROCESS — where the XENO Agent SDK actually runs.
|
|
3
|
+
*
|
|
4
|
+
* This module is loaded only inside the supervised child (`cli.js adapter
|
|
5
|
+
* --provider xeno-sdk`). It is deliberately NOT imported by the ACP endpoint:
|
|
6
|
+
* `@xenosystem/acp-agent` keeps zero I/O authority, and the SDK brings network, tools
|
|
7
|
+
* and credentials with it.
|
|
8
|
+
*
|
|
9
|
+
* ## Credentials never travel through env
|
|
10
|
+
*
|
|
11
|
+
* The supervisor's env allowlist forbids `*_API_KEY` / `*_TOKEN` / `*_SECRET` by
|
|
12
|
+
* policy. The SDK does not need them to: `readXenoApiKey()` resolves the
|
|
13
|
+
* operator's own credential from `~/.xeno/credentials.json`, exactly as the
|
|
14
|
+
* Claude CLI resolves its own local session for `claude-local`. So the adapter
|
|
15
|
+
* self-authenticates, the policy holds unmodified, and no secret is forwarded by
|
|
16
|
+
* this process or visible in its environment.
|
|
17
|
+
*
|
|
18
|
+
* If no credential is present the adapter FAILS BY NAME rather than running a
|
|
19
|
+
* degraded turn — an agent that silently produces nothing is indistinguishable
|
|
20
|
+
* from one that had nothing to say.
|
|
21
|
+
*/
|
|
22
|
+
import { createXenoSdkEventSink } from "./xenoSdkProvider.js";
|
|
23
|
+
const DEFAULT_SYSTEM_PROMPT = "You are the XENO Agent, reached over the Agent Client Protocol. Answer the request directly.";
|
|
24
|
+
/**
|
|
25
|
+
* Runs one turn and emits the v1 adapter protocol on the supplied writer.
|
|
26
|
+
*
|
|
27
|
+
* Resolves once the turn is finished. It never throws: a failure is a `failed`
|
|
28
|
+
* protocol event, because the supervisor reads stdout and an exception would
|
|
29
|
+
* reach the host as a dead process rather than a described failure.
|
|
30
|
+
*/
|
|
31
|
+
export async function runXenoSdkAdapterTurn(options) {
|
|
32
|
+
const sink = createXenoSdkEventSink(options.emit);
|
|
33
|
+
try {
|
|
34
|
+
const sdk = await (options.loadSdk?.() ?? loadRealSdk());
|
|
35
|
+
const apiKey = sdk.readXenoApiKey();
|
|
36
|
+
if (!apiKey) {
|
|
37
|
+
// Named refusal, not an empty turn.
|
|
38
|
+
sink.onError(new Error("no XENO credential found (~/.xeno/credentials.json)"), "xeno-sdk-auth");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const loop = new sdk.AgentLoop({
|
|
42
|
+
apiKey,
|
|
43
|
+
baseURL: sdk.XENO_API_BASE,
|
|
44
|
+
model: options.model,
|
|
45
|
+
maxTokens: options.maxTokens ?? 8192,
|
|
46
|
+
maxIterations: options.maxIterations ?? 24,
|
|
47
|
+
systemPrompt: options.systemPrompt ?? DEFAULT_SYSTEM_PROMPT,
|
|
48
|
+
permissionEngine: new sdk.PermissionEngine(),
|
|
49
|
+
onText: sink.onText,
|
|
50
|
+
onToolStart: sink.onToolStart,
|
|
51
|
+
onToolEnd: sink.onToolEnd,
|
|
52
|
+
onError: sink.onError,
|
|
53
|
+
});
|
|
54
|
+
await loop.run(options.promptText);
|
|
55
|
+
sink.completed();
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
sink.onError(error instanceof Error ? error : new Error(String(error)), "xeno-sdk-run");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function loadRealSdk() {
|
|
62
|
+
const mod = (await import("@xenosystem/agent-sdk"));
|
|
63
|
+
return mod;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=xenoSdkAdapterProcess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xenoSdkAdapterProcess.js","sourceRoot":"","sources":["../../src/providers/xenoSdkAdapterProcess.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAA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AAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAC1F,CAAC;AACH,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAA6B,CAAC;IAChF,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `xeno-sdk` — the XENO Agent SDK reachable over ACP.
|
|
3
|
+
*
|
|
4
|
+
* This is the keystone of the locked XENO Agent ADE architecture
|
|
5
|
+
* (`xeno-agent-interface/docs/specs/XENO_AGENT_ADE_SPEC.md` §2.6): **our own agent
|
|
6
|
+
* becomes an ACP provider like any other**, so `sdk-native` stops being a
|
|
7
|
+
* privileged in-process lane.
|
|
8
|
+
*
|
|
9
|
+
* The reason is not tidiness. §2.2 requires third-party agents to be first-class,
|
|
10
|
+
* and with two execution paths that is a gate somebody has to keep green forever
|
|
11
|
+
* — every new capability lands on the privileged path first, and the privileged
|
|
12
|
+
* path is the one that grows shortcuts. With one bus it is STRUCTURAL: our agent
|
|
13
|
+
* cannot outgrow the path foreign agents use, because it is the same path.
|
|
14
|
+
*
|
|
15
|
+
* ## Where the SDK actually runs
|
|
16
|
+
*
|
|
17
|
+
* In the supervised ADAPTER PROCESS, never in the ACP endpoint. `@xenosystem/acp-agent`
|
|
18
|
+
* keeps zero I/O authority: it spawns, it reads v1 protocol lines from stdout,
|
|
19
|
+
* and it maps them to `session/update`. The SDK's own tool authority, network
|
|
20
|
+
* access and credentials live inside the child, behind the process supervisor —
|
|
21
|
+
* exactly where a third-party CLI's do.
|
|
22
|
+
*
|
|
23
|
+
* ## Why the prompt goes over stdin
|
|
24
|
+
*
|
|
25
|
+
* `claude-local` passes its prompt as argv because the Claude CLI requires it.
|
|
26
|
+
* We own both ends here, so the prompt goes over **stdin**: argv is visible to
|
|
27
|
+
* every local user through the process table, and it has a length limit that a
|
|
28
|
+
* real agent prompt will eventually exceed. The harness supports `stdin`
|
|
29
|
+
* directly (`AdapterHarnessConfig.adapter.stdin`), so this costs nothing.
|
|
30
|
+
*
|
|
31
|
+
* ## Honest declarations
|
|
32
|
+
*
|
|
33
|
+
* The SDK agent talks to a model. So `requiresAuth` and `usesNetwork` are TRUE,
|
|
34
|
+
* which routes this provider through the auth/egress policy validators and the
|
|
35
|
+
* manual-approval gate. It is deliberately NOT declared as a no-auth local
|
|
36
|
+
* adapter: that would be the convenient lie that makes it runnable "just because
|
|
37
|
+
* it exists", and the security layer would be evaluating a fiction.
|
|
38
|
+
*/
|
|
39
|
+
import type { ProviderCapabilitySet, ProviderDefinition, ProviderPromptRequest } from "./providerTypes.js";
|
|
40
|
+
import type { RunnabilityInput } from "../config/providerRunnability.js";
|
|
41
|
+
export declare const XENO_SDK_ID = "xeno-sdk";
|
|
42
|
+
/** Default model surface. Overridable by config; never hardcoded downstream. */
|
|
43
|
+
export declare const XENO_SDK_DEFAULT_MODEL = "gpt-5.5";
|
|
44
|
+
export declare const XENO_SDK_CAPABILITIES: ProviderCapabilitySet;
|
|
45
|
+
/** The v1 protocol line writer the adapter process emits through. */
|
|
46
|
+
export type XenoSdkEmit = (event: Record<string, unknown>) => void;
|
|
47
|
+
/**
|
|
48
|
+
* The AgentLoop callbacks, expressed as v1 protocol events.
|
|
49
|
+
*
|
|
50
|
+
* Deliberately PURE and separated from constructing an `AgentLoop`: this is the
|
|
51
|
+
* whole translation layer between our agent and ACP, and it must be testable
|
|
52
|
+
* without a model, a network or a key. The live runner below is a thin shell
|
|
53
|
+
* around it, so almost nothing that can be wrong lives outside a test's reach.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createXenoSdkEventSink(emit: XenoSdkEmit): {
|
|
56
|
+
onText: (text: string) => void;
|
|
57
|
+
onToolStart: (name: string, input: Record<string, unknown>) => void;
|
|
58
|
+
onToolEnd: (name: string, result: {
|
|
59
|
+
success?: boolean;
|
|
60
|
+
error?: unknown;
|
|
61
|
+
}) => void;
|
|
62
|
+
onError: (error: Error, context: string) => void;
|
|
63
|
+
completed: (stopReason?: string) => void;
|
|
64
|
+
toolCallIdFor: (name: string) => string;
|
|
65
|
+
};
|
|
66
|
+
/** Where the adapter process lives — this package's own CLI, never a third-party binary. */
|
|
67
|
+
export declare function xenoSdkAdapterEntrypoint(): string;
|
|
68
|
+
export interface XenoSdkOptions {
|
|
69
|
+
runnability?: RunnabilityInput;
|
|
70
|
+
model?: string;
|
|
71
|
+
timeoutMs?: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The adapter argv. The prompt is NOT here — see the module header: argv is
|
|
75
|
+
* world-readable through the process table and length-limited, and the harness
|
|
76
|
+
* accepts stdin directly.
|
|
77
|
+
*/
|
|
78
|
+
export declare function xenoSdkAdapterCommand(model: string): {
|
|
79
|
+
executable: string;
|
|
80
|
+
args: string[];
|
|
81
|
+
};
|
|
82
|
+
/** Flattens the prompt blocks into the text the SDK agent receives on stdin. */
|
|
83
|
+
export declare function renderXenoSdkPrompt(request: ProviderPromptRequest): string;
|
|
84
|
+
export declare function createXenoSdkDefinition(): ProviderDefinition;
|
|
85
|
+
//# sourceMappingURL=xenoSdkProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xenoSdkProvider.d.ts","sourceRoot":"","sources":["../../src/providers/xenoSdkProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAMH,OAAO,KAAK,EACV,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EAMtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,eAAO,MAAM,WAAW,aAAa,CAAC;AAEtC,gFAAgF;AAChF,eAAO,MAAM,sBAAsB,YAAY,C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