@tnunamak/dalan 0.8.1 → 0.8.3
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 +61 -2
- package/CONTRIBUTING.md +2 -0
- package/README.md +8 -12
- package/bin/dalan.mjs +25 -4
- package/bin/dot-acp-agent.mjs +572 -76
- package/bin/dot-alert.mjs +9 -3
- package/bin/dot-deadman.mjs +3 -1
- package/bin/dot-heartbeat.mjs +14 -7
- package/bin/dot-pr-reviewer.mjs +3 -31
- package/bin/dot-worker.mjs +121 -34
- package/contracts/adapter-qualification.schema.json +94 -7
- package/docs/chatgpt-worker-onboarding.md +1 -1
- package/docs/codex-to-muse.md +2 -2
- package/docs/connect-chatgpt.md +1 -1
- package/docs/connection-longevity.md +2 -2
- package/docs/dalan-upgrade.md +8 -5
- package/docs/deadman.md +4 -0
- package/docs/design/authority-matrix.md +18 -0
- package/docs/design/failure-table.md +87 -0
- package/docs/design/identities.md +22 -0
- package/docs/design/pnpm-prepared-dependencies.md +64 -0
- package/docs/design/reuse-ledger.md +75 -0
- package/docs/design/target-architecture-v2.md +434 -0
- package/docs/local-agent-mcp.md +14 -0
- package/docs/local-agent-requester.md +2 -1
- package/docs/manual-setup.md +1 -1
- package/docs/operations.md +77 -14
- package/docs/pull-workers.md +11 -1
- package/docs/service-setup.md +10 -10
- package/docs/t3-integration.md +4 -2
- package/docs/t3-reverse-control.md +5 -5
- package/docs/test-suite-isolation.md +7 -6
- package/docs/trials/chatgpt-agent.md +47 -0
- package/docs/trials/claude-code-requester.md +68 -0
- package/docs/trials/muse.md +46 -0
- package/docs/usage.md +21 -7
- package/docs/worker-clients.md +1 -1
- package/integrations/t3/acp-kit/src/errors.mjs +6 -2
- package/integrations/t3/acp-kit/src/lock.mjs +46 -17
- package/integrations/t3/acp-kit/src/session-store.mjs +15 -3
- package/integrations/t3/acp-kit/src/t3-envelope.mjs +10 -2
- package/package.json +4 -3
- package/packages/job-core/protocol/canonical.mjs +45 -7
- package/packages/job-core/transitions.mjs +4 -2
- package/scripts/upgrade-drain.mjs +96 -8
- package/scripts/worker-bridge-setup.mjs +215 -120
- package/src/ack-ledger.mjs +7 -1
- package/src/acp-bridge.mjs +256 -28
- package/src/admin-socket.mjs +32 -3
- package/src/alerts.mjs +17 -8
- package/src/answer-journal-retention.mjs +82 -0
- package/src/answer-journal.mjs +6 -4
- package/src/as-store.mjs +51 -6
- package/src/as.mjs +27 -5
- package/src/catalog-switch-inventory.mjs +70 -0
- package/src/check-response.mjs +4 -1
- package/src/cli-help.mjs +14 -3
- package/src/cli-name.mjs +13 -1
- package/src/connect-cli.mjs +159 -4
- package/src/deadman.mjs +8 -5
- package/src/delivery.mjs +2 -19
- package/src/destinations/index.mjs +75 -14
- package/src/drain-runner.mjs +5 -1
- package/src/follow-current.mjs +3 -1
- package/src/get-summary.mjs +11 -2
- package/src/git-env.mjs +1 -1
- package/src/gozar-routes.mjs +313 -94
- package/src/host-budget-storage.py +56 -6
- package/src/host-budget.mjs +98 -15
- package/src/host-execution-policy.mjs +17 -6
- package/src/legacy-names.mjs +0 -2
- package/src/lifecycle.mjs +44 -9
- package/src/loopback-probe.mjs +46 -0
- package/src/mcp-outcome.mjs +3 -1
- package/src/mcp-sse.mjs +2 -1
- package/src/mcp-stdio.mjs +192 -30
- package/src/patch-apply.mjs +212 -7
- package/src/phase-trace.mjs +73 -0
- package/src/prepared-go-modules.mjs +127 -0
- package/src/prepared-node-modules.mjs +225 -38
- package/src/prepared-pnpm.mjs +276 -0
- package/src/prepared-store-prune.mjs +52 -0
- package/src/projects.mjs +59 -7
- package/src/protocol-artifact-commands.mjs +28 -0
- package/src/protocol-finish.mjs +3 -2
- package/src/publication-authority.mjs +22 -0
- package/src/publish-plan.mjs +2 -2
- package/src/pull-queue.mjs +55 -20
- package/src/read-api.mjs +127 -0
- package/src/redaction.mjs +173 -0
- package/src/rejections.mjs +19 -3
- package/src/route-custody.mjs +90 -0
- package/src/route-publication.mjs +50 -0
- package/src/route-setup.mjs +184 -0
- package/src/schema-subset.mjs +5 -3
- package/src/server.mjs +503 -98
- package/src/service-launchd.mjs +5 -1
- package/src/service-update-lock.mjs +7 -4
- package/src/service-update-runtime.mjs +136 -21
- package/src/service-update.mjs +207 -51
- package/src/service.mjs +276 -77
- package/src/setup.mjs +48 -25
- package/src/signal.mjs +1 -1
- package/src/status-evidence.mjs +18 -5
- package/src/store.mjs +876 -120
- package/src/submission-policy.mjs +257 -56
- package/src/t3-control.mjs +1 -1
- package/src/t3.mjs +14 -8
- package/src/terminal-safe.mjs +9 -7
- package/src/tool-registry.mjs +134 -41
- package/src/try-exposure.mjs +53 -86
- package/src/try-hosted.mjs +257 -70
- package/src/try.mjs +48 -22
- package/src/work-order.mjs +11 -6
- package/src/worker-instructions.mjs +26 -4
- package/src/worker-runs.mjs +35 -0
- package/src/workers.mjs +34 -7
- package/src/workspace.mjs +354 -54
- package/systemd/dot-deadman.service +3 -1
- package/docs/dot-pr-reviewer.config.example.json +0 -9
- package/docs/pr-head-reviewer.md +0 -70
- package/src/pr-head-reviewer.mjs +0 -596
- package/systemd/dot-pr-reviewer.service +0 -11
- package/systemd/dot-pr-reviewer.timer +0 -10
package/src/delivery.mjs
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
// T3 uses UUIDs, `mcp:<uuid>`, and opaque delegated/provider IDs. Keep this
|
|
5
|
-
// deliberately bounded while accepting the characters present in those forms.
|
|
6
|
-
export function validT3ThreadId(value) {
|
|
7
|
-
return typeof value === 'string'
|
|
8
|
-
&& value.length >= 8
|
|
9
|
-
&& value.length <= maxT3ThreadIdLength
|
|
10
|
-
&& t3ThreadIdPattern.test(value);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function parseDelivery(value) {
|
|
14
|
-
if (value === 'none') return { mode: 'none', threadId: null };
|
|
15
|
-
if (typeof value === 'string' && value.startsWith('t3:') && validT3ThreadId(value.slice(3))) {
|
|
16
|
-
return { mode: 't3', threadId: value.slice(3) };
|
|
17
|
-
}
|
|
18
|
-
throw new Error('invalid delivery; expected none or t3:<thread-id>');
|
|
19
|
-
}
|
|
1
|
+
// The destination registry owns adapter-specific admission and routing; retain the existing API.
|
|
2
|
+
export { maxT3ThreadIdLength, parseDelivery, validT3ThreadId } from './destinations/index.mjs';
|
|
@@ -1,17 +1,75 @@
|
|
|
1
1
|
import { createNoneDestination } from './none.mjs';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const t3ThreadIdPattern = /^[A-Za-z0-9._:%-]+$/;
|
|
4
|
+
export const maxT3ThreadIdLength = 1024;
|
|
5
|
+
|
|
6
|
+
// T3 uses UUIDs, `mcp:<uuid>`, and opaque delegated/provider IDs. Keep this
|
|
7
|
+
// deliberately bounded while accepting the characters present in those forms.
|
|
8
|
+
export function validT3ThreadId(value) {
|
|
9
|
+
return typeof value === 'string'
|
|
10
|
+
&& value.length >= 8
|
|
11
|
+
&& value.length <= maxT3ThreadIdLength
|
|
12
|
+
&& t3ThreadIdPattern.test(value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const destinations=new Map();
|
|
16
|
+
const split=value=>{
|
|
17
|
+
const colon=value.indexOf(':');
|
|
18
|
+
return colon<0?[value,undefined]:[value.slice(0,colon),value.slice(colon+1)];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function registerDestination(name,{parse,load,version='1',...builtIn}={}) {
|
|
22
|
+
if(typeof name!=='string'||!/^[a-z][a-z0-9-]*$/.test(name)||typeof parse!=='function'||typeof load!=='function'||typeof version!=='string'||!/^\S{1,64}$/.test(version))
|
|
23
|
+
throw new TypeError('invalid destination registration');
|
|
24
|
+
if(destinations.has(name)) throw new Error(`destination already registered: ${name}`);
|
|
25
|
+
destinations.set(name,{parse,load,version,...builtIn});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const destinationVersion=name=>destinations.get(name)?.version;
|
|
29
|
+
|
|
30
|
+
registerDestination('none',{
|
|
31
|
+
version:'1',form:'none', bare:true,
|
|
32
|
+
routes:(value,address)=>address===undefined,
|
|
33
|
+
parse:address=>address===undefined?{mode:'none',threadId:null}:null,
|
|
34
|
+
load:createNoneDestination,
|
|
35
|
+
});
|
|
36
|
+
registerDestination('t3',{
|
|
37
|
+
version:'1',
|
|
38
|
+
form:'t3:<thread-id>',
|
|
39
|
+
// Persisted rows predate strict admission parsing and can carry an opaque short ID.
|
|
40
|
+
routes:(value,address)=>typeof value==='string'?(address===undefined||/^.+$/.test(address)):validT3ThreadId(value?.threadId),
|
|
41
|
+
parse:address=>validT3ThreadId(address)?{mode:'t3',threadId:address}:null,
|
|
42
|
+
load:deps=>deps.loadT3?deps.loadT3():import('./t3.mjs').then(({createT3Destination})=>createT3Destination(deps)),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
function parseAddress(mode,adapter,address) {
|
|
46
|
+
if(!adapter.bare&&(typeof address!=='string'||!address)) return null;
|
|
47
|
+
try {
|
|
48
|
+
const parsed=adapter.parse(address);
|
|
49
|
+
return parsed?.mode===mode?parsed:null;
|
|
50
|
+
} catch { return null; } // Do not include opaque addresses in parser diagnostics.
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function parseDelivery(value) {
|
|
54
|
+
if(typeof value==='string') {
|
|
55
|
+
const [mode,address]=split(value), adapter=destinations.get(mode);
|
|
56
|
+
const parsed=adapter&&parseAddress(mode,adapter,address);
|
|
57
|
+
if(parsed) return parsed;
|
|
58
|
+
}
|
|
59
|
+
const forms=[...destinations].map(([name,adapter])=>adapter.form??`${name}:<address>`);
|
|
60
|
+
throw new Error(`invalid delivery; expected ${forms.join(' or ')}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
4
63
|
export const destinationName=delivery=>{
|
|
5
64
|
if(delivery===undefined) return 'none';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if(delivery?.mode==='t3'&&typeof delivery.threadId==='string') return 't3';
|
|
11
|
-
const error=new Error(`invalid delivery mode: ${String(delivery)}`);
|
|
65
|
+
const [mode,address]=typeof delivery==='string'?split(delivery):[delivery?.mode,undefined];
|
|
66
|
+
const adapter=destinations.get(mode);
|
|
67
|
+
if(adapter&&(adapter.routes?adapter.routes(delivery,address):parseAddress(mode,adapter,typeof delivery==='string'?address:delivery?.address))) return mode;
|
|
68
|
+
const error=new Error('invalid delivery mode');
|
|
12
69
|
error.code='INVALID_DELIVERY_MODE';
|
|
13
70
|
throw error;
|
|
14
71
|
};
|
|
72
|
+
|
|
15
73
|
// A destination is an adapter with this interface. Besides send and reconcile it has three methods for the parent it wakes:
|
|
16
74
|
// capture(delivery) -> string|null what to record at submit about the parent. One opaque string: the Store keeps
|
|
17
75
|
// it in assignments.parent_generation and never parses it.
|
|
@@ -19,11 +77,14 @@ export const destinationName=delivery=>{
|
|
|
19
77
|
// canAdmitContinuation(row) -> {ok,reason} whether the parent may be woken now. Best effort: a read, and the send follows.
|
|
20
78
|
// validate(delivery) returns {environmentId,generation}, where generation is what capture would return from the same read.
|
|
21
79
|
export function createDestinations(deps) {
|
|
22
|
-
const none=
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
80
|
+
const none=destinations.get('none').load(deps), loaded=new Map();
|
|
81
|
+
return {none,for:async delivery=>{
|
|
82
|
+
const name=destinationName(delivery);
|
|
83
|
+
if(name==='none') return none;
|
|
84
|
+
if(!loaded.has(name)) loaded.set(name,Promise.resolve().then(()=>destinations.get(name).load(deps)).catch(error=>{
|
|
85
|
+
loaded.delete(name);
|
|
86
|
+
throw error;
|
|
87
|
+
}));
|
|
88
|
+
return loaded.get(name);
|
|
89
|
+
}};
|
|
29
90
|
}
|
package/src/drain-runner.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export function createDrainRunner(drain,log) {
|
|
2
2
|
const report=error=>{
|
|
3
|
-
try {
|
|
3
|
+
try {
|
|
4
|
+
const result=log({kind:'delivery_drain_error',reason:String(error?.message??error).slice(0,300)});
|
|
5
|
+
// Logging must not create a second, unhandled failure.
|
|
6
|
+
Promise.resolve(result).catch(()=>{});
|
|
7
|
+
} catch {}
|
|
4
8
|
};
|
|
5
9
|
return function runDrain() {
|
|
6
10
|
try { return Promise.resolve(drain()).catch(error=>{ report(error); }); }
|
package/src/follow-current.mjs
CHANGED
|
@@ -11,7 +11,9 @@ const real = file => { try { return fs.realpathSync(file); } catch { return null
|
|
|
11
11
|
// command line after the script. An explicit --home names a home other than the default one, so this package runs it.
|
|
12
12
|
export function followTarget({ ownBin, env = process.env, argv = [] }) {
|
|
13
13
|
if (env.DALAN_NO_FOLLOW === '1' || env.DALAN_FOLLOWED === '1') return null;
|
|
14
|
-
|
|
14
|
+
const separator = argv.indexOf('--');
|
|
15
|
+
const options = separator === -1 ? argv : argv.slice(0, separator);
|
|
16
|
+
if (options.some(arg => arg === '--home' || arg.startsWith('--home='))) return null;
|
|
15
17
|
const home = env.DALAN_HOME ? path.resolve(env.DALAN_HOME) : readDefaultHome(env);
|
|
16
18
|
if (!home) return null;
|
|
17
19
|
const target = real(path.join(home, 'current', 'bin', 'dalan.mjs')), own = real(ownBin);
|
package/src/get-summary.mjs
CHANGED
|
@@ -5,6 +5,7 @@ export function formatGetSummary(job, { id, cli }) {
|
|
|
5
5
|
const state = job.status ?? 'unknown';
|
|
6
6
|
const report = job.report ?? null;
|
|
7
7
|
const lines = [`Job ${id}: ${state}`];
|
|
8
|
+
if (job.revised_by?.request_id) lines.push(`Correction: ${job.revised_by.request_id}`);
|
|
8
9
|
if (job.target_worker) lines.push(`Worker: ${job.target_worker}`);
|
|
9
10
|
if (report?.outcome && report.outcome !== 'done') lines.push(`Outcome: ${report.outcome}`);
|
|
10
11
|
if (report?.summary) lines.push(`Summary: ${report.summary}`);
|
|
@@ -15,14 +16,22 @@ export function formatGetSummary(job, { id, cli }) {
|
|
|
15
16
|
const count = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
16
17
|
const artifacts = (job.artifacts?.length ?? 0) || (job.artifact_ids?.length ?? 0), checks = job.checks?.length ?? 0;
|
|
17
18
|
if (artifacts || checks) lines.push('', `Evidence: ${[artifacts && count(artifacts, 'artifact'), checks && count(checks, 'check')].filter(Boolean).join(', ')}`);
|
|
18
|
-
const next = state === 'finished' ? `${cli} decide ${id} accepted`
|
|
19
|
+
const next = correctionAction(job, cli) ?? (state === 'finished' ? `${cli} decide ${id} accepted`
|
|
19
20
|
: state === 'cancelled' ? null
|
|
20
|
-
: `${cli} wait ${id} --timeout 3600, then ${cli} get ${id}
|
|
21
|
+
: `${cli} wait ${id} --timeout 3600, then ${cli} get ${id}`);
|
|
21
22
|
if (next) lines.push('', `Next: ${next}`);
|
|
22
23
|
lines.push(`Full record: ${cli} get ${id} --json`);
|
|
23
24
|
return lines.join('\n');
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const correctionAction = (job, cli) => job?.revised_by?.request_id ? `${cli} get ${job.revised_by.request_id}` : null;
|
|
28
|
+
|
|
29
|
+
// Piped human output retains the full JSON record and adds only this stderr guidance.
|
|
30
|
+
export function formatGetEndNote(job, { id, cli, decideWords }) {
|
|
31
|
+
const correction = correctionAction(job, cli);
|
|
32
|
+
return correction ? `Next: ${correction}` : job?.status === 'finished' ? `decide: ${cli} decide ${id} ${decideWords}` : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
// `dalan wait` on a terminal: one line, in place of the JSON status document.
|
|
27
36
|
export function formatWaitLine(result, { id, cli, seconds }) {
|
|
28
37
|
const state = result?.status ?? 'unknown';
|
package/src/git-env.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
const kept=new Set(['GIT_ASKPASS','GIT_TERMINAL_PROMPT']);
|
|
10
10
|
export function gitEnv(base=process.env) {
|
|
11
11
|
const env=Object.fromEntries(Object.entries(base).filter(([key])=>!key.startsWith('GIT_')||kept.has(key)));
|
|
12
|
-
return {...env,GIT_CONFIG_NOSYSTEM:'1',GIT_CONFIG_GLOBAL:'/dev/null',GIT_ATTR_NOSYSTEM:'1',
|
|
12
|
+
return {...env,GIT_PAGER:'cat',GIT_EDITOR:'false',GIT_SEQUENCE_EDITOR:'false',GIT_CONFIG_NOSYSTEM:'1',GIT_CONFIG_GLOBAL:'/dev/null',GIT_ATTR_NOSYSTEM:'1',
|
|
13
13
|
GIT_CONFIG_COUNT:'4',GIT_CONFIG_KEY_0:'core.hooksPath',GIT_CONFIG_VALUE_0:'/dev/null',GIT_CONFIG_KEY_1:'core.fsmonitor',GIT_CONFIG_VALUE_1:'false',
|
|
14
14
|
GIT_CONFIG_KEY_2:'core.excludesFile',GIT_CONFIG_VALUE_2:'/dev/null',GIT_CONFIG_KEY_3:'core.attributesFile',GIT_CONFIG_VALUE_3:'/dev/null'};
|
|
15
15
|
}
|