agentspeak-cli 0.8.1 → 0.9.0
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/adapters/claude.d.ts +13 -0
- package/dist/adapters/claude.d.ts.map +1 -0
- package/dist/adapters/claude.js +32 -0
- package/dist/adapters/claude.js.map +1 -0
- package/dist/adapters/cursor-agent.d.ts +10 -0
- package/dist/adapters/cursor-agent.d.ts.map +1 -0
- package/dist/adapters/cursor-agent.js +29 -0
- package/dist/adapters/cursor-agent.js.map +1 -0
- package/dist/adapters/echo.d.ts +17 -0
- package/dist/adapters/echo.d.ts.map +1 -0
- package/dist/adapters/echo.js +39 -0
- package/dist/adapters/echo.js.map +1 -0
- package/dist/adapters/hermes.d.ts +10 -0
- package/dist/adapters/hermes.d.ts.map +1 -0
- package/dist/adapters/hermes.js +33 -0
- package/dist/adapters/hermes.js.map +1 -0
- package/dist/adapters/index.d.ts +69 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +106 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/openclaw.d.ts +10 -0
- package/dist/adapters/openclaw.d.ts.map +1 -0
- package/dist/adapters/openclaw.js +32 -0
- package/dist/adapters/openclaw.js.map +1 -0
- package/dist/adapters/shell-helper.d.ts +32 -0
- package/dist/adapters/shell-helper.d.ts.map +1 -0
- package/dist/adapters/shell-helper.js +99 -0
- package/dist/adapters/shell-helper.js.map +1 -0
- package/dist/adapters/stdin.d.ts +13 -0
- package/dist/adapters/stdin.d.ts.map +1 -0
- package/dist/adapters/stdin.js +72 -0
- package/dist/adapters/stdin.js.map +1 -0
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/auto-shim.d.ts +38 -0
- package/dist/auto-shim.d.ts.map +1 -0
- package/dist/auto-shim.js +136 -0
- package/dist/auto-shim.js.map +1 -0
- package/dist/commands/handle-turn.d.ts +23 -8
- package/dist/commands/handle-turn.d.ts.map +1 -1
- package/dist/commands/handle-turn.js +119 -24
- package/dist/commands/handle-turn.js.map +1 -1
- package/dist/commands/identity.d.ts +28 -0
- package/dist/commands/identity.d.ts.map +1 -0
- package/dist/commands/identity.js +104 -0
- package/dist/commands/identity.js.map +1 -0
- package/dist/commands/inbox.d.ts +20 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +41 -0
- package/dist/commands/inbox.js.map +1 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +35 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.d.ts +30 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +195 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +14 -1
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/run.d.ts +7 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +104 -47
- package/dist/commands/run.js.map +1 -1
- package/dist/exec.d.ts +26 -0
- package/dist/exec.d.ts.map +1 -1
- package/dist/exec.js +36 -2
- package/dist/exec.js.map +1 -1
- package/dist/index.js +97 -61
- package/dist/index.js.map +1 -1
- package/dist/state.d.ts +36 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +64 -0
- package/dist/state.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { renderPromptFromEnvelope } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* `--via stdin` — interactive bridge.
|
|
4
|
+
*
|
|
5
|
+
* Prints the rendered turn prompt to stdout, then reads the reply from
|
|
6
|
+
* stdin until EOF (Ctrl-D / pipe close). For a human-in-the-loop driver
|
|
7
|
+
* or for a parent runtime that pipes the reply in.
|
|
8
|
+
*
|
|
9
|
+
* Honours the smoke-test envelope to keep `cmdRun`'s pre-attach gate
|
|
10
|
+
* passable without forcing the operator to type anything during install.
|
|
11
|
+
*/
|
|
12
|
+
export const stdinAdapter = async (ctx) => {
|
|
13
|
+
const start = Date.now();
|
|
14
|
+
if (ctx.smokeTest) {
|
|
15
|
+
return ok('[smoke ok]', start);
|
|
16
|
+
}
|
|
17
|
+
const prompt = renderPromptFromEnvelope(ctx.envelope);
|
|
18
|
+
process.stdout.write('\n--- AGENTSPEAK TURN PROMPT ---\n');
|
|
19
|
+
process.stdout.write(prompt);
|
|
20
|
+
process.stdout.write('\n--- END PROMPT (type your reply, then Ctrl-D / EOF) ---\n');
|
|
21
|
+
const body = await readStdinUntilEof(ctx.timeoutMs);
|
|
22
|
+
if (body.trim().length === 0) {
|
|
23
|
+
return {
|
|
24
|
+
stdout: '',
|
|
25
|
+
stderr: 'stdin adapter: empty reply (EOF before any text); refusing to submit blank turn',
|
|
26
|
+
exitCode: 1,
|
|
27
|
+
durationMs: Date.now() - start,
|
|
28
|
+
timedOut: false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return ok(body, start);
|
|
32
|
+
};
|
|
33
|
+
function ok(body, start) {
|
|
34
|
+
return {
|
|
35
|
+
stdout: body,
|
|
36
|
+
stderr: '',
|
|
37
|
+
exitCode: 0,
|
|
38
|
+
durationMs: Date.now() - start,
|
|
39
|
+
timedOut: false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function readStdinUntilEof(timeoutMs) {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
const chunks = [];
|
|
45
|
+
let done = false;
|
|
46
|
+
const finalize = () => {
|
|
47
|
+
if (done)
|
|
48
|
+
return;
|
|
49
|
+
done = true;
|
|
50
|
+
try {
|
|
51
|
+
process.stdin.removeAllListeners('data');
|
|
52
|
+
process.stdin.removeAllListeners('end');
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// ignore
|
|
56
|
+
}
|
|
57
|
+
resolve(Buffer.concat(chunks).toString('utf8'));
|
|
58
|
+
};
|
|
59
|
+
process.stdin.on('data', (c) => chunks.push(c));
|
|
60
|
+
process.stdin.on('end', finalize);
|
|
61
|
+
if (timeoutMs && timeoutMs > 0) {
|
|
62
|
+
setTimeout(finalize, timeoutMs);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
process.stdin.resume();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// already resumed
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=stdin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin.js","sourceRoot":"","sources":["../../src/adapters/stdin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAGtD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAY,KAAK,EAAE,GAAG,EAAE,EAAE;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACzB,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,MAAM,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAEpF,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACpD,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,iFAAiF;YACzF,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,IA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C,QAAQ,EAAE,SAAS,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC;YACH,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/api.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const api: {
|
|
|
17
17
|
}) => Promise<T>;
|
|
18
18
|
post: <T = unknown>(ctx: ApiCtx, path: string, body: unknown, opts?: {
|
|
19
19
|
timeoutMs?: number;
|
|
20
|
+
headers?: Record<string, string>;
|
|
20
21
|
}) => Promise<T>;
|
|
21
22
|
put: <T = unknown>(ctx: ApiCtx, path: string, body: unknown) => Promise<T>;
|
|
22
23
|
};
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,QAAS,SAAQ,KAAK;IACd,MAAM,EAAE,MAAM;IAAS,IAAI,EAAE,MAAM;gBAAnC,MAAM,EAAE,MAAM,EAAS,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAGzE;AAwCD,eAAO,MAAM,GAAG;UACR,CAAC,iBAAiB,MAAM,QAAQ,MAAM,SAAS;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;WAEpE,CAAC,iBACD,MAAM,QACL,MAAM,QACN,OAAO,SACN;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,MAAM,CAAC;IACh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AAW,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACzE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAC3B,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,GAAG,CAAC,KAAK,EAAE;gBACpC,MAAM,EAAE,kBAAkB;gBAC1B,YAAY,EAAE,oBAAoB;aACnC;YACD,MAAM,EAAE,UAAU,CAAC,MAAM;SAC1B,CAAC,CAAC;QACH,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClD,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACnE,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAQD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAW,EAAE,SAAiB;IACnE,OAAO,GAAG,CAAC,GAAG,CAAgB,GAAG,EAAE,iBAAiB,SAAS,SAAS,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-written reply shim (Phase 2 of the reliable-bridge plan).
|
|
3
|
+
*
|
|
4
|
+
* Yaow's failure on Windows came down to a hand-authored reply.sh with
|
|
5
|
+
* `#!/bin/bash` (doesn't exist on git-bash) and a `jq` call (rarely
|
|
6
|
+
* installed). Ernesto's sandbox failures involved repeatedly authoring
|
|
7
|
+
* the same fragile shim only to lose it between tool calls. The fix is
|
|
8
|
+
* to ship one canonical, hardened reply shim that the CLI writes ITSELF
|
|
9
|
+
* on `init`, so no agent ever has to author one from scratch.
|
|
10
|
+
*
|
|
11
|
+
* Properties of the auto-written shim:
|
|
12
|
+
* - Shebang `#!/usr/bin/env bash` (works on macOS, Linux, git-bash, WSL).
|
|
13
|
+
* - Zero external deps. We are the node CLI; node is guaranteed.
|
|
14
|
+
* JSON parsing happens inline via `node -e`.
|
|
15
|
+
* - Honours the smoke-test envelope (echoes "[smoke ok]" and exits 0)
|
|
16
|
+
* so cmdRun's pre-attach gate always passes against the auto-shim.
|
|
17
|
+
* - Default body is a templated [ack]; the operator can edit the
|
|
18
|
+
* marked block to call their LLM of choice.
|
|
19
|
+
* - Companion `reply.cmd` written on Windows for cmd.exe fallback.
|
|
20
|
+
*/
|
|
21
|
+
export interface AutoShimResult {
|
|
22
|
+
posixPath: string;
|
|
23
|
+
cmdPath?: string;
|
|
24
|
+
written: boolean;
|
|
25
|
+
reused: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function autoShimPaths(): {
|
|
28
|
+
posixPath: string;
|
|
29
|
+
cmdPath: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Write the auto-shim if it does not already exist. Idempotent: re-runs
|
|
33
|
+
* leave a previously-customised shim alone unless `force` is true.
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeAutoShim(opts?: {
|
|
36
|
+
force?: boolean;
|
|
37
|
+
}): AutoShimResult;
|
|
38
|
+
//# sourceMappingURL=auto-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-shim.d.ts","sourceRoot":"","sources":["../src/auto-shim.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,aAAa,IAAI;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAMtE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,cAAc,CA4B5E"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { home } from './state.js';
|
|
4
|
+
export function autoShimPaths() {
|
|
5
|
+
const dir = home();
|
|
6
|
+
return {
|
|
7
|
+
posixPath: join(dir, 'reply.sh'),
|
|
8
|
+
cmdPath: join(dir, 'reply.cmd'),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Write the auto-shim if it does not already exist. Idempotent: re-runs
|
|
13
|
+
* leave a previously-customised shim alone unless `force` is true.
|
|
14
|
+
*/
|
|
15
|
+
export function writeAutoShim(opts = {}) {
|
|
16
|
+
const { posixPath, cmdPath } = autoShimPaths();
|
|
17
|
+
mkdirSync(dirname(posixPath), { recursive: true });
|
|
18
|
+
const exists = existsSync(posixPath);
|
|
19
|
+
if (exists && !opts.force) {
|
|
20
|
+
return { posixPath, cmdPath: process.platform === 'win32' ? cmdPath : undefined, written: false, reused: true };
|
|
21
|
+
}
|
|
22
|
+
writeFileSync(posixPath, AUTO_SHIM_BASH, { mode: 0o755 });
|
|
23
|
+
try {
|
|
24
|
+
chmodSync(posixPath, 0o755);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// some sandboxes refuse chmod; not fatal
|
|
28
|
+
}
|
|
29
|
+
let cmdWritten = false;
|
|
30
|
+
if (process.platform === 'win32') {
|
|
31
|
+
writeFileSync(cmdPath, AUTO_SHIM_CMD);
|
|
32
|
+
cmdWritten = true;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
posixPath,
|
|
36
|
+
cmdPath: cmdWritten ? cmdPath : undefined,
|
|
37
|
+
written: true,
|
|
38
|
+
reused: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hardened reply shim. Lines marked with `# EDIT ME` are the only
|
|
43
|
+
* places the operator should change to wire in their LLM client. The
|
|
44
|
+
* smoke-test short-circuit MUST stay above the EDIT ME block so the
|
|
45
|
+
* cmdRun pre-attach gate continues to pass even with a half-written
|
|
46
|
+
* customisation.
|
|
47
|
+
*/
|
|
48
|
+
const AUTO_SHIM_BASH = `#!/usr/bin/env bash
|
|
49
|
+
# AgentSpeak auto-written reply shim. Generated by \`agentspeak-cli init\`.
|
|
50
|
+
# Safe to edit. Re-running \`init\` will NOT overwrite this file unless
|
|
51
|
+
# you pass --force-shim.
|
|
52
|
+
#
|
|
53
|
+
# Contract:
|
|
54
|
+
# stdin = TurnEnvelope JSON (taskId, turnNumber, meetingId, agentId, role,
|
|
55
|
+
# instructions, previousTurns, agentspeak.smokeTest, ...).
|
|
56
|
+
# stdout = your reply body (markdown). Empty stdout is treated as a
|
|
57
|
+
# failure by the loop.
|
|
58
|
+
# exit 0 = success.
|
|
59
|
+
# To close the meeting include the literal:
|
|
60
|
+
# <!-- agentspeak:signal=done -->
|
|
61
|
+
# anywhere in your stdout.
|
|
62
|
+
#
|
|
63
|
+
# This shim parses JSON via node (we ARE the node CLI; node is
|
|
64
|
+
# guaranteed). DO NOT add jq / python / curl dependencies.
|
|
65
|
+
|
|
66
|
+
set -e
|
|
67
|
+
PAYLOAD="$(cat)"
|
|
68
|
+
|
|
69
|
+
# --- Parse a few useful fields out of the envelope using node ---
|
|
70
|
+
read TURN ROLE MEETING IS_SMOKE <<< "$(node -e '
|
|
71
|
+
let s = "";
|
|
72
|
+
process.stdin.on("data", c => s += c);
|
|
73
|
+
process.stdin.on("end", () => {
|
|
74
|
+
try {
|
|
75
|
+
const e = JSON.parse(s);
|
|
76
|
+
const turn = e.turnNumber ?? "?";
|
|
77
|
+
const role = (e.role ?? "participant").replace(/\\s+/g, "_");
|
|
78
|
+
const meeting = e.meetingId ?? "unknown";
|
|
79
|
+
const smoke = e.agentspeak && e.agentspeak.smokeTest ? "1" : "0";
|
|
80
|
+
process.stdout.write(turn + " " + role + " " + meeting + " " + smoke);
|
|
81
|
+
} catch (err) {
|
|
82
|
+
process.stdout.write("? participant unknown 0");
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
' <<< "$PAYLOAD")"
|
|
86
|
+
|
|
87
|
+
# Smoke-test short-circuit. cmdRun's pre-attach gate sends a synthetic
|
|
88
|
+
# envelope with agentspeak.smokeTest=true; we MUST exit 0 with non-empty
|
|
89
|
+
# stdout here without burning an LLM call. Do not remove this block.
|
|
90
|
+
if [ "$IS_SMOKE" = "1" ]; then
|
|
91
|
+
echo "[smoke ok]"
|
|
92
|
+
exit 0
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# --- EDIT ME: replace the body below with a real LLM call. ---
|
|
96
|
+
# Examples (uncomment one and adapt):
|
|
97
|
+
#
|
|
98
|
+
# # Anthropic Claude Code CLI:
|
|
99
|
+
# echo "$PAYLOAD" | claude -p
|
|
100
|
+
#
|
|
101
|
+
# # Cursor agent CLI:
|
|
102
|
+
# echo "$PAYLOAD" | cursor-agent --print
|
|
103
|
+
#
|
|
104
|
+
# # OpenAI via curl + your OPENAI_API_KEY:
|
|
105
|
+
# PROMPT=$(node -e 'let s="";process.stdin.on("data",c=>s+=c);process.stdin.on("end",()=>{const e=JSON.parse(s);process.stdout.write((e.instructions||"")+"\\n\\n"+JSON.stringify(e.previousTurns||[]));})' <<< "$PAYLOAD")
|
|
106
|
+
# curl -sS https://api.openai.com/v1/chat/completions \\
|
|
107
|
+
# -H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" \\
|
|
108
|
+
# -d "{\\"model\\":\\"gpt-4o\\",\\"messages\\":[{\\"role\\":\\"user\\",\\"content\\":$(node -e "process.stdout.write(JSON.stringify(process.argv[1]))" "$PROMPT")}]}" \\
|
|
109
|
+
# | node -e 'let s="";process.stdin.on("data",c=>s+=c);process.stdin.on("end",()=>{const o=JSON.parse(s);process.stdout.write(o.choices[0].message.content);})'
|
|
110
|
+
#
|
|
111
|
+
# The default below acknowledges the turn so the meeting keeps moving;
|
|
112
|
+
# replace it with your LLM call as soon as you're ready.
|
|
113
|
+
echo "[ack] turn $TURN ($ROLE on $MEETING) handled by ~/.agentspeak/reply.sh."
|
|
114
|
+
echo
|
|
115
|
+
echo "This is the AgentSpeak auto-written reply shim. Edit ~/.agentspeak/reply.sh"
|
|
116
|
+
echo "and replace the marked block with a call to your LLM client."
|
|
117
|
+
`;
|
|
118
|
+
/**
|
|
119
|
+
* Windows companion. Most Windows agents will go through bash via
|
|
120
|
+
* git-bash / WSL (auto-detected by exec.ts), but this provides a
|
|
121
|
+
* cmd.exe fallback for the rare environment without bash.
|
|
122
|
+
*/
|
|
123
|
+
const AUTO_SHIM_CMD = `@echo off
|
|
124
|
+
REM AgentSpeak auto-written reply shim (Windows cmd.exe fallback).
|
|
125
|
+
REM Prefer the bash variant in reply.sh — exec.ts auto-detects bash.
|
|
126
|
+
REM This file exists only as a safety net for environments without bash.
|
|
127
|
+
|
|
128
|
+
REM Read all of stdin into a temp file, then ask node to do the heavy
|
|
129
|
+
REM lifting (parse the envelope, decide on the response, print to stdout).
|
|
130
|
+
set "TMPFILE=%TEMP%\\agentspeak-turn-%RANDOM%.json"
|
|
131
|
+
more > "%TMPFILE%"
|
|
132
|
+
|
|
133
|
+
node -e "const fs=require('fs');const e=JSON.parse(fs.readFileSync(process.argv[1],'utf8'));if(e.agentspeak&&e.agentspeak.smokeTest){process.stdout.write('[smoke ok]');process.exit(0);}const t=e.turnNumber??'?';const r=e.role??'participant';process.stdout.write('[ack] turn '+t+' ('+r+') handled by reply.cmd.\\n\\nEdit %%USERPROFILE%%\\\\.agentspeak\\\\reply.cmd to author real replies.');" "%TMPFILE%"
|
|
134
|
+
del "%TMPFILE%" >nul 2>&1
|
|
135
|
+
`;
|
|
136
|
+
//# sourceMappingURL=auto-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-shim.js","sourceRoot":"","sources":["../src/auto-shim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AA8BlC,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,IAAI,EAAE,CAAC;IACnB,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC;QAChC,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;KAChC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,OAA4B,EAAE;IAC1D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAAC;IAC/C,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClH,CAAC;IAED,aAAa,CAAC,SAAS,EAAE,cAAc,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,IAAI,CAAC;QACH,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,yCAAyC;IAC3C,CAAC;IAED,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACtC,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,OAAO;QACL,SAAS;QACT,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACzC,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqEtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,aAAa,GAAG;;;;;;;;;;;;CAYrB,CAAC"}
|
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `agentspeak handle-turn` — one-shot, push-driven (T2.handle_turn)
|
|
2
|
+
* `agentspeak handle-turn` — one-shot, push-driven (T2.handle_turn)
|
|
3
|
+
* AND the right pattern for sandboxed runtimes that wipe state between
|
|
4
|
+
* tool calls (Phase 5 of the reliable-bridge plan).
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
* webhook) wakes the bot with a message that says "run this command".
|
|
6
|
-
* The command is exactly:
|
|
6
|
+
* Two ways to call it:
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* # Push-wake (existing): the wake transport says "run this", you
|
|
9
|
+
* # already have ~/.agentspeak/identity.json and a meetings/<id>.json:
|
|
10
|
+
* agentspeak-cli handle-turn --meeting <id> --exec ./reply.sh
|
|
11
|
+
*
|
|
12
|
+
* # Sandboxed (Phase 5): no on-disk state, no long-running process.
|
|
13
|
+
* # Pass the identity blob from your context, let us discover the
|
|
14
|
+
* # meeting via the inbox, and use a built-in adapter:
|
|
15
|
+
* agentspeak-cli handle-turn --identity <blob> --via echo
|
|
9
16
|
*
|
|
10
17
|
* We do ONE my_turn fetch (wait=0 — must already have a turn assigned
|
|
11
|
-
* since the push fired), run the
|
|
18
|
+
* since the push fired or the inbox said so), run the bridge, submit,
|
|
19
|
+
* exit.
|
|
12
20
|
*
|
|
13
21
|
* If no turn is actually assigned (race with concurrent pushes), exit 0
|
|
14
|
-
* with a warning rather than blocking — the next
|
|
22
|
+
* with a warning rather than blocking — the next wake will retry.
|
|
15
23
|
*/
|
|
16
24
|
export interface HandleTurnOpts {
|
|
17
25
|
meetingId?: string;
|
|
18
|
-
exec
|
|
26
|
+
exec?: string;
|
|
27
|
+
via?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Inline identity blob (base64). Lets sandboxed runtimes call this
|
|
30
|
+
* command without ~/.agentspeak/identity.json existing on disk.
|
|
31
|
+
* Falls back to AGENTSPEAK_IDENTITY env var, then to disk.
|
|
32
|
+
*/
|
|
33
|
+
identityBlob?: string;
|
|
19
34
|
shimTimeoutMs?: number;
|
|
20
35
|
/** Wait this many seconds for the turn (default 5 — push race tolerance). */
|
|
21
36
|
waitSeconds?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-turn.d.ts","sourceRoot":"","sources":["../../src/commands/handle-turn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handle-turn.d.ts","sourceRoot":"","sources":["../../src/commands/handle-turn.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAwIzE"}
|
|
@@ -1,15 +1,55 @@
|
|
|
1
|
-
import { api, pollMyTurn } from '../api.js';
|
|
1
|
+
import { api, ApiError, pollMyTurn } from '../api.js';
|
|
2
2
|
import { runShim } from '../exec.js';
|
|
3
3
|
import { startHeartbeat } from '../heartbeat.js';
|
|
4
|
-
import { loadCurrentMeetingId, loadMeeting } from '../state.js';
|
|
4
|
+
import { loadCurrentMeetingId, loadMeeting, resolveIdentity, saveIdentity, saveMeeting, } from '../state.js';
|
|
5
|
+
import { resolveAdapter } from '../adapters/index.js';
|
|
6
|
+
import { autoShimPaths } from '../auto-shim.js';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
5
8
|
export async function cmdHandleTurn(opts) {
|
|
6
|
-
|
|
9
|
+
// Resolve identity first; everything else needs the coordinator token.
|
|
10
|
+
const identity = resolveIdentity(opts.identityBlob);
|
|
11
|
+
if (!identity) {
|
|
12
|
+
process.stderr.write('agentspeak-cli handle-turn: no identity available. Pass --identity <blob>, ' +
|
|
13
|
+
'set AGENTSPEAK_IDENTITY, or run `agentspeak-cli init` first.\n');
|
|
14
|
+
return 2;
|
|
15
|
+
}
|
|
16
|
+
// Persist any newly-imported identity to disk so the matching meeting
|
|
17
|
+
// state files (loadMeeting) resolve correctly. No-op when identity
|
|
18
|
+
// came from disk in the first place.
|
|
19
|
+
if (opts.identityBlob || process.env.AGENTSPEAK_IDENTITY) {
|
|
20
|
+
try {
|
|
21
|
+
saveIdentity(identity);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// sandbox may be read-only; keep going with in-memory identity
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Resolve target meeting. Order:
|
|
28
|
+
// 1. --meeting <id>
|
|
29
|
+
// 2. ~/.agentspeak/current.json (last joined)
|
|
30
|
+
// 3. Inbox: ask the server for any pending turn (Phase 5)
|
|
31
|
+
let meetingId = opts.meetingId ?? loadCurrentMeetingId();
|
|
7
32
|
if (!meetingId) {
|
|
8
|
-
|
|
33
|
+
meetingId = await firstPendingMeeting(identity);
|
|
34
|
+
if (!meetingId) {
|
|
35
|
+
process.stderr.write('[agentspeak] handle-turn: no meeting id supplied and your inbox has no pending turns. ' +
|
|
36
|
+
'Either pass --meeting <id> or wait for a wake notification.\n');
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
process.stderr.write(`[agentspeak] handle-turn: auto-discovered ${meetingId} via inbox\n`);
|
|
9
40
|
}
|
|
10
|
-
|
|
41
|
+
// Resolve meeting state. If we don't have local state for this
|
|
42
|
+
// meeting (sandboxed call with a freshly-imported identity), call
|
|
43
|
+
// /api/meetings/<id>/status to learn the agentId we joined as.
|
|
44
|
+
let state = loadMeeting(meetingId);
|
|
11
45
|
if (!state) {
|
|
12
|
-
|
|
46
|
+
state = await reconstructMeetingState(identity, meetingId);
|
|
47
|
+
try {
|
|
48
|
+
saveMeeting(state);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// sandbox may be read-only; keep going with in-memory state
|
|
52
|
+
}
|
|
13
53
|
}
|
|
14
54
|
const ctx = { baseUrl: state.baseUrl, token: state.coordinatorToken };
|
|
15
55
|
const wait = opts.waitSeconds ?? 5;
|
|
@@ -21,40 +61,44 @@ export async function cmdHandleTurn(opts) {
|
|
|
21
61
|
const envelope = poll.envelope;
|
|
22
62
|
const turnNumber = typeof envelope.turnNumber === 'number' ? envelope.turnNumber : -1;
|
|
23
63
|
const taskId = typeof envelope.taskId === 'string' ? envelope.taskId : '';
|
|
24
|
-
process.stdout.write(`[agentspeak] handle-turn: ${meetingId} turn ${turnNumber} — running
|
|
64
|
+
process.stdout.write(`[agentspeak] handle-turn: ${meetingId} turn ${turnNumber} — running bridge\n`);
|
|
65
|
+
const bridge = resolveBridge(opts);
|
|
66
|
+
if (!bridge) {
|
|
67
|
+
process.stderr.write('agentspeak-cli handle-turn: no reply bridge configured. Pass --via <preset> or ' +
|
|
68
|
+
'--exec <command>, or run `agentspeak-cli init` to write the auto-shim.\n');
|
|
69
|
+
return 2;
|
|
70
|
+
}
|
|
25
71
|
const hb = startHeartbeat(ctx, meetingId, state.agentId, turnNumber);
|
|
26
|
-
let
|
|
72
|
+
let result;
|
|
27
73
|
try {
|
|
28
|
-
|
|
29
|
-
timeoutMs: opts.shimTimeoutMs ?? 600_000,
|
|
30
|
-
});
|
|
74
|
+
result = await runBridge(bridge, envelope, opts.shimTimeoutMs ?? 600_000);
|
|
31
75
|
}
|
|
32
76
|
finally {
|
|
33
77
|
hb.stop();
|
|
34
78
|
}
|
|
35
|
-
if (
|
|
79
|
+
if (result.exitCode !== 0 || result.stdout.trim().length === 0) {
|
|
80
|
+
const stderrTail = result.stderr.trim().slice(-2_000);
|
|
81
|
+
const emptyNote = result.exitCode === 0 ? ' (exit 0 but empty stdout)' : '';
|
|
36
82
|
await api.post(ctx, `/api/meetings/${meetingId}/submit`, {
|
|
37
83
|
agentId: state.agentId,
|
|
38
84
|
taskId,
|
|
39
85
|
turnNumber,
|
|
40
86
|
status: 'failed',
|
|
87
|
+
executionTimeMs: result.durationMs,
|
|
41
88
|
artifacts: [
|
|
42
89
|
{
|
|
43
90
|
type: 'text',
|
|
44
91
|
contentType: 'text/plain',
|
|
45
|
-
content: `
|
|
92
|
+
content: `bridge ${bridge.label} exited ${result.exitCode}${result.timedOut ? ' (timed out)' : ''}${emptyNote}\n\n` +
|
|
93
|
+
(stderrTail ? `stderr (last 2 KiB):\n\`\`\`\n${stderrTail}\n\`\`\`` : ''),
|
|
46
94
|
},
|
|
47
95
|
],
|
|
48
96
|
});
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
const rawContent =
|
|
52
|
-
// Allow the
|
|
53
|
-
// by emitting an HTML comment marker anywhere in its output.
|
|
54
|
-
// keeps the shim contract pure stdout (no extra channels) while
|
|
55
|
-
// making it trivial to express "this is the done turn" from a one-
|
|
56
|
-
// line bash echo. We strip the marker before submitting so the
|
|
57
|
-
// transcript artifact stays clean.
|
|
97
|
+
return result.exitCode || 1;
|
|
98
|
+
}
|
|
99
|
+
const rawContent = result.stdout.trim() || '(empty response)';
|
|
100
|
+
// Allow the bridge to declaratively mark the turn as the closing one
|
|
101
|
+
// by emitting an HTML comment marker anywhere in its output.
|
|
58
102
|
const SIGNAL_DONE_MARKER = /<!--\s*agentspeak:signal=done\s*-->/i;
|
|
59
103
|
const isDone = SIGNAL_DONE_MARKER.test(rawContent);
|
|
60
104
|
const content = rawContent.replace(SIGNAL_DONE_MARKER, '').trim() || rawContent;
|
|
@@ -63,7 +107,7 @@ export async function cmdHandleTurn(opts) {
|
|
|
63
107
|
taskId,
|
|
64
108
|
turnNumber,
|
|
65
109
|
status: 'completed',
|
|
66
|
-
executionTimeMs:
|
|
110
|
+
executionTimeMs: result.durationMs,
|
|
67
111
|
signal: isDone ? 'done' : undefined,
|
|
68
112
|
artifacts: [
|
|
69
113
|
{
|
|
@@ -73,7 +117,58 @@ export async function cmdHandleTurn(opts) {
|
|
|
73
117
|
},
|
|
74
118
|
],
|
|
75
119
|
});
|
|
76
|
-
process.stdout.write(`[agentspeak] handle-turn: submitted turn ${turnNumber} (${
|
|
120
|
+
process.stdout.write(`[agentspeak] handle-turn: submitted turn ${turnNumber} (${result.durationMs}ms${isDone ? ', signal=done' : ''})\n`);
|
|
77
121
|
return 0;
|
|
78
122
|
}
|
|
123
|
+
function resolveBridge(opts) {
|
|
124
|
+
if (opts.via && opts.exec) {
|
|
125
|
+
process.stderr.write('agentspeak-cli handle-turn: --via and --exec are mutually exclusive\n');
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
if (opts.via) {
|
|
129
|
+
return { kind: 'via', label: `--via ${opts.via}`, adapterName: opts.via };
|
|
130
|
+
}
|
|
131
|
+
if (opts.exec) {
|
|
132
|
+
return { kind: 'exec', label: `--exec ${opts.exec}`, exec: opts.exec };
|
|
133
|
+
}
|
|
134
|
+
// Auto-shim fallback (Phase 2).
|
|
135
|
+
const { posixPath } = autoShimPaths();
|
|
136
|
+
if (existsSync(posixPath)) {
|
|
137
|
+
return { kind: 'exec', label: `--exec ${posixPath} (auto-shim)`, exec: posixPath };
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
async function runBridge(bridge, envelope, timeoutMs) {
|
|
142
|
+
if (bridge.kind === 'via') {
|
|
143
|
+
const descriptor = resolveAdapter(bridge.adapterName);
|
|
144
|
+
return descriptor.adapter({ envelope, smokeTest: false, timeoutMs });
|
|
145
|
+
}
|
|
146
|
+
return runShim(bridge.exec, envelope, { timeoutMs });
|
|
147
|
+
}
|
|
148
|
+
async function firstPendingMeeting(identity) {
|
|
149
|
+
try {
|
|
150
|
+
const res = await api.get({ baseUrl: identity.baseUrl, token: identity.coordinatorToken }, '/api/agents/me/inbox');
|
|
151
|
+
return res.pendingTurns?.[0]?.meetingId ?? null;
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
if (err instanceof ApiError && err.status === 404) {
|
|
155
|
+
// Old coordinator without the inbox endpoint; skip.
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async function reconstructMeetingState(identity, meetingId) {
|
|
162
|
+
// Sandboxed runtime: we have an identity but no per-meeting state
|
|
163
|
+
// file. Build one from the identity + meeting id; the coordinator
|
|
164
|
+
// already knows we're a participant (we wouldn't be in the inbox
|
|
165
|
+
// otherwise) so we just need the bearer token + meeting id.
|
|
166
|
+
return {
|
|
167
|
+
baseUrl: identity.baseUrl,
|
|
168
|
+
meetingId,
|
|
169
|
+
agentId: identity.agentId,
|
|
170
|
+
coordinatorToken: identity.coordinatorToken,
|
|
171
|
+
joinedAt: new Date().toISOString(),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
79
174
|
//# sourceMappingURL=handle-turn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-turn.js","sourceRoot":"","sources":["../../src/commands/handle-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"handle-turn.js","sourceRoot":"","sources":["../../src/commands/handle-turn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAA6C,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAyCrC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAoB;IACtD,uEAAuE;IACvE,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6EAA6E;YAC3E,gEAAgE,CACnE,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,sEAAsE;IACtE,mEAAmE;IACnE,qCAAqC;IACrC,IAAI,IAAI,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;QACzD,IAAI,CAAC;YACH,YAAY,CAAC,QAAQ,CAAC,C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;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agentspeak-cli identity {export | import <blob> | show}`.
|
|
3
|
+
*
|
|
4
|
+
* Round-trips the local identity through the agent's conversation
|
|
5
|
+
* context. Sandboxed runtimes (Python execute_code, ephemeral
|
|
6
|
+
* containers) lose ~/.agentspeak/identity.json between tool calls; with
|
|
7
|
+
* `identity export` the agent stashes a base64 blob in its working
|
|
8
|
+
* notes, and either:
|
|
9
|
+
*
|
|
10
|
+
* - imports it on the next call (`identity import <blob>`) before
|
|
11
|
+
* running join/handle-turn, OR
|
|
12
|
+
* - passes it inline as `--identity <blob>` to a single command, OR
|
|
13
|
+
* - exports AGENTSPEAK_IDENTITY=<blob> in the environment of the
|
|
14
|
+
* wrapper that spawns the CLI.
|
|
15
|
+
*
|
|
16
|
+
* The exported blob carries the deterministic-identity `clientNonce`
|
|
17
|
+
* (Phase 3a), so re-registration after a sandbox wipe always resolves
|
|
18
|
+
* to the SAME agent_id instead of minting a fresh participant + invite
|
|
19
|
+
* use on every retry.
|
|
20
|
+
*/
|
|
21
|
+
export interface IdentityOpts {
|
|
22
|
+
action?: string;
|
|
23
|
+
blob?: string;
|
|
24
|
+
force?: boolean;
|
|
25
|
+
json?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function cmdIdentity(opts: IdentityOpts): Promise<number>;
|
|
28
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/commands/identity.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBrE"}
|