@namzu/sdk 69.0.0 → 69.2.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/CHANGELOG.md +68 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +2 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/authorization/skill-grant.d.ts.map +1 -1
- package/dist/authorization/skill-grant.js +1 -0
- package/dist/authorization/skill-grant.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +10 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +1 -0
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/connector/index.d.ts +2 -2
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +29 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +59 -2
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/errors.d.ts +7 -0
- package/dist/connector/mcp/errors.d.ts.map +1 -1
- package/dist/connector/mcp/errors.js +14 -0
- package/dist/connector/mcp/errors.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +5 -1
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +3 -1
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/skill-source.d.ts +144 -0
- package/dist/connector/mcp/skill-source.d.ts.map +1 -0
- package/dist/connector/mcp/skill-source.js +375 -0
- package/dist/connector/mcp/skill-source.js.map +1 -0
- package/dist/connector/mcp/skills.d.ts +137 -0
- package/dist/connector/mcp/skills.d.ts.map +1 -0
- package/dist/connector/mcp/skills.js +303 -0
- package/dist/connector/mcp/skills.js.map +1 -0
- package/dist/network/audit.d.ts +1 -1
- package/dist/network/audit.d.ts.map +1 -1
- package/dist/network/audit.js +2 -0
- package/dist/network/audit.js.map +1 -1
- package/dist/network/computer.d.ts +107 -0
- package/dist/network/computer.d.ts.map +1 -0
- package/dist/network/computer.js +250 -0
- package/dist/network/computer.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.d.ts.map +1 -1
- package/dist/network/index.js +1 -0
- package/dist/network/index.js.map +1 -1
- package/dist/network/join.d.ts +3 -1
- package/dist/network/join.d.ts.map +1 -1
- package/dist/network/join.js +6 -3
- package/dist/network/join.js.map +1 -1
- package/dist/network/roster.d.ts +5 -0
- package/dist/network/roster.d.ts.map +1 -1
- package/dist/network/roster.js.map +1 -1
- package/dist/network/service.d.ts +12 -2
- package/dist/network/service.d.ts.map +1 -1
- package/dist/network/service.js +377 -52
- package/dist/network/service.js.map +1 -1
- package/dist/network/store.d.ts +10 -0
- package/dist/network/store.d.ts.map +1 -1
- package/dist/network/store.js +25 -3
- package/dist/network/store.js.map +1 -1
- package/dist/network/wire.d.ts +2 -0
- package/dist/network/wire.d.ts.map +1 -1
- package/dist/network/wire.js +5 -0
- package/dist/network/wire.js.map +1 -1
- package/dist/persona/assembler.d.ts.map +1 -1
- package/dist/persona/assembler.js +7 -1
- package/dist/persona/assembler.js.map +1 -1
- package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
- package/dist/plugin/shell-hook-tool-names.js +1 -0
- package/dist/plugin/shell-hook-tool-names.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +8 -3
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +132 -7
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +4 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +3 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts.map +1 -1
- package/dist/provider/model-window-suffix.js +1 -0
- package/dist/provider/model-window-suffix.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +3 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +9 -6
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +11 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +7 -4
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +9 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +3 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +10 -1
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +12 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +43 -9
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +4 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +32 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +2 -2
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +2 -2
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/shell-line-escalation.d.ts +24 -0
- package/dist/runtime/query/shell-line-escalation.d.ts.map +1 -0
- package/dist/runtime/query/shell-line-escalation.js +38 -0
- package/dist/runtime/query/shell-line-escalation.js.map +1 -0
- package/dist/runtime/query/tooling.d.ts +7 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +2 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +11 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +3 -1
- package/dist/scheduler/local.js.map +1 -1
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +2 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/inline-shell-host.d.ts +103 -0
- package/dist/skills/inline-shell-host.d.ts.map +1 -0
- package/dist/skills/inline-shell-host.js +238 -0
- package/dist/skills/inline-shell-host.js.map +1 -0
- package/dist/skills/inline-shell.d.ts +176 -0
- package/dist/skills/inline-shell.d.ts.map +1 -0
- package/dist/skills/inline-shell.js +646 -0
- package/dist/skills/inline-shell.js.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/task/file.d.ts +124 -0
- package/dist/store/task/file.d.ts.map +1 -0
- package/dist/store/task/file.js +498 -0
- package/dist/store/task/file.js.map +1 -0
- package/dist/teams/backend.d.ts +28 -0
- package/dist/teams/backend.d.ts.map +1 -0
- package/dist/teams/backend.js +2 -0
- package/dist/teams/backend.js.map +1 -0
- package/dist/teams/fs-sync.d.ts +19 -0
- package/dist/teams/fs-sync.d.ts.map +1 -0
- package/dist/teams/fs-sync.js +81 -0
- package/dist/teams/fs-sync.js.map +1 -0
- package/dist/teams/index.d.ts +14 -0
- package/dist/teams/index.d.ts.map +1 -0
- package/dist/teams/index.js +11 -0
- package/dist/teams/index.js.map +1 -0
- package/dist/teams/names.d.ts +15 -0
- package/dist/teams/names.d.ts.map +1 -0
- package/dist/teams/names.js +43 -0
- package/dist/teams/names.js.map +1 -0
- package/dist/teams/store.d.ts +133 -0
- package/dist/teams/store.d.ts.map +1 -0
- package/dist/teams/store.js +536 -0
- package/dist/teams/store.js.map +1 -0
- package/dist/teams/types.d.ts +97 -0
- package/dist/teams/types.d.ts.map +1 -0
- package/dist/teams/types.js +70 -0
- package/dist/teams/types.js.map +1 -0
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +9 -1
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts +19 -3
- package/dist/tools/builtins/atomic-write-file.d.ts.map +1 -1
- package/dist/tools/builtins/atomic-write-file.js +56 -3
- package/dist/tools/builtins/atomic-write-file.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +56 -2
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +604 -90
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +1 -1
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts +31 -0
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +232 -88
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +11 -2
- package/dist/tools/task/create.js.map +1 -1
- package/dist/tools/task/get.d.ts +8 -0
- package/dist/tools/task/get.d.ts.map +1 -0
- package/dist/tools/task/get.js +51 -0
- package/dist/tools/task/get.js.map +1 -0
- package/dist/tools/task/index.d.ts +7 -0
- package/dist/tools/task/index.d.ts.map +1 -1
- package/dist/tools/task/index.js +10 -2
- package/dist/tools/task/index.js.map +1 -1
- package/dist/tools/task/list.d.ts.map +1 -1
- package/dist/tools/task/list.js +10 -2
- package/dist/tools/task/list.js.map +1 -1
- package/dist/tools/task/number.d.ts +13 -0
- package/dist/tools/task/number.d.ts.map +1 -0
- package/dist/tools/task/number.js +30 -0
- package/dist/tools/task/number.js.map +1 -0
- package/dist/tools/task/present.d.ts.map +1 -1
- package/dist/tools/task/present.js +17 -3
- package/dist/tools/task/present.js.map +1 -1
- package/dist/tools/task/update.d.ts +2 -1
- package/dist/tools/task/update.d.ts.map +1 -1
- package/dist/tools/task/update.js +86 -19
- package/dist/tools/task/update.js.map +1 -1
- package/dist/types/acp/index.d.ts +10 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +4 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +9 -0
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +7 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +10 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/permission/index.d.ts +20 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +25 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +47 -3
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +4 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/interface.d.ts +6 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/skills/index.d.ts +7 -0
- package/dist/types/skills/index.d.ts.map +1 -1
- package/dist/types/skills/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +28 -2
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +4 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +2 -0
- package/src/authorization/skill-grant.ts +1 -0
- package/src/bridge/acp/permission.ts +11 -1
- package/src/bridge/acp/server.ts +1 -0
- package/src/connector/index.ts +27 -0
- package/src/connector/mcp/client.ts +71 -2
- package/src/connector/mcp/errors.ts +14 -0
- package/src/connector/mcp/index.ts +36 -0
- package/src/connector/mcp/skill-source.ts +499 -0
- package/src/connector/mcp/skills.ts +367 -0
- package/src/network/audit.ts +2 -0
- package/src/network/computer.ts +347 -0
- package/src/network/index.ts +20 -0
- package/src/network/join.ts +4 -2
- package/src/network/roster.ts +5 -0
- package/src/network/service.ts +492 -75
- package/src/network/store.ts +29 -3
- package/src/network/wire.ts +5 -0
- package/src/persona/assembler.ts +7 -1
- package/src/plugin/shell-hook-tool-names.ts +1 -0
- package/src/plugin/shell-hook.ts +144 -7
- package/src/provider/fallback.ts +4 -0
- package/src/provider/idle-timeout.ts +3 -0
- package/src/provider/model-window-suffix.ts +1 -0
- package/src/provider/retry.ts +3 -0
- package/src/public-runtime.ts +99 -0
- package/src/public-tools.ts +15 -0
- package/src/public-types.ts +28 -0
- package/src/runtime/query/executor/tool-call-admission.ts +10 -1
- package/src/runtime/query/executor.ts +57 -8
- package/src/runtime/query/index.ts +43 -0
- package/src/runtime/query/review-policy.ts +7 -1
- package/src/runtime/query/shell-line-escalation.ts +49 -0
- package/src/runtime/query/tooling.ts +6 -0
- package/src/runtime/query/turn/outcome-ledger.ts +11 -0
- package/src/scheduler/local.ts +3 -1
- package/src/skills/index.ts +43 -0
- package/src/skills/inline-shell-host.ts +303 -0
- package/src/skills/inline-shell.ts +765 -0
- package/src/store/index.ts +8 -0
- package/src/store/task/file.ts +641 -0
- package/src/teams/backend.ts +29 -0
- package/src/teams/fs-sync.ts +91 -0
- package/src/teams/index.ts +47 -0
- package/src/teams/names.ts +49 -0
- package/src/teams/store.ts +607 -0
- package/src/teams/types.ts +102 -0
- package/src/tools/admit-facts.ts +9 -1
- package/src/tools/builtins/atomic-write-file.ts +73 -5
- package/src/tools/builtins/computer-use.ts +689 -95
- package/src/tools/builtins/index.ts +1 -0
- package/src/tools/builtins/skill.ts +291 -95
- package/src/tools/task/create.ts +11 -2
- package/src/tools/task/get.ts +53 -0
- package/src/tools/task/index.ts +14 -2
- package/src/tools/task/list.ts +10 -2
- package/src/tools/task/number.ts +32 -0
- package/src/tools/task/present.ts +18 -3
- package/src/tools/task/update.ts +93 -19
- package/src/types/acp/index.ts +11 -1
- package/src/types/agent/base.ts +6 -0
- package/src/types/agent/scheduler.ts +9 -0
- package/src/types/computer-use/index.ts +7 -0
- package/src/types/connector/mcp.ts +10 -0
- package/src/types/permission/index.ts +29 -0
- package/src/types/plugin/index.ts +95 -39
- package/src/types/provider/interface.ts +7 -0
- package/src/types/skills/index.ts +8 -0
- package/src/types/tool/index.ts +23 -2
- package/src/types/tool/presentation.ts +2 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { randomInt } from 'node:crypto';
|
|
2
|
+
import { renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { temporaryPathFor } from '../utils/atomic-write.js';
|
|
4
|
+
import { FileLockError, lockPathFor, withFileLockSync } from '../utils/file-lock.js';
|
|
5
|
+
import { TeamStoreError } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* How a team's files are changed by more than one process: a lock file beside the record, bounded
|
|
8
|
+
* retries with a short random wait, and a write that publishes by rename so a reader sees the old file
|
|
9
|
+
* or the new one and never half of one. The retry count is a bound on patience, not a measure of time:
|
|
10
|
+
* a lock whose owner has exited is taken over at once, so waiting is only for an owner that is alive.
|
|
11
|
+
*/
|
|
12
|
+
/** Tries before a held lock is reported as busy. */
|
|
13
|
+
export const LOCK_ATTEMPTS = 100;
|
|
14
|
+
const WAIT_MIN_MS = 5;
|
|
15
|
+
const WAIT_MAX_MS = 100;
|
|
16
|
+
export function sleepSync(ms) {
|
|
17
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
18
|
+
}
|
|
19
|
+
/** One jittered wait, for callers that sleep without blocking. */
|
|
20
|
+
export function jitterDelay() {
|
|
21
|
+
return randomInt(WAIT_MIN_MS, WAIT_MAX_MS + 1);
|
|
22
|
+
}
|
|
23
|
+
export function jitterWait(sleep) {
|
|
24
|
+
return () => sleep(randomInt(WAIT_MIN_MS, WAIT_MAX_MS + 1));
|
|
25
|
+
}
|
|
26
|
+
/** Run `operation` holding the lock beside `file`; a lock held past the retry bound is a `busy` error. */
|
|
27
|
+
export function lockedSync(file, sleep, operation) {
|
|
28
|
+
try {
|
|
29
|
+
return withFileLockSync(lockPathFor(file), operation, {
|
|
30
|
+
attempts: LOCK_ATTEMPTS,
|
|
31
|
+
wait: jitterWait(sleep),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof FileLockError)
|
|
36
|
+
throw new TeamStoreError('busy', `${file} is in use by another process and did not free up; try again.`);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const CONTENDED = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
41
|
+
/** Tries on transient rename or remove contention (a reader holding the file open on Windows). */
|
|
42
|
+
const CONTENTION_ATTEMPTS = 20;
|
|
43
|
+
/** Remove a file (absent is fine), retrying transient contention like {@link writeAtomicSync}. */
|
|
44
|
+
export function removeSync(path, sleep = sleepSync) {
|
|
45
|
+
for (let attempt = 1;; attempt++) {
|
|
46
|
+
try {
|
|
47
|
+
rmSync(path, { force: true });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const code = error.code ?? '';
|
|
52
|
+
if (!CONTENDED.has(code) || attempt >= CONTENTION_ATTEMPTS)
|
|
53
|
+
throw error;
|
|
54
|
+
sleep(randomInt(5, 51));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Publish `content` at `path` by rename, private to the user. Transient Windows contention is retried with a jittered wait. */
|
|
59
|
+
export function writeAtomicSync(path, content, sleep = sleepSync) {
|
|
60
|
+
const temp = temporaryPathFor(path);
|
|
61
|
+
try {
|
|
62
|
+
writeFileSync(temp, content, { encoding: 'utf8', mode: 0o600 });
|
|
63
|
+
for (let attempt = 1;; attempt++) {
|
|
64
|
+
try {
|
|
65
|
+
renameSync(temp, path);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const code = error.code ?? '';
|
|
70
|
+
if (!CONTENDED.has(code) || attempt >= CONTENTION_ATTEMPTS)
|
|
71
|
+
throw error;
|
|
72
|
+
sleep(randomInt(5, 51));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
rmSync(temp, { force: true });
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fs-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-sync.js","sourceRoot":"","sources":["../../src/teams/fs-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;GAKG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA;AAChC,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,MAAM,UAAU,SAAS,CAAC,EAAU;IACnC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;AACjE,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,WAAW;IAC1B,OAAO,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAA2B;IACrD,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,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,eAAe,CAC9B,IAAY,EACZ,OAAe,EACf,QAA8B,SAAS;IAEvC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC;QACJ,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QAC/D,KAAK,IAAI,OAAO,GAAG,CAAC,GAAI,OAAO,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC;gBACJ,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;gBACtB,OAAM;YACP,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,IAAI,EAAE,CAAA;gBACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,mBAAmB;oBAAE,MAAM,KAAK,CAAA;gBACvE,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;YACxB,CAAC;QACF,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAC7B,MAAM,KAAK,CAAA;IACZ,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teams: named helpers that work beside the main conversation, with a membership file, a mailbox each
|
|
3
|
+
* and (elsewhere) a shared task list. This module is the storage and naming layer plus the seam a
|
|
4
|
+
* teammate runner plugs into; running a teammate is host territory.
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export { normalizeTeamName, TEAM_LEAD_NAME, teammateNameProblem, teamNameProblem, } from './names.js';
|
|
9
|
+
export { MAX_MAIL_ENTRIES, MAX_MAIL_TEXT_BYTES, TEAM_COLORS, TEAM_CREATE_GRACE_MS, TeamStore, } from './store.js';
|
|
10
|
+
export type { CreateTeamInput, MailReadOptions, ReserveMemberInput, TeamStoreOptions, } from './store.js';
|
|
11
|
+
export { MAIL_KINDS, MailEntrySchema, MailKindSchema, TEAM_CONFIG_VERSION, TeamBackendKindSchema, TeamConfigSchema, TeamMemberSchema, TeamStoreError, } from './types.js';
|
|
12
|
+
export type { MailDraft, MailEntry, MailKind, TeamBackendKind, TeamConfig, TeamMember, TeamStoreErrorCode, } from './types.js';
|
|
13
|
+
export type { TeammateBackend, TeammateStartSpec } from './backend.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/teams/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,eAAe,GACf,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,SAAS,GACT,MAAM,YAAY,CAAA;AACnB,YAAY,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,GAChB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,UAAU,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACd,MAAM,YAAY,CAAA;AACnB,YAAY,EACX,SAAS,EACT,SAAS,EACT,QAAQ,EACR,eAAe,EACf,UAAU,EACV,UAAU,EACV,kBAAkB,GAClB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Teams: named helpers that work beside the main conversation, with a membership file, a mailbox each
|
|
3
|
+
* and (elsewhere) a shared task list. This module is the storage and naming layer plus the seam a
|
|
4
|
+
* teammate runner plugs into; running a teammate is host territory.
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export { normalizeTeamName, TEAM_LEAD_NAME, teammateNameProblem, teamNameProblem, } from './names.js';
|
|
9
|
+
export { MAX_MAIL_ENTRIES, MAX_MAIL_TEXT_BYTES, TEAM_COLORS, TEAM_CREATE_GRACE_MS, TeamStore, } from './store.js';
|
|
10
|
+
export { MAIL_KINDS, MailEntrySchema, MailKindSchema, TEAM_CONFIG_VERSION, TeamBackendKindSchema, TeamConfigSchema, TeamMemberSchema, TeamStoreError, } from './types.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/teams/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,eAAe,GACf,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,SAAS,GACT,MAAM,YAAY,CAAA;AAOnB,OAAO,EACN,UAAU,EACV,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,GACd,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of teams and their members. A member's name is how the others address it (`send_message`
|
|
3
|
+
* `to`), and it is also a file name under the team's directory, so the rules are strict.
|
|
4
|
+
*
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
/** The name every member and the lead is addressed by when the recipient is the main conversation. */
|
|
8
|
+
export declare const TEAM_LEAD_NAME = "lead";
|
|
9
|
+
/** How two spellings of a name are told apart: width-folded, trimmed, lower-case, spaces as hyphens. */
|
|
10
|
+
export declare function normalizeTeamName(raw: string): string;
|
|
11
|
+
/** Why a member name cannot be used, in words for the model; undefined when it can. */
|
|
12
|
+
export declare function teammateNameProblem(raw: string): string | undefined;
|
|
13
|
+
/** Why a team name cannot be used as a directory name; undefined when it can. */
|
|
14
|
+
export declare function teamNameProblem(raw: string): string | undefined;
|
|
15
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../src/teams/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,sGAAsG;AACtG,eAAO,MAAM,cAAc,SAAS,CAAA;AAEpC,wGAAwG;AACxG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED,uFAAuF;AACvF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQnE;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI/D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of teams and their members. A member's name is how the others address it (`send_message`
|
|
3
|
+
* `to`), and it is also a file name under the team's directory, so the rules are strict.
|
|
4
|
+
*
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
/** Letters, digits, underscore and hyphen; starts with a letter or digit; at most 64. */
|
|
8
|
+
const NAME_SHAPE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
9
|
+
/** Names that already address something else. `lead` is the conversation the person talks to. */
|
|
10
|
+
const RESERVED = new Set(['lead', 'main', 'team-lead', 'user', 'system']);
|
|
11
|
+
/** What an id looks like: a task UUID, or a workflow run id. Those address an agent or run directly. */
|
|
12
|
+
const ID_SHAPES = [
|
|
13
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
14
|
+
/^w[0-9a-z]{8}$/,
|
|
15
|
+
];
|
|
16
|
+
/** The name every member and the lead is addressed by when the recipient is the main conversation. */
|
|
17
|
+
export const TEAM_LEAD_NAME = 'lead';
|
|
18
|
+
/** How two spellings of a name are told apart: width-folded, trimmed, lower-case, spaces as hyphens. */
|
|
19
|
+
export function normalizeTeamName(raw) {
|
|
20
|
+
return raw
|
|
21
|
+
.normalize('NFKC')
|
|
22
|
+
.replace(/[\p{Cc}\p{Cf}\p{Cs}]/gu, (c) => (/\s/.test(c) ? c : ''))
|
|
23
|
+
.trim()
|
|
24
|
+
.toLowerCase()
|
|
25
|
+
.replace(/\s+/g, '-');
|
|
26
|
+
}
|
|
27
|
+
/** Why a member name cannot be used, in words for the model; undefined when it can. */
|
|
28
|
+
export function teammateNameProblem(raw) {
|
|
29
|
+
if (!NAME_SHAPE.test(raw))
|
|
30
|
+
return 'name must start with a letter or digit and contain only letters, digits, underscores or hyphens (at most 64 characters).';
|
|
31
|
+
if (RESERVED.has(normalizeTeamName(raw)))
|
|
32
|
+
return `"${raw}" is reserved. Pick another name; "lead" is how a teammate reaches the main conversation.`;
|
|
33
|
+
if (ID_SHAPES.some((shape) => shape.test(raw)))
|
|
34
|
+
return 'name must not look like a task or run id, which already address an agent directly.';
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
/** Why a team name cannot be used as a directory name; undefined when it can. */
|
|
38
|
+
export function teamNameProblem(raw) {
|
|
39
|
+
if (!NAME_SHAPE.test(raw))
|
|
40
|
+
return 'team name must start with a letter or digit and contain only letters, digits, underscores or hyphens (at most 64 characters).';
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../src/teams/names.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yFAAyF;AACzF,MAAM,UAAU,GAAG,kCAAkC,CAAA;AAEr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0,0 +1,133 @@
|
|
|
1
|
+
import { type MailDraft, type MailEntry, type TeamBackendKind, type TeamConfig, type TeamMember } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The teams on this machine, under `<NAMZU_HOME>/teams/<team>/`:
|
|
4
|
+
*
|
|
5
|
+
* - `config.json`: the team and its members, changed only through this class, under a lock and by
|
|
6
|
+
* rename, so two processes naming a member at once cannot both succeed.
|
|
7
|
+
* - `inboxes/<name>.json`: one mailbox per member and one for `lead` (the name is folded to lower case,
|
|
8
|
+
* so two spellings of a name never share or split a file). A JSON array of mail entries.
|
|
9
|
+
*
|
|
10
|
+
* `active` on a member means it holds a place in the team: it is set when the name is reserved and
|
|
11
|
+
* cleared when the teammate ends, so the size limit counts what is running or about to.
|
|
12
|
+
*
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
/** Colours handed out in order, so members are told apart on a screen. */
|
|
16
|
+
export declare const TEAM_COLORS: readonly ["blue", "green", "purple", "orange", "pink", "cyan", "yellow", "red"];
|
|
17
|
+
/** One piece of mail may carry this much text. */
|
|
18
|
+
export declare const MAX_MAIL_TEXT_BYTES: number;
|
|
19
|
+
/** A mailbox keeps this many entries; the oldest read ones go first. */
|
|
20
|
+
export declare const MAX_MAIL_ENTRIES = 500;
|
|
21
|
+
/** A team directory with no readable config is left alone this long, so one being created is not swept. */
|
|
22
|
+
export declare const TEAM_CREATE_GRACE_MS = 60000;
|
|
23
|
+
export interface TeamStoreOptions {
|
|
24
|
+
/** The directory teams live in. Default `<NAMZU_HOME>/teams`. */
|
|
25
|
+
readonly rootDir?: string;
|
|
26
|
+
/** Environment and OS home for resolving `NAMZU_HOME`; tests only. */
|
|
27
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
28
|
+
readonly home?: string;
|
|
29
|
+
/** Tests only: replace the wall clock, the wait between lock retries and the liveness check. */
|
|
30
|
+
readonly now?: () => number;
|
|
31
|
+
readonly sleep?: (ms: number) => void;
|
|
32
|
+
readonly isProcessAlive?: (pid: number) => boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface CreateTeamInput {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly leadSessionId: string;
|
|
37
|
+
readonly leadPid?: number;
|
|
38
|
+
readonly project?: string;
|
|
39
|
+
readonly cwd?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ReserveMemberInput {
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly backend?: TeamBackendKind;
|
|
44
|
+
readonly agentType?: string;
|
|
45
|
+
readonly color?: string;
|
|
46
|
+
/** Refuse with `team_full` when this many members already hold a place. */
|
|
47
|
+
readonly maxMembers?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface MailReadOptions {
|
|
50
|
+
readonly unreadOnly?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export declare class TeamStore {
|
|
53
|
+
readonly rootDir: string;
|
|
54
|
+
private readonly now;
|
|
55
|
+
private readonly sleep;
|
|
56
|
+
private readonly alive;
|
|
57
|
+
constructor(options?: TeamStoreOptions);
|
|
58
|
+
teamDir(team: string): string;
|
|
59
|
+
configPath(team: string): string;
|
|
60
|
+
inboxPath(team: string, name: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Create a team. Asking again with the same lead session returns the team that is there (a resumed
|
|
63
|
+
* lead); a different lead session is `team_exists`.
|
|
64
|
+
*/
|
|
65
|
+
createTeam(input: CreateTeamInput): TeamConfig;
|
|
66
|
+
/** The team's config, or undefined when there is no such team or its file is unreadable. */
|
|
67
|
+
readTeam(team: string): TeamConfig | undefined;
|
|
68
|
+
listTeams(): string[];
|
|
69
|
+
/** Remove a team's directory. Returns false when there was none. Tasks and transcripts live elsewhere. */
|
|
70
|
+
deleteTeam(team: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Remove the directories of teams whose lead is gone: the lead's process no longer exists, or the
|
|
73
|
+
* directory has no readable config and was last changed more than `graceMs` ago. A team that records
|
|
74
|
+
* no lead process is never removed here. Returns the names removed.
|
|
75
|
+
*/
|
|
76
|
+
sweepOrphans(options?: {
|
|
77
|
+
readonly graceMs?: number;
|
|
78
|
+
}): string[];
|
|
79
|
+
/**
|
|
80
|
+
* Take a name in the team's file. Two callers asking for one name at once: exactly one gets it, the
|
|
81
|
+
* other gets `name_taken`. The member holds a place from now on; hand it back with
|
|
82
|
+
* {@link rollbackMember} if starting it fails, or let {@link withReservedMember} do both.
|
|
83
|
+
*/
|
|
84
|
+
reserveMember(team: string, input: ReserveMemberInput): TeamMember;
|
|
85
|
+
/**
|
|
86
|
+
* Give back a reservation that never started. Removes exactly the member with this id, so a later
|
|
87
|
+
* member that took the same name is never touched. False when it is already gone, or the team is.
|
|
88
|
+
*/
|
|
89
|
+
rollbackMember(team: string, memberId: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Reserve a name, run `start`, and give the name back if `start` throws: a teammate is either
|
|
92
|
+
* running under its name or the name is free again.
|
|
93
|
+
*/
|
|
94
|
+
withReservedMember<T>(team: string, input: ReserveMemberInput, start: (member: TeamMember) => Promise<T>): Promise<{
|
|
95
|
+
readonly member: TeamMember;
|
|
96
|
+
readonly result: T;
|
|
97
|
+
}>;
|
|
98
|
+
/** Mark a member as holding a place (resumed) or not (ended). Resuming is refused over `maxMembers`. */
|
|
99
|
+
setMemberActive(team: string, name: string, active: boolean, maxMembers?: number): TeamMember;
|
|
100
|
+
/** Remove a member and its mailbox. False when there is no such member. */
|
|
101
|
+
removeMember(team: string, name: string): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Add one piece of mail to a member's mailbox (or the lead's). The file is made if it is not there
|
|
104
|
+
* (create-exclusive), then read, added to and replaced by rename under a lock, so appends from many
|
|
105
|
+
* processes are all kept. Refused for a team that is gone, a recipient that is not in it, and text
|
|
106
|
+
* over {@link MAX_MAIL_TEXT_BYTES}.
|
|
107
|
+
*/
|
|
108
|
+
appendMail(team: string, to: string, draft: MailDraft): MailEntry;
|
|
109
|
+
/** The valid entries in a mailbox, oldest first. An entry that does not match the schema is left out. */
|
|
110
|
+
readMail(team: string, name: string, options?: MailReadOptions): MailEntry[];
|
|
111
|
+
/** Take the unread mail and mark it read, in one step: no entry is handed out twice. */
|
|
112
|
+
drainMail(team: string, name: string): MailEntry[];
|
|
113
|
+
markRead(team: string, name: string, ids: readonly string[]): void;
|
|
114
|
+
/**
|
|
115
|
+
* Rewrite a mailbox without its invalid entries and with at most `keepRead` read ones (the newest).
|
|
116
|
+
* Unread mail is always kept. Returns how many entries were dropped.
|
|
117
|
+
*/
|
|
118
|
+
pruneMail(team: string, name: string, options?: {
|
|
119
|
+
readonly keepRead?: number;
|
|
120
|
+
}): number;
|
|
121
|
+
private nextColor;
|
|
122
|
+
private writeConfig;
|
|
123
|
+
/** Remove a team directory this call may have recreated while taking a lock on a team that is gone. */
|
|
124
|
+
private dropRecreated;
|
|
125
|
+
/** Change the config under its lock. Refused with `team_not_found` when the team has been removed. */
|
|
126
|
+
private mutate;
|
|
127
|
+
private requireRecipient;
|
|
128
|
+
private ensureInbox;
|
|
129
|
+
private readInbox;
|
|
130
|
+
/** Read, change and replace a mailbox under its lock. Invalid entries are dropped on the way, and the size is bounded. */
|
|
131
|
+
private changeInbox;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/teams/store.ts"],"names":[],"mappings":"AAkBA,OAAO,EACN,KAAK,SAAS,EACd,KAAK,SAAS,EAGd,KAAK,eAAe,EACpB,KAAK,UAAU,EAEf,KAAK,UAAU,EAEf,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;GAYG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,WAAW,iFASd,CAAA;AAEV,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,QAAY,CAAA;AAC5C,wEAAwE;AACxE,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,2GAA2G;AAC3G,eAAO,MAAM,oBAAoB,QAAS,CA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