strands-darwin 0.0.44 → 0.0.45
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/README.md +4 -1
- package/README.zh-CN.md +4 -1
- package/dist/patches/ink+7.1.1.patch +15 -0
- package/dist/src/agent/context-breakdown.d.ts +26 -3
- package/dist/src/agent/context-breakdown.js +27 -1
- package/dist/src/agent/context-breakdown.js.map +1 -1
- package/dist/src/agent/goal-check.d.ts +35 -0
- package/dist/src/agent/goal-check.js +132 -0
- package/dist/src/agent/goal-check.js.map +1 -0
- package/dist/src/agent/model-retry.d.ts +6 -1
- package/dist/src/agent/model-retry.js +45 -9
- package/dist/src/agent/model-retry.js.map +1 -1
- package/dist/src/agent/permission-rules.d.ts +31 -13
- package/dist/src/agent/permission-rules.js +180 -20
- package/dist/src/agent/permission-rules.js.map +1 -1
- package/dist/src/agent/permission.d.ts +0 -6
- package/dist/src/agent/permission.js +4 -3
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +9 -0
- package/dist/src/agent/runtime.js +39 -3
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/safety-classifier.d.ts +3 -1
- package/dist/src/agent/safety-classifier.js +0 -0
- package/dist/src/agent/safety-classifier.js.map +1 -1
- package/dist/src/agent/working-context.d.ts +16 -0
- package/dist/src/agent/working-context.js +20 -0
- package/dist/src/agent/working-context.js.map +1 -1
- package/dist/src/cli-main.js +3 -1
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/cli-mcp.d.ts +12 -0
- package/dist/src/cli-mcp.js +111 -0
- package/dist/src/cli-mcp.js.map +1 -0
- package/dist/src/cli-usage.d.ts +1 -1
- package/dist/src/cli-usage.js +2 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +4 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/collaboration/command.js +1 -1
- package/dist/src/collaboration/command.js.map +1 -1
- package/dist/src/collaboration/local.d.ts +137 -6
- package/dist/src/collaboration/local.js +76 -19
- package/dist/src/collaboration/local.js.map +1 -1
- package/dist/src/collaboration/tools.js +1 -1
- package/dist/src/collaboration/tools.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +1 -1
- package/dist/src/commands/custom-commands.js +3 -1
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/commands/goal-command.d.ts +26 -0
- package/dist/src/commands/goal-command.js +32 -0
- package/dist/src/commands/goal-command.js.map +1 -0
- package/dist/src/config.d.ts +3 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/mcp/oauth-login.d.ts +37 -0
- package/dist/src/mcp/oauth-login.js +263 -0
- package/dist/src/mcp/oauth-login.js.map +1 -0
- package/dist/src/mcp/oauth-net.d.ts +50 -0
- package/dist/src/mcp/oauth-net.js +321 -0
- package/dist/src/mcp/oauth-net.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +89 -0
- package/dist/src/mcp/oauth-provider.js +398 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-store.d.ts +49 -0
- package/dist/src/mcp/oauth-store.js +176 -0
- package/dist/src/mcp/oauth-store.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +6 -0
- package/dist/src/mcp/registry.js +83 -4
- package/dist/src/mcp/registry.js.map +1 -1
- package/dist/src/tools/shell-env.d.ts +27 -1
- package/dist/src/tools/shell-env.js +34 -5
- package/dist/src/tools/shell-env.js.map +1 -1
- package/dist/src/tui/App.d.ts +4 -1
- package/dist/src/tui/App.js +209 -10
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +1 -1
- package/dist/src/tui/InputBox.js +1 -1
- package/dist/src/tui/context-format.d.ts +7 -3
- package/dist/src/tui/context-format.js +28 -3
- package/dist/src/tui/context-format.js.map +1 -1
- package/dist/src/tui/goal.d.ts +123 -0
- package/dist/src/tui/goal.js +187 -0
- package/dist/src/tui/goal.js.map +1 -0
- package/dist/src/tui/help-format.d.ts +1 -1
- package/dist/src/tui/help-format.js +1 -1
- package/dist/src/tui/mcp-format.js +5 -1
- package/dist/src/tui/mcp-format.js.map +1 -1
- package/dist/src/tui/prompt-editor.d.ts +4 -3
- package/dist/src/tui/prompt-editor.js +8 -3
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `darwin mcp login <name> [--no-browser]` and `darwin mcp logout <name>` (SER-107).
|
|
3
|
+
*
|
|
4
|
+
* Routed by `cli.ts` before `cli-main` (no runtime, model, Ink, session or MCP client is built).
|
|
5
|
+
* `login` resolves the server exactly as a session would — the entry a session in this directory
|
|
6
|
+
* would connect to — and refuses before any token read or network request when that entry is
|
|
7
|
+
* declared by a project layer the workspace-trust decision holds (SER-090): a checkout cannot make
|
|
8
|
+
* `darwin mcp login` talk to a server the user has not consented to. Every other refusal is a
|
|
9
|
+
* plain one-line error and exit 1; a grammar error is exit 2 with the shared usage hint.
|
|
10
|
+
*/
|
|
11
|
+
import { ConfigError } from './config.js';
|
|
12
|
+
import { usageErrorText } from './cli-usage.js';
|
|
13
|
+
import { projectLayersArmed, resolveWorkspaceTrust } from './agent/workspace-trust.js';
|
|
14
|
+
import { deleteOAuthRecord } from './mcp/oauth-store.js';
|
|
15
|
+
import { describeLoginFailure, runOAuthLogin, LOGIN_TIMEOUT_MS } from './mcp/oauth-login.js';
|
|
16
|
+
import { resolveOAuthSettings } from './mcp/oauth-provider.js';
|
|
17
|
+
import { inventoryProjectMcpServers, readMcpServerConfigs } from './mcp/registry.js';
|
|
18
|
+
export const MCP_USAGE = 'usage: darwin mcp login <name> [--no-browser] | darwin mcp logout <name>';
|
|
19
|
+
/** Runs the command and returns the process exit code (0 ok, 1 refused/failed, 2 usage). */
|
|
20
|
+
export async function mcpCommand(projectRoot, argv, overrides = {}) {
|
|
21
|
+
const io = {
|
|
22
|
+
stdout: (text) => void process.stdout.write(text),
|
|
23
|
+
stderr: (text) => void process.stderr.write(text),
|
|
24
|
+
timeoutMs: LOGIN_TIMEOUT_MS,
|
|
25
|
+
open: undefined,
|
|
26
|
+
signal: undefined,
|
|
27
|
+
...overrides,
|
|
28
|
+
};
|
|
29
|
+
const usage = () => {
|
|
30
|
+
io.stderr(usageErrorText(MCP_USAGE));
|
|
31
|
+
return 2;
|
|
32
|
+
};
|
|
33
|
+
const [verb, name, ...flags] = argv;
|
|
34
|
+
if ((verb !== 'login' && verb !== 'logout') || name === undefined || name === '' || name.startsWith('-'))
|
|
35
|
+
return usage();
|
|
36
|
+
const noBrowser = flags.length === 1 && flags[0] === '--no-browser' && verb === 'login';
|
|
37
|
+
if (flags.length > 0 && !noBrowser)
|
|
38
|
+
return usage();
|
|
39
|
+
if (verb === 'logout') {
|
|
40
|
+
let removed;
|
|
41
|
+
try {
|
|
42
|
+
removed = await deleteOAuthRecord(name);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
io.stderr(`error: could not remove the stored login for ${name}: ${describeLoginFailure(error)}\n`);
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
io.stdout(removed ? `logged out of ${name}: stored login removed\n` : `no stored login for ${name}\n`);
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
// The entry a session here would use: the project layer only when it declares the name AND is trusted.
|
|
52
|
+
const inventory = await inventoryProjectMcpServers(projectRoot);
|
|
53
|
+
const projectDeclared = inventory.servers.some((server) => server.name === name);
|
|
54
|
+
const armed = projectDeclared ? projectLayersArmed(await resolveWorkspaceTrust(projectRoot)) : false;
|
|
55
|
+
let entry;
|
|
56
|
+
try {
|
|
57
|
+
const configs = await readMcpServerConfigs(projectRoot, { projectLayer: projectDeclared && armed ? 'armed' : 'held' });
|
|
58
|
+
entry = configs.servers?.[name];
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
io.stderr(`error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
if (entry === undefined) {
|
|
65
|
+
io.stderr(projectDeclared && !armed
|
|
66
|
+
? `error: MCP server "${name}" is declared by this project (${inventory.servers.find((server) => server.name === name).file}), which is not trusted. ` +
|
|
67
|
+
`Nothing was contacted. Start \`darwin\` in this directory and trust the workspace, then run this again.\n`
|
|
68
|
+
: `error: no MCP server named "${name}" is configured. Run \`darwin doctor\` or \`/mcp\` to see the servers darwin reads.\n`);
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
let settings;
|
|
72
|
+
try {
|
|
73
|
+
settings = resolveOAuthSettings(name, entry);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
io.stderr(`error: ${error instanceof ConfigError ? error.message : describeLoginFailure(error)}\n`);
|
|
77
|
+
return 1;
|
|
78
|
+
}
|
|
79
|
+
if (settings === undefined) {
|
|
80
|
+
io.stderr(`error: MCP server "${name}" has no "oauth" entry. Add \`"oauth": true\` to its config (remote streamable-http servers only), then run this again.\n`);
|
|
81
|
+
return 1;
|
|
82
|
+
}
|
|
83
|
+
const controller = new AbortController();
|
|
84
|
+
const onSignal = () => controller.abort();
|
|
85
|
+
process.once('SIGINT', onSignal);
|
|
86
|
+
io.signal?.addEventListener('abort', onSignal, { once: true });
|
|
87
|
+
try {
|
|
88
|
+
io.stderr(`Logging in to MCP server "${name}" (${settings.serverUrl.origin})…\n`);
|
|
89
|
+
await runOAuthLogin({
|
|
90
|
+
settings,
|
|
91
|
+
timeoutMs: io.timeoutMs,
|
|
92
|
+
signal: controller.signal,
|
|
93
|
+
log: (line) => io.stderr(`${line}\n`),
|
|
94
|
+
...(noBrowser ? { open: false } : io.open === undefined ? {} : { open: io.open }),
|
|
95
|
+
});
|
|
96
|
+
io.stdout(`logged in to ${name}; restart darwin (or start a new session) to use it\n`);
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
io.stderr(`error: login to "${name}" failed: ${describeLoginFailure(error)}\n`);
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
process.off('SIGINT', onSignal);
|
|
105
|
+
io.signal?.removeEventListener('abort', onSignal);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export async function runMcpCli(projectRoot, argv) {
|
|
109
|
+
process.exitCode = await mcpCommand(projectRoot, argv);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=cli-mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-mcp.js","sourceRoot":"","sources":["../../src/cli-mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,CAAC,MAAM,SAAS,GAAG,0EAA0E,CAAC;AAWpG,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,WAAmB,EACnB,IAAuB,EACvB,SAAS,GAAgC,EAAE;IAE3C,MAAM,EAAE,GAAuB;QAC7B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;QACjD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;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CAAC;SAC3F,CAAC,CAAC;QACH,EAAE,CAAC,MAAM,CAAC,gBAAgB,IAAI,uDAAuD,CAAC,CAAC;QACvF,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,EAAE,CAAC,MAAM,CAAC,oBAAoB,IAAI,aAAa,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChF,OAAO,CAAC,CAAC;IACX,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChC,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,WAAmB,EAAE,IAAuB;IAC1E,OAAO,CAAC,QAAQ,GAAG,MAAM,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/src/cli-usage.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const HELP_FLAGS: readonly ['--help', '-h'];
|
|
2
2
|
export declare const VERSION_FLAGS: readonly ['--version', '-V'];
|
|
3
3
|
/** The complete grammar, exactly as `darwin --help` prints it (trailing newline included). */
|
|
4
|
-
export declare const CLI_USAGE = "Usage: darwin [--resume [<id>]|--session <id>] [--permission-mode <default|auto|plan|yolo>] [--yolo]\n darwin -p <message> [--output-format text|json|stream-json]\n [--continue|--resume [<id>]|--session <id>] [permission flags]\n [--max-model-calls <n>] [--context-offload] [--compact-before]\n darwin sessions\n darwin list-agents\n darwin collaborate [status|list|pending|relations|on|off]\n darwin collaborate send <endpoint-uuid> <literal text>\n darwin collaborate confirm <pending-id> --persist\n darwin collaborate revoke <pair-id>\n darwin collaborate hub enroll <url> <token> [--name <label>]\n darwin collaborate hub status|nodes|leave|publish on|off|block <node>|unblock <node>\n darwin permissions test <rule>\n darwin import --from claude-code [--apply]\n darwin doctor\n darwin cloud-memory [status|preferences|list|inspect|pending|preview] \u2026\n darwin trajectory <list|search|replay|fork> \u2026\n darwin --help | -h\n darwin --version | -V\n\n--context-offload force-enables the default-on offloader for this process; it never persists.\nPrint-only flags: --output-format, --max-model-calls, --context-offload, --compact-before, --continue.\nWith -p, piped (non-TTY) stdin is read to EOF and appended to <message> as one delimited block (256 KiB cap).\n";
|
|
4
|
+
export declare const CLI_USAGE = "Usage: darwin [--resume [<id>]|--session <id>] [--permission-mode <default|auto|plan|yolo>] [--yolo]\n darwin -p <message> [--output-format text|json|stream-json]\n [--continue|--resume [<id>]|--session <id>] [permission flags]\n [--max-model-calls <n>] [--context-offload] [--compact-before]\n darwin sessions\n darwin list-agents\n darwin collaborate [status|list|pending|relations|on|off]\n darwin collaborate send <endpoint-uuid> <literal text>\n darwin collaborate confirm <pending-id> --persist\n darwin collaborate revoke <pair-id>\n darwin collaborate hub enroll <url> <token> [--name <label>]\n darwin collaborate hub status|nodes|leave|publish on|off|block <node>|unblock <node>\n darwin permissions test <rule>\n darwin mcp login <name> [--no-browser]\n darwin mcp logout <name>\n darwin import --from claude-code [--apply]\n darwin doctor\n darwin cloud-memory [status|preferences|list|inspect|pending|preview] \u2026\n darwin trajectory <list|search|replay|fork> \u2026\n darwin --help | -h\n darwin --version | -V\n\n--context-offload force-enables the default-on offloader for this process; it never persists.\nPrint-only flags: --output-format, --max-model-calls, --context-offload, --compact-before, --continue.\nWith -p, piped (non-TTY) stdin is read to EOF and appended to <message> as one delimited block (256 KiB cap).\n";
|
|
5
5
|
/** The one hint every usage error appends after its `error:` line. */
|
|
6
6
|
export declare const CLI_HELP_HINT = "Run `darwin --help` for usage.";
|
|
7
7
|
/**
|
package/dist/src/cli-usage.js
CHANGED
|
@@ -27,6 +27,8 @@ export const CLI_USAGE = `Usage: darwin [--resume [<id>]|--session <id>] [--perm
|
|
|
27
27
|
darwin collaborate hub enroll <url> <token> [--name <label>]
|
|
28
28
|
darwin collaborate hub status|nodes|leave|publish on|off|block <node>|unblock <node>
|
|
29
29
|
darwin permissions test <rule>
|
|
30
|
+
darwin mcp login <name> [--no-browser]
|
|
31
|
+
darwin mcp logout <name>
|
|
30
32
|
darwin import --from claude-code [--apply]
|
|
31
33
|
darwin doctor
|
|
32
34
|
darwin cloud-memory [status|preferences|list|inspect|pending|preview] …
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-usage.js","sourceRoot":"","sources":["../../src/cli-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAU,CAAC;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,IAAI,CAAU,CAAC;AAE1D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,SAAS,GAAG
|
|
1
|
+
{"version":3,"file":"cli-usage.js","sourceRoot":"","sources":["../../src/cli-usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAU,CAAC;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,IAAI,CAAU,CAAC;AAE1D,8FAA8F;AAC9F,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBxB,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,aAAa,GAAG,gCAAgC,CAAC;AAE9D;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,UAAU,OAAO,KAAK,aAAa,IAAI,CAAC;AACjD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,OAAO,WAAW,SAAS,8BAA8B,SAAS,IAAI,CAAC;AACzE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAuB;IACpD,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IACrE,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,UAAU,cAAc,IAAI,CAAC;IAC3F,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/src/cli.js
CHANGED
|
@@ -42,6 +42,10 @@ else {
|
|
|
42
42
|
const { runPermissionsCli } = await import('./cli-permissions.js');
|
|
43
43
|
await runPermissionsCli(process.cwd(), args.slice(1));
|
|
44
44
|
}
|
|
45
|
+
else if (args[0] === 'mcp' && !args.some(arg => ['--help', '-h', '--version', '-V'].includes(arg))) {
|
|
46
|
+
const { runMcpCli } = await import('./cli-mcp.js');
|
|
47
|
+
await runMcpCli(process.cwd(), args.slice(1));
|
|
48
|
+
}
|
|
45
49
|
else if (args[0] === 'cloud-memory' && !args.some(arg => ['--help', '-h', '--version', '-V'].includes(arg))) {
|
|
46
50
|
const { runCloudMemoryCli } = await import('./agentcore/cli.js');
|
|
47
51
|
await runCloudMemoryCli(process.cwd(), args.slice(1));
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE5F,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;AACpC,IAAI,OAAO,KAAK,SAAS,EAAE,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,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;SAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACrG,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;QACnD,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;SAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,cAAc,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC9G,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACjE,MAAM,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;QAC/C,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -45,7 +45,7 @@ export async function collaborationCommand(local, text) {
|
|
|
45
45
|
await local.start();
|
|
46
46
|
}
|
|
47
47
|
const hub = `${local.hub.state}${local.hub.reason ? ` (${local.hub.reason})` : ''}${local.hub.address ? ` endpoint ${local.hub.address.endpoint}` : ''}`;
|
|
48
|
-
return `${result}\nThis endpoint: ${JSON.stringify(local.
|
|
48
|
+
return `${result}\nThis endpoint: ${JSON.stringify(local.endpointStatus)}; queued: ${local.pending}\nHub: ${hub}\n${COLLABORATE_USAGE}`;
|
|
49
49
|
}
|
|
50
50
|
export async function runCollaborationCli(root, args) {
|
|
51
51
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/collaboration/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,6FAA6F;AAC7F,SAAS,eAAe,CAAC,IAAuB;IAC9C,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9B,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,OAAO;IAAC,CAAC;IAC5D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAK,CAAC;QAAE,OAAO;IACzG,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO;QAAE,OAAO;IAC9G,IAAI,IAAI,KAAK,QAA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I,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO;QAAC,CAAC;QACtG,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,OAAO,UAAU,EAAE,EAAE,CAAC,CAAC;QAClE,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,4EAA4E;QAC5E,4EAA4E;QAC5E,IAAI,CAAC;YAAC,KAAK,CAAC,cAAc,EAAE,CAAC;YAAC,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;gBACzF,CAAC;YAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC,CAAC;QACnG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { type PeerAddress, type PeerInput, type PeerTransport } from './protocol.js';
|
|
2
2
|
import { HubTransport } from './hub-transport.js';
|
|
3
3
|
export declare function socketPath(id: string): string;
|
|
4
|
-
/** Bounded
|
|
5
|
-
export declare function discoverPeers(): Promise<{
|
|
6
|
-
|
|
4
|
+
/** Bounded authenticated endpoint projection; exclusion happens before probe slots are reserved. */
|
|
5
|
+
export declare function discoverPeers(excludeEndpoint?: string): Promise<{
|
|
6
|
+
state: 'readable';
|
|
7
|
+
endpoints: {
|
|
8
|
+
version: 1;
|
|
9
|
+
transport: "local";
|
|
10
|
+
node: string;
|
|
11
|
+
endpoint: string;
|
|
12
|
+
project: string;
|
|
13
|
+
session: string;
|
|
14
|
+
}[];
|
|
7
15
|
omitted: number;
|
|
16
|
+
omissions: {
|
|
17
|
+
self: number;
|
|
18
|
+
unusableRegistrationOrSocket: number;
|
|
19
|
+
challengeFailed: number;
|
|
20
|
+
probeLimit: number;
|
|
21
|
+
};
|
|
8
22
|
uninspected: number;
|
|
9
23
|
scanLimited: boolean;
|
|
10
24
|
scope: string;
|
|
@@ -41,6 +55,7 @@ export declare class LocalCollaboration implements PeerTransport {
|
|
|
41
55
|
private accepting;
|
|
42
56
|
private stopped;
|
|
43
57
|
private generation;
|
|
58
|
+
private inactiveReason;
|
|
44
59
|
private canonicalRoot;
|
|
45
60
|
/** Cross-machine transport (hub/README.md); shares this session's inbox, ledger and caps. */
|
|
46
61
|
readonly hub: HubTransport;
|
|
@@ -52,6 +67,20 @@ export declare class LocalCollaboration implements PeerTransport {
|
|
|
52
67
|
get root(): string;
|
|
53
68
|
get pending(): number;
|
|
54
69
|
get active(): boolean;
|
|
70
|
+
/** Runtime state, not the global policy's enabled bit; contains no credential. */
|
|
71
|
+
get endpointStatus(): {
|
|
72
|
+
active: boolean;
|
|
73
|
+
address: {
|
|
74
|
+
version: 1;
|
|
75
|
+
transport: "local";
|
|
76
|
+
node: string;
|
|
77
|
+
endpoint: string;
|
|
78
|
+
project: string;
|
|
79
|
+
session: string;
|
|
80
|
+
} | null;
|
|
81
|
+
reason?: string;
|
|
82
|
+
userAction?: string;
|
|
83
|
+
};
|
|
55
84
|
subscribe(listener: () => void): () => void;
|
|
56
85
|
takeNotices(): string[];
|
|
57
86
|
private changed;
|
|
@@ -96,9 +125,111 @@ export declare class LocalCollaboration implements PeerTransport {
|
|
|
96
125
|
private notifyExpired;
|
|
97
126
|
/** Drop queued hub input from one node (revoked at the hub, or blocked by the user). */
|
|
98
127
|
dropHubNode(node: string, reason: string): void;
|
|
99
|
-
/**
|
|
100
|
-
discover(): Promise<
|
|
101
|
-
|
|
128
|
+
/** Endpoints are authenticated send targets; lease holders are diagnostic only. */
|
|
129
|
+
discover(): Promise<{
|
|
130
|
+
state: 'readable';
|
|
131
|
+
endpoints: {
|
|
132
|
+
version: 1;
|
|
133
|
+
transport: "local";
|
|
134
|
+
node: string;
|
|
135
|
+
endpoint: string;
|
|
136
|
+
project: string;
|
|
137
|
+
session: string;
|
|
138
|
+
}[];
|
|
139
|
+
omitted: number;
|
|
140
|
+
omissions: {
|
|
141
|
+
self: number;
|
|
142
|
+
unusableRegistrationOrSocket: number;
|
|
143
|
+
challengeFailed: number;
|
|
144
|
+
probeLimit: number;
|
|
145
|
+
};
|
|
146
|
+
uninspected: number;
|
|
147
|
+
scanLimited: boolean;
|
|
148
|
+
scope: string;
|
|
149
|
+
self: {
|
|
150
|
+
active: boolean;
|
|
151
|
+
address: {
|
|
152
|
+
version: 1;
|
|
153
|
+
transport: "local";
|
|
154
|
+
node: string;
|
|
155
|
+
endpoint: string;
|
|
156
|
+
project: string;
|
|
157
|
+
session: string;
|
|
158
|
+
} | null;
|
|
159
|
+
reason?: string;
|
|
160
|
+
userAction?: string;
|
|
161
|
+
project: string;
|
|
162
|
+
session: string;
|
|
163
|
+
};
|
|
164
|
+
localSessions: {
|
|
165
|
+
project: string;
|
|
166
|
+
rows: {
|
|
167
|
+
session: string;
|
|
168
|
+
pid: number;
|
|
169
|
+
startedAt: string;
|
|
170
|
+
communication: string;
|
|
171
|
+
}[];
|
|
172
|
+
state: "missing" | "readable" | "unavailable";
|
|
173
|
+
omissions: Record<string, number>;
|
|
174
|
+
limits: string[];
|
|
175
|
+
scope: string;
|
|
176
|
+
};
|
|
177
|
+
hub: {
|
|
178
|
+
state: import("./hub-transport.js").HubState;
|
|
179
|
+
reason?: string;
|
|
180
|
+
endpoints: Array<{
|
|
181
|
+
address: import("./hub-wire.js").HubAddress;
|
|
182
|
+
name: string;
|
|
183
|
+
fingerprint: string;
|
|
184
|
+
}>;
|
|
185
|
+
omitted: number;
|
|
186
|
+
};
|
|
187
|
+
} | {
|
|
188
|
+
state: 'unavailable';
|
|
189
|
+
endpoints: never[];
|
|
190
|
+
omitted: null;
|
|
191
|
+
omissions: null;
|
|
192
|
+
uninspected: null;
|
|
193
|
+
scanLimited: null;
|
|
194
|
+
scope: string;
|
|
195
|
+
self: {
|
|
196
|
+
active: boolean;
|
|
197
|
+
address: {
|
|
198
|
+
version: 1;
|
|
199
|
+
transport: "local";
|
|
200
|
+
node: string;
|
|
201
|
+
endpoint: string;
|
|
202
|
+
project: string;
|
|
203
|
+
session: string;
|
|
204
|
+
} | null;
|
|
205
|
+
reason?: string;
|
|
206
|
+
userAction?: string;
|
|
207
|
+
project: string;
|
|
208
|
+
session: string;
|
|
209
|
+
};
|
|
210
|
+
localSessions: {
|
|
211
|
+
project: string;
|
|
212
|
+
rows: {
|
|
213
|
+
session: string;
|
|
214
|
+
pid: number;
|
|
215
|
+
startedAt: string;
|
|
216
|
+
communication: string;
|
|
217
|
+
}[];
|
|
218
|
+
state: "missing" | "readable" | "unavailable";
|
|
219
|
+
omissions: Record<string, number>;
|
|
220
|
+
limits: string[];
|
|
221
|
+
scope: string;
|
|
222
|
+
};
|
|
223
|
+
hub: {
|
|
224
|
+
state: import("./hub-transport.js").HubState;
|
|
225
|
+
reason?: string;
|
|
226
|
+
endpoints: Array<{
|
|
227
|
+
address: import("./hub-wire.js").HubAddress;
|
|
228
|
+
name: string;
|
|
229
|
+
fingerprint: string;
|
|
230
|
+
}>;
|
|
231
|
+
omitted: number;
|
|
232
|
+
};
|
|
102
233
|
}>;
|
|
103
234
|
private enqueue;
|
|
104
235
|
/** Only a driver at idle takes input. Runtime rechecks it immediately before invocation. */
|
|
@@ -3,7 +3,8 @@ import { chmodSync, lstatSync, opendirSync, unlinkSync } from 'node:fs';
|
|
|
3
3
|
import net from 'node:net';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { collaborationDir } from '../paths.js';
|
|
6
|
+
import { collaborationDir, projectKey } from '../paths.js';
|
|
7
|
+
import { readLocalAgents } from '../list-agents.js';
|
|
7
8
|
import { authorization, canonicalProject, checkStore, idSchema, readPolicy, readPrivate, requestCooperation, withPolicy, writePrivate } from './storage.js';
|
|
8
9
|
import { addressSchema, authentic, CHAIN_TTL_MS, dropNoticeId, dropNoticeText, IO_TIMEOUT_MS, localEnvelopeSchema, MAX_AUTO_RESENDS, MAX_FRAME_BYTES, MAX_HOPS, MAX_QUEUE, MESSAGE_TTL_MS, queuedText, sign } from './protocol.js';
|
|
9
10
|
import { isPublished } from './hub-store.js';
|
|
@@ -101,10 +102,11 @@ async function probe(record) {
|
|
|
101
102
|
if (result !== 'live')
|
|
102
103
|
throw new Error('Endpoint is not live');
|
|
103
104
|
}
|
|
104
|
-
/** Bounded
|
|
105
|
-
export async function discoverPeers() {
|
|
105
|
+
/** Bounded authenticated endpoint projection; exclusion happens before probe slots are reserved. */
|
|
106
|
+
export async function discoverPeers(excludeEndpoint) {
|
|
106
107
|
const dir = opendirSync(checkStore());
|
|
107
108
|
const candidates = [];
|
|
109
|
+
const omissions = { self: 0, unusableRegistrationOrSocket: 0, challengeFailed: 0, probeLimit: 0 };
|
|
108
110
|
let omitted = 0;
|
|
109
111
|
let uninspected = 0;
|
|
110
112
|
let scanLimited = false;
|
|
@@ -114,20 +116,27 @@ export async function discoverPeers() {
|
|
|
114
116
|
if (!entry)
|
|
115
117
|
break;
|
|
116
118
|
if (/^[a-f0-9-]{36}\.json$/.test(entry.name)) {
|
|
117
|
-
|
|
118
|
-
// Cheap private metadata/socket checks precede the expensive challenge
|
|
119
|
-
// budget. Crash remnants must not hide current live endpoints.
|
|
120
|
-
const record = registration(entry.name.slice(0, -5));
|
|
121
|
-
if (candidates.length < 32)
|
|
122
|
-
candidates.push(record);
|
|
123
|
-
else {
|
|
124
|
-
omitted++;
|
|
125
|
-
uninspected++;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
119
|
+
if (entry.name === `${excludeEndpoint}.json`) {
|
|
129
120
|
omitted++;
|
|
121
|
+
omissions.self++;
|
|
130
122
|
}
|
|
123
|
+
else
|
|
124
|
+
try {
|
|
125
|
+
// Cheap private metadata/socket checks precede the expensive challenge
|
|
126
|
+
// budget. Crash remnants must not hide current live endpoints.
|
|
127
|
+
const record = registration(entry.name.slice(0, -5));
|
|
128
|
+
if (candidates.length < 32)
|
|
129
|
+
candidates.push(record);
|
|
130
|
+
else {
|
|
131
|
+
omitted++;
|
|
132
|
+
uninspected++;
|
|
133
|
+
omissions.probeLimit++;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
omitted++;
|
|
138
|
+
omissions.unusableRegistrationOrSocket++;
|
|
139
|
+
}
|
|
131
140
|
}
|
|
132
141
|
if (n === 255)
|
|
133
142
|
scanLimited = dir.readSync() !== null;
|
|
@@ -146,10 +155,11 @@ export async function discoverPeers() {
|
|
|
146
155
|
}
|
|
147
156
|
catch {
|
|
148
157
|
omitted++;
|
|
158
|
+
omissions.challengeFailed++;
|
|
149
159
|
}
|
|
150
160
|
}));
|
|
151
161
|
}
|
|
152
|
-
return { endpoints: endpoints.sort((a, b) => a.endpoint.localeCompare(b.endpoint)), omitted, uninspected, scanLimited, scope: '
|
|
162
|
+
return { state: 'readable', endpoints: endpoints.sort((a, b) => a.endpoint.localeCompare(b.endpoint)), omitted, omissions, uninspected, scanLimited, scope: 'Authenticated local messaging endpoints only; the requesting runtime is excluded when supplied. Omitted is the sum of omissions: self, unusable registration/socket (invalid, unsafe or missing), failed live challenge, and probe limit. Uninspected is the probe-limit subset; scanLimited means further directory entries were not inspected (count unknown). Empty endpoints does not mean no other Darwin is running. Discovery starts no model work and performs no cleanup.' };
|
|
153
163
|
}
|
|
154
164
|
/** One parent session, never a daemon or SDK loop. Only drivers drain the inbox. */
|
|
155
165
|
export class LocalCollaboration {
|
|
@@ -183,6 +193,7 @@ export class LocalCollaboration {
|
|
|
183
193
|
accepting = false;
|
|
184
194
|
stopped = false;
|
|
185
195
|
generation = 0;
|
|
196
|
+
inactiveReason = 'not started';
|
|
186
197
|
canonicalRoot;
|
|
187
198
|
/** Cross-machine transport (hub/README.md); shares this session's inbox, ledger and caps. */
|
|
188
199
|
hub;
|
|
@@ -208,6 +219,17 @@ export class LocalCollaboration {
|
|
|
208
219
|
get root() { return this.projectRoot; }
|
|
209
220
|
get pending() { return this.inbox.length; }
|
|
210
221
|
get active() { return this.accepting; }
|
|
222
|
+
/** Runtime state, not the global policy's enabled bit; contains no credential. */
|
|
223
|
+
get endpointStatus() {
|
|
224
|
+
return {
|
|
225
|
+
active: this.active,
|
|
226
|
+
address: this.address ?? null,
|
|
227
|
+
...(!this.active ? {
|
|
228
|
+
reason: this.address ? 'admission closed' : this.inactiveReason,
|
|
229
|
+
userAction: 'User: /collaborate on in this session to publish a new local endpoint',
|
|
230
|
+
} : {}),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
211
233
|
subscribe(listener) { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; }
|
|
212
234
|
takeNotices() { return this.notices.splice(0); }
|
|
213
235
|
changed() { for (const listener of this.listeners) {
|
|
@@ -222,6 +244,7 @@ export class LocalCollaboration {
|
|
|
222
244
|
if (this.server)
|
|
223
245
|
return;
|
|
224
246
|
this.stopped = false;
|
|
247
|
+
this.inactiveReason = 'starting';
|
|
225
248
|
const generation = ++this.generation;
|
|
226
249
|
try {
|
|
227
250
|
this.canonicalRoot = canonicalProject(this.projectRoot);
|
|
@@ -229,6 +252,7 @@ export class LocalCollaboration {
|
|
|
229
252
|
if (this.stopped || generation !== this.generation)
|
|
230
253
|
return;
|
|
231
254
|
if (!readPolicy().enabled) {
|
|
255
|
+
this.inactiveReason = 'collaboration off';
|
|
232
256
|
this.notice('Collaboration is off. User: /collaborate on');
|
|
233
257
|
return;
|
|
234
258
|
}
|
|
@@ -286,6 +310,7 @@ export class LocalCollaboration {
|
|
|
286
310
|
*/
|
|
287
311
|
close(reason) {
|
|
288
312
|
this.generation++;
|
|
313
|
+
this.inactiveReason = reason.slice(0, 256);
|
|
289
314
|
this.stopped = true;
|
|
290
315
|
this.accepting = false;
|
|
291
316
|
const hubClosed = this.hub.close();
|
|
@@ -489,10 +514,42 @@ export class LocalCollaboration {
|
|
|
489
514
|
if (this.inbox.length !== before)
|
|
490
515
|
this.notice(`peer messages dropped: ${before - this.inbox.length} (${reason})`);
|
|
491
516
|
}
|
|
492
|
-
/**
|
|
517
|
+
/** Endpoints are authenticated send targets; lease holders are diagnostic only. */
|
|
493
518
|
async discover() {
|
|
494
|
-
const
|
|
495
|
-
|
|
519
|
+
const project = this.canonicalRoot ?? this.projectRoot;
|
|
520
|
+
const key = projectKey(project);
|
|
521
|
+
const [local, hub, inventory] = await Promise.all([
|
|
522
|
+
discoverPeers(this.address?.endpoint).catch(() => ({
|
|
523
|
+
state: 'unavailable', endpoints: [], omitted: null, omissions: null, uninspected: null, scanLimited: null,
|
|
524
|
+
scope: 'Local endpoint inventory unavailable; inspection and omission counts are unknown. No credentials or private errors are returned. Lease holders and self state remain diagnostic only; no endpoint is authenticated by this failed scan.',
|
|
525
|
+
})),
|
|
526
|
+
this.hub.discover(), readLocalAgents(project, this.session),
|
|
527
|
+
]);
|
|
528
|
+
const self = this.endpointStatus;
|
|
529
|
+
// User on/cancel may replace the incarnation while discovery awaits probes.
|
|
530
|
+
// Keep the final self projection out of targets too; send's guard is unchanged.
|
|
531
|
+
if (local.state === 'readable') {
|
|
532
|
+
const endpoints = local.endpoints.filter(endpoint => endpoint.endpoint !== self.address?.endpoint);
|
|
533
|
+
const excluded = local.endpoints.length - endpoints.length;
|
|
534
|
+
local.endpoints = endpoints;
|
|
535
|
+
local.omitted += excluded;
|
|
536
|
+
local.omissions.self += excluded;
|
|
537
|
+
}
|
|
538
|
+
const rows = inventory.rows.filter(row => row.projectKey === key && row.sessionId !== this.session).map(row => ({
|
|
539
|
+
session: row.sessionId, pid: row.pid, startedAt: row.startedAt,
|
|
540
|
+
communication: local.state === 'unavailable' ? 'discovery-unavailable'
|
|
541
|
+
: local.endpoints.some(endpoint => endpoint.project === project && endpoint.session === row.sessionId)
|
|
542
|
+
? 'authenticated-endpoint' : 'not-discovered',
|
|
543
|
+
}));
|
|
544
|
+
return {
|
|
545
|
+
...local,
|
|
546
|
+
self: { project: self.address?.project ?? project, session: this.session, ...self },
|
|
547
|
+
localSessions: {
|
|
548
|
+
project, rows, state: inventory.state, omissions: inventory.omissions, limits: inventory.limits,
|
|
549
|
+
scope: 'Other same-project live session lease holders from the bounded read-only /list-agents inventory. PID/lease is not authenticated identity or a send target. Not-discovered does not prove collaboration is off: an endpoint may be closed, unavailable, unsupported or outside discovery bounds. Ask the user to inspect /collaborate status in that session; /collaborate on republishes its endpoint. Inventory omissions/limits cover the whole HOME scan; older/non-registering processes are not tracked.',
|
|
550
|
+
},
|
|
551
|
+
hub,
|
|
552
|
+
};
|
|
496
553
|
}
|
|
497
554
|
enqueue(envelope, auth) {
|
|
498
555
|
const now = Date.now();
|