@phyzess/pappra 0.0.0-stage → 0.1.0-beta.10
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/LICENSE +21 -0
- package/README.md +99 -2
- package/THIRD_PARTY_NOTICES.md +16 -0
- package/assets/integrations/skills/pappra/SKILL.md +71 -0
- package/assets/integrations/skills/pappra/references/hosts.md +40 -0
- package/assets/integrations/skills/pappra/references/lifecycle.md +41 -0
- package/assets/integrations/skills/pappra/references/operations.md +27 -0
- package/assets/manifest.json +4 -0
- package/dist/app/collaboration.d.ts +170 -0
- package/dist/app/collaboration.js +1643 -0
- package/dist/app/doctor.d.ts +9 -0
- package/dist/app/doctor.js +1030 -0
- package/dist/app/init.d.ts +171 -0
- package/dist/app/init.js +1442 -0
- package/dist/cli/commands/code.d.ts +16 -0
- package/dist/cli/commands/code.js +127 -0
- package/dist/cli/commands/collaboration.d.ts +13 -0
- package/dist/cli/commands/collaboration.js +186 -0
- package/dist/cli/commands/continuity.d.ts +29 -0
- package/dist/cli/commands/continuity.js +133 -0
- package/dist/cli/commands/docs.d.ts +12 -0
- package/dist/cli/commands/docs.js +234 -0
- package/dist/cli/commands/doctor.d.ts +14 -0
- package/dist/cli/commands/doctor.js +57 -0
- package/dist/cli/commands/host.d.ts +17 -0
- package/dist/cli/commands/host.js +199 -0
- package/dist/cli/commands/init.d.ts +59 -0
- package/dist/cli/commands/init.js +845 -0
- package/dist/cli/commands/runtime.d.ts +14 -0
- package/dist/cli/commands/runtime.js +263 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +10 -0
- package/dist/cli/output.d.ts +4 -0
- package/dist/cli/output.js +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.js +749 -0
- package/dist/code/budget.d.ts +14 -0
- package/dist/code/budget.js +39 -0
- package/dist/code/exec.d.ts +23 -0
- package/dist/code/exec.js +133 -0
- package/dist/code/identity.d.ts +13 -0
- package/dist/code/identity.js +214 -0
- package/dist/code/index.d.ts +6 -0
- package/dist/code/index.js +3 -0
- package/dist/code/providers/codegraph.d.ts +59 -0
- package/dist/code/providers/codegraph.js +567 -0
- package/dist/code/registration.d.ts +9 -0
- package/dist/code/registration.js +293 -0
- package/dist/code/service.d.ts +53 -0
- package/dist/code/service.js +633 -0
- package/dist/code/text.d.ts +3 -0
- package/dist/code/text.js +202 -0
- package/dist/collab/admission.d.ts +450 -0
- package/dist/collab/admission.js +797 -0
- package/dist/collab/canonical.d.ts +26 -0
- package/dist/collab/canonical.js +136 -0
- package/dist/collab/contracts.d.ts +73 -0
- package/dist/collab/contracts.js +76 -0
- package/dist/collab/envelope.d.ts +52 -0
- package/dist/collab/envelope.js +241 -0
- package/dist/collab/fingerprint.d.ts +7 -0
- package/dist/collab/fingerprint.js +58 -0
- package/dist/collab/handoff.d.ts +350 -0
- package/dist/collab/handoff.js +513 -0
- package/dist/collab/index.d.ts +9 -0
- package/dist/collab/index.js +8 -0
- package/dist/collab/lifecycle.d.ts +449 -0
- package/dist/collab/lifecycle.js +534 -0
- package/dist/collab/messages.d.ts +148 -0
- package/dist/collab/messages.js +583 -0
- package/dist/collab/notify.d.ts +47 -0
- package/dist/collab/notify.js +140 -0
- package/dist/collab/preflight.d.ts +31 -0
- package/dist/collab/preflight.js +271 -0
- package/dist/collab/resources.d.ts +119 -0
- package/dist/collab/resources.js +451 -0
- package/dist/collab/store.d.ts +143 -0
- package/dist/collab/store.js +606 -0
- package/dist/collab/types.d.ts +354 -0
- package/dist/collab/types.js +1 -0
- package/dist/collab/validation.d.ts +10 -0
- package/dist/collab/validation.js +303 -0
- package/dist/continuity/context.d.ts +24 -0
- package/dist/continuity/context.js +179 -0
- package/dist/continuity/index.d.ts +3 -0
- package/dist/continuity/index.js +1 -0
- package/dist/continuity/paths.d.ts +37 -0
- package/dist/continuity/paths.js +258 -0
- package/dist/continuity/service.d.ts +59 -0
- package/dist/continuity/service.js +1258 -0
- package/dist/hosts/claude/native.d.ts +79 -0
- package/dist/hosts/claude/native.js +853 -0
- package/dist/hosts/codex/native.d.ts +345 -0
- package/dist/hosts/codex/native.js +1528 -0
- package/dist/hosts/codex/protocol.d.ts +51 -0
- package/dist/hosts/codex/protocol.js +42 -0
- package/dist/hosts/detect.d.ts +29 -0
- package/dist/hosts/detect.js +73 -0
- package/dist/hosts/index.d.ts +10 -0
- package/dist/hosts/index.js +10 -0
- package/dist/hosts/integration/bundle-export.d.ts +24 -0
- package/dist/hosts/integration/bundle-export.js +128 -0
- package/dist/hosts/integration/bundle.d.ts +19 -0
- package/dist/hosts/integration/bundle.js +99 -0
- package/dist/hosts/integration/hook-entry.d.ts +1 -0
- package/dist/hosts/integration/hook-entry.js +68 -0
- package/dist/hosts/integration/hook.d.ts +32 -0
- package/dist/hosts/integration/hook.js +781 -0
- package/dist/hosts/integration/pappra-extension-runtime.mjs +24610 -0
- package/dist/hosts/integration/pappra-hook.mjs +24728 -0
- package/dist/hosts/integration/pi-extension-runtime.d.ts +18 -0
- package/dist/hosts/integration/pi-extension-runtime.js +89 -0
- package/dist/hosts/integration/pi-template.d.ts +3 -0
- package/dist/hosts/integration/pi-template.js +5 -0
- package/dist/hosts/integration/service.d.ts +49 -0
- package/dist/hosts/integration/service.js +1421 -0
- package/dist/hosts/integration/support.d.ts +59 -0
- package/dist/hosts/integration/support.js +66 -0
- package/dist/hosts/integration/templates.d.ts +22 -0
- package/dist/hosts/integration/templates.js +75 -0
- package/dist/hosts/pi/protocol.d.ts +22 -0
- package/dist/hosts/pi/protocol.js +28 -0
- package/dist/hosts/pi/query-result.d.ts +22 -0
- package/dist/hosts/pi/query-result.js +710 -0
- package/dist/hosts/pi/rpc.d.ts +939 -0
- package/dist/hosts/pi/rpc.js +1659 -0
- package/dist/hosts/pilot.d.ts +485 -0
- package/dist/hosts/pilot.js +593 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/infra/fs.d.ts +27 -0
- package/dist/infra/fs.js +130 -0
- package/dist/infra/git.d.ts +60 -0
- package/dist/infra/git.js +358 -0
- package/dist/infra/owned-process-group.d.ts +173 -0
- package/dist/infra/owned-process-group.js +571 -0
- package/dist/install/apply.d.ts +65 -0
- package/dist/install/apply.js +663 -0
- package/dist/install/index.d.ts +5 -0
- package/dist/install/index.js +5 -0
- package/dist/install/ownership.d.ts +85 -0
- package/dist/install/ownership.js +430 -0
- package/dist/install/plan.d.ts +39 -0
- package/dist/install/plan.js +97 -0
- package/dist/install/rollback.d.ts +18 -0
- package/dist/install/rollback.js +544 -0
- package/dist/install/runtime.d.ts +76 -0
- package/dist/install/runtime.js +1252 -0
- package/dist/knowledge/catalog.d.ts +47 -0
- package/dist/knowledge/catalog.js +308 -0
- package/dist/knowledge/context.d.ts +28 -0
- package/dist/knowledge/context.js +61 -0
- package/dist/knowledge/index.d.ts +3 -0
- package/dist/knowledge/index.js +1 -0
- package/dist/knowledge/journal.d.ts +16 -0
- package/dist/knowledge/journal.js +109 -0
- package/dist/knowledge/lifecycle.d.ts +8 -0
- package/dist/knowledge/lifecycle.js +1001 -0
- package/dist/knowledge/paths.d.ts +37 -0
- package/dist/knowledge/paths.js +236 -0
- package/dist/knowledge/refs.d.ts +36 -0
- package/dist/knowledge/refs.js +267 -0
- package/dist/knowledge/service.d.ts +21 -0
- package/dist/knowledge/service.js +393 -0
- package/dist/knowledge/types.d.ts +171 -0
- package/dist/knowledge/types.js +1 -0
- package/dist/knowledge/write.d.ts +8 -0
- package/dist/knowledge/write.js +1223 -0
- package/dist/package-info.d.ts +8 -0
- package/dist/package-info.js +25 -0
- package/dist/schemas/code.d.ts +377 -0
- package/dist/schemas/code.js +145 -0
- package/dist/schemas/collaboration.d.ts +115 -0
- package/dist/schemas/collaboration.js +106 -0
- package/dist/schemas/continuity.d.ts +315 -0
- package/dist/schemas/continuity.js +199 -0
- package/dist/schemas/diagnostics.d.ts +28 -0
- package/dist/schemas/diagnostics.js +27 -0
- package/dist/schemas/doctor.d.ts +157 -0
- package/dist/schemas/doctor.js +75 -0
- package/dist/schemas/document.d.ts +644 -0
- package/dist/schemas/document.js +296 -0
- package/dist/schemas/errors.d.ts +177 -0
- package/dist/schemas/errors.js +176 -0
- package/dist/schemas/evidence.d.ts +24 -0
- package/dist/schemas/evidence.js +16 -0
- package/dist/schemas/host.d.ts +436 -0
- package/dist/schemas/host.js +203 -0
- package/dist/schemas/index.d.ts +15 -0
- package/dist/schemas/index.js +15 -0
- package/dist/schemas/init.d.ts +121 -0
- package/dist/schemas/init.js +94 -0
- package/dist/schemas/install.d.ts +227 -0
- package/dist/schemas/install.js +147 -0
- package/dist/schemas/machine.d.ts +43 -0
- package/dist/schemas/machine.js +96 -0
- package/dist/schemas/outcome.d.ts +23 -0
- package/dist/schemas/outcome.js +17 -0
- package/dist/schemas/paths.d.ts +19 -0
- package/dist/schemas/paths.js +63 -0
- package/dist/schemas/workspace.d.ts +120 -0
- package/dist/schemas/workspace.js +201 -0
- package/dist/workspace/config-file.d.ts +36 -0
- package/dist/workspace/config-file.js +237 -0
- package/dist/workspace/config.d.ts +28 -0
- package/dist/workspace/config.js +79 -0
- package/dist/workspace/discover.d.ts +34 -0
- package/dist/workspace/discover.js +195 -0
- package/dist/workspace/documents.d.ts +21 -0
- package/dist/workspace/documents.js +395 -0
- package/dist/workspace/ignore.d.ts +10 -0
- package/dist/workspace/ignore.js +48 -0
- package/dist/workspace/index.d.ts +7 -0
- package/dist/workspace/index.js +3 -0
- package/dist/workspace/repositories.d.ts +24 -0
- package/dist/workspace/repositories.js +411 -0
- package/dist/workspace/resolve.d.ts +24 -0
- package/dist/workspace/resolve.js +268 -0
- package/dist/workspace/types.d.ts +71 -0
- package/dist/workspace/types.js +1 -0
- package/dist/workspace/validation.d.ts +18 -0
- package/dist/workspace/validation.js +197 -0
- package/package.json +111 -4
- package/skills/pappra/SKILL.md +71 -0
- package/skills/pappra/references/hosts.md +40 -0
- package/skills/pappra/references/lifecycle.md +41 -0
- package/skills/pappra/references/operations.md +27 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { runGit } from '../infra/git.js';
|
|
3
|
+
import { observePath, readFileBounded, sha256Digest } from '../infra/fs.js';
|
|
4
|
+
import { isPathInside } from '../schemas/paths.js';
|
|
5
|
+
import { ensureCodeMutationBoundary } from './registration.js';
|
|
6
|
+
import { diagnosticCodes } from '../schemas/errors.js';
|
|
7
|
+
import { failed, succeeded } from '../schemas/outcome.js';
|
|
8
|
+
import { boundCodeItems } from './budget.js';
|
|
9
|
+
const MAX_FILE_BYTES = 256 * 1024;
|
|
10
|
+
const MAX_FILE_COUNT = 5000;
|
|
11
|
+
const EXCLUDES = [
|
|
12
|
+
':(exclude).codegraph',
|
|
13
|
+
':(exclude).pappra/local',
|
|
14
|
+
':(exclude).pappra/generated',
|
|
15
|
+
];
|
|
16
|
+
function lineAt(text, offset) {
|
|
17
|
+
const before = text.slice(0, offset);
|
|
18
|
+
const lines = before.split('\n');
|
|
19
|
+
return {
|
|
20
|
+
line: lines.length,
|
|
21
|
+
column: (lines[lines.length - 1]?.length ?? 0) + 1,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function snippetAt(text, offset, length) {
|
|
25
|
+
const start = Math.max(0, offset - 120);
|
|
26
|
+
const end = Math.min(text.length, offset + length + 160);
|
|
27
|
+
return text.slice(start, end).replace(/\s+/g, ' ').trim().slice(0, 4096);
|
|
28
|
+
}
|
|
29
|
+
function normalizeRelative(path) {
|
|
30
|
+
const normalized = path.replaceAll('\\', '/');
|
|
31
|
+
if (normalized.length === 0 ||
|
|
32
|
+
normalized.startsWith('/') ||
|
|
33
|
+
normalized.split('/').some((part) => part === '..' || part === '')) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
function evidenceFor(root, path, bytes) {
|
|
39
|
+
return {
|
|
40
|
+
kind: 'file',
|
|
41
|
+
ref: join(root, path),
|
|
42
|
+
digest: sha256Digest(bytes),
|
|
43
|
+
observedAt: new Date().toISOString(),
|
|
44
|
+
scope: 'live-owned',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function structureMatches(text, query) {
|
|
48
|
+
const items = [];
|
|
49
|
+
const pattern = /(?:^|\n)\s*(?:export\s+)?(?:default\s+)?(?:async\s+)?(?:function|class|interface|type|const|let|var)\s+([A-Za-z_$][\w$]*)/g;
|
|
50
|
+
for (const match of text.matchAll(pattern)) {
|
|
51
|
+
const name = match[1];
|
|
52
|
+
if (name === undefined ||
|
|
53
|
+
!name.toLowerCase().includes(query.toLowerCase())) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const offset = match.index ?? 0;
|
|
57
|
+
const location = lineAt(text, offset);
|
|
58
|
+
items.push({
|
|
59
|
+
path: '',
|
|
60
|
+
line: location.line,
|
|
61
|
+
column: location.column,
|
|
62
|
+
kind: 'symbol',
|
|
63
|
+
name,
|
|
64
|
+
snippet: snippetAt(text, offset, match[0].length),
|
|
65
|
+
source: 'structure',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return items;
|
|
69
|
+
}
|
|
70
|
+
export async function runTextQuery(request, mode, signal) {
|
|
71
|
+
const root = request.identity.root;
|
|
72
|
+
const protectedRoots = [
|
|
73
|
+
join(root, '.pappra', 'local'),
|
|
74
|
+
join(root, '.pappra', 'generated'),
|
|
75
|
+
...(request.excludedRoots ?? []),
|
|
76
|
+
];
|
|
77
|
+
const list = await runGit({
|
|
78
|
+
cwd: root,
|
|
79
|
+
args: [
|
|
80
|
+
'ls-files',
|
|
81
|
+
'--cached',
|
|
82
|
+
'--others',
|
|
83
|
+
'--exclude-standard',
|
|
84
|
+
'-z',
|
|
85
|
+
'--',
|
|
86
|
+
'.',
|
|
87
|
+
...EXCLUDES,
|
|
88
|
+
],
|
|
89
|
+
timeoutMs: 10_000,
|
|
90
|
+
maxOutputBytes: 2 * 1024 * 1024,
|
|
91
|
+
...(signal === undefined ? {} : { signal }),
|
|
92
|
+
});
|
|
93
|
+
if (!list.ok) {
|
|
94
|
+
return failed(diagnosticCodes.code_query_invalid, `Cannot list selected repository files: ${list.message}`, { nextAction: 'Inspect Git availability and the selected repository.' });
|
|
95
|
+
}
|
|
96
|
+
const paths = [...new Set(list.value.stdout.split('\0').filter(Boolean))]
|
|
97
|
+
.map(normalizeRelative)
|
|
98
|
+
.filter((path) => path !== null)
|
|
99
|
+
.slice(0, Math.min(request.limits.maxFiles, MAX_FILE_COUNT));
|
|
100
|
+
const items = [];
|
|
101
|
+
const evidence = [];
|
|
102
|
+
const reasons = [];
|
|
103
|
+
let bytes = 0;
|
|
104
|
+
let truncated = list.value.stdout.split('\0').filter(Boolean).length > paths.length;
|
|
105
|
+
for (const path of paths) {
|
|
106
|
+
if (items.length >= request.limits.maxResults ||
|
|
107
|
+
bytes >= request.limits.maxBytes) {
|
|
108
|
+
truncated = true;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
const absolute = join(root, path);
|
|
112
|
+
if (!isPathInside(root, absolute)) {
|
|
113
|
+
reasons.push('path_unsafe');
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if ((request.excludedRoots ?? []).some((excluded) => isPathInside(excluded, absolute))) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const boundary = await ensureCodeMutationBoundary(root, absolute, protectedRoots);
|
|
120
|
+
if (!boundary.ok) {
|
|
121
|
+
reasons.push('canonical_path_unsafe');
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const observation = await observePath(absolute).catch(() => null);
|
|
125
|
+
if (observation === null || observation.kind !== 'file') {
|
|
126
|
+
reasons.push('non_regular_skipped');
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const read = await readFileBounded(absolute, MAX_FILE_BYTES);
|
|
130
|
+
if (!read.ok) {
|
|
131
|
+
reasons.push('file_unreadable_or_large');
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (read.value.bytes.includes(0)) {
|
|
135
|
+
reasons.push('binary_skipped');
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
bytes += read.value.size;
|
|
139
|
+
if (bytes > request.limits.maxBytes) {
|
|
140
|
+
bytes = request.limits.maxBytes;
|
|
141
|
+
truncated = true;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
const text = read.value.bytes.toString('utf8');
|
|
145
|
+
if (mode === 'text') {
|
|
146
|
+
const lower = text.toLowerCase();
|
|
147
|
+
const needle = request.query.toLowerCase();
|
|
148
|
+
let offset = lower.indexOf(needle);
|
|
149
|
+
while (offset !== -1 && items.length < request.limits.maxResults) {
|
|
150
|
+
const location = lineAt(text, offset);
|
|
151
|
+
items.push({
|
|
152
|
+
path,
|
|
153
|
+
line: location.line,
|
|
154
|
+
column: location.column,
|
|
155
|
+
kind: 'text',
|
|
156
|
+
name: null,
|
|
157
|
+
snippet: snippetAt(text, offset, request.query.length),
|
|
158
|
+
source: 'text',
|
|
159
|
+
});
|
|
160
|
+
offset = lower.indexOf(needle, offset + Math.max(1, needle.length));
|
|
161
|
+
}
|
|
162
|
+
if (offset !== -1)
|
|
163
|
+
truncated = true;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const matches = structureMatches(text, request.query);
|
|
167
|
+
for (const match of matches) {
|
|
168
|
+
if (items.length >= request.limits.maxResults) {
|
|
169
|
+
truncated = true;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
items.push({ ...match, path });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (items.some((item) => item.path === path)) {
|
|
176
|
+
evidence.push(evidenceFor(root, path, read.value.bytes));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const bounded = boundCodeItems(items, request.limits.maxBytes, request.limits.maxResults, request.limits.maxFiles);
|
|
180
|
+
const includedEvidence = new Set(bounded.items.map((item) => join(root, item.path)));
|
|
181
|
+
return succeeded({
|
|
182
|
+
schema: 'pappra/code-query-result/1',
|
|
183
|
+
provider: mode,
|
|
184
|
+
kind: request.kind,
|
|
185
|
+
query: request.query,
|
|
186
|
+
identityDigest: sha256Digest(JSON.stringify(request.identity)),
|
|
187
|
+
observedIdentity: request.identity,
|
|
188
|
+
coverage: truncated || bounded.truncated || reasons.length > 0
|
|
189
|
+
? 'partial'
|
|
190
|
+
: 'fallback',
|
|
191
|
+
items: bounded.items,
|
|
192
|
+
bytes: bounded.bytes,
|
|
193
|
+
truncated: truncated || bounded.truncated,
|
|
194
|
+
reasons: [...new Set([...reasons, ...bounded.reasons])].slice(0, 16),
|
|
195
|
+
evidence: evidence
|
|
196
|
+
.filter((entry) => includedEvidence.has(entry.ref))
|
|
197
|
+
.slice(0, 32),
|
|
198
|
+
unsupportedReason: mode === 'structure'
|
|
199
|
+
? 'Structural fallback is a bounded declaration scan, not a semantic symbol index.'
|
|
200
|
+
: 'Text fallback scans bounded working-tree files, not the CodeGraph index.',
|
|
201
|
+
});
|
|
202
|
+
}
|
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
import type { TaskRecord, Resource, ReservationInput } from './types.js';
|
|
2
|
+
export interface AdmissionOptions {
|
|
3
|
+
assignmentFile: string;
|
|
4
|
+
capabilitiesFile: string;
|
|
5
|
+
taskRoot: string;
|
|
6
|
+
cwd: string;
|
|
7
|
+
sessionId?: string | null;
|
|
8
|
+
harness?: string | null;
|
|
9
|
+
profile?: string | null;
|
|
10
|
+
launchKind?: string;
|
|
11
|
+
discovery?: boolean;
|
|
12
|
+
resumeSelector?: string | null;
|
|
13
|
+
now?: number;
|
|
14
|
+
maxAgeMinutes?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface SettleOptions {
|
|
17
|
+
reservationId: string;
|
|
18
|
+
outcome: string;
|
|
19
|
+
exitCode?: number | null;
|
|
20
|
+
sessionId?: string | null;
|
|
21
|
+
runId?: string | null;
|
|
22
|
+
evidenceRef?: string | null;
|
|
23
|
+
runner?: string | null;
|
|
24
|
+
detail?: string | null;
|
|
25
|
+
expectedIdentity?: string | null;
|
|
26
|
+
capabilityEvidence?: string | null;
|
|
27
|
+
identityStatus?: string | null;
|
|
28
|
+
cleanExit?: boolean;
|
|
29
|
+
clock?: number;
|
|
30
|
+
}
|
|
31
|
+
export declare const TOOL_PROFILES: {
|
|
32
|
+
pi: {
|
|
33
|
+
writer: string;
|
|
34
|
+
reviewer: string;
|
|
35
|
+
};
|
|
36
|
+
claude: {
|
|
37
|
+
writer: string;
|
|
38
|
+
reviewer: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Pre-dispatch admission. A launcher that started a native process without checking the
|
|
43
|
+
* assignment, the capability snapshot, the collaboration record and the actual resource
|
|
44
|
+
* ownership would be an automatic entry that bypasses the whole contract, so it refuses.
|
|
45
|
+
*
|
|
46
|
+
* Two modes exist:
|
|
47
|
+
* work the default; requires a runtime-ready capability card
|
|
48
|
+
* discovery the restricted path that produces the first runtime observation; it may use a
|
|
49
|
+
* declared card but must require no capability at all, so it cannot claim
|
|
50
|
+
* anything it has not observed
|
|
51
|
+
*/
|
|
52
|
+
export declare function admitLaunch({ assignmentFile, capabilitiesFile, taskRoot, cwd, sessionId, harness, profile, launchKind, discovery, resumeSelector, now, maxAgeMinutes, }: AdmissionOptions): {
|
|
53
|
+
ok: false;
|
|
54
|
+
reason: string;
|
|
55
|
+
checks: Record<string, unknown>[];
|
|
56
|
+
expected: string;
|
|
57
|
+
actual: string;
|
|
58
|
+
required_skills?: never;
|
|
59
|
+
required_tools?: never;
|
|
60
|
+
preflight?: never;
|
|
61
|
+
state?: never;
|
|
62
|
+
detail?: never;
|
|
63
|
+
state_revision?: never;
|
|
64
|
+
owner_epoch?: never;
|
|
65
|
+
attempt_state?: never;
|
|
66
|
+
resources?: never;
|
|
67
|
+
mode?: never;
|
|
68
|
+
launch_kind?: never;
|
|
69
|
+
resume_selector?: never;
|
|
70
|
+
pre_bound_identity?: never;
|
|
71
|
+
expected_identity?: never;
|
|
72
|
+
capability_evidence?: never;
|
|
73
|
+
assignment_digest?: never;
|
|
74
|
+
input_revision?: never;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
reason: string;
|
|
78
|
+
checks: Record<string, unknown>[];
|
|
79
|
+
detail: string;
|
|
80
|
+
required_skills?: never;
|
|
81
|
+
required_tools?: never;
|
|
82
|
+
preflight?: never;
|
|
83
|
+
state?: never;
|
|
84
|
+
expected?: never;
|
|
85
|
+
actual?: never;
|
|
86
|
+
state_revision?: never;
|
|
87
|
+
owner_epoch?: never;
|
|
88
|
+
attempt_state?: never;
|
|
89
|
+
resources?: never;
|
|
90
|
+
mode?: never;
|
|
91
|
+
launch_kind?: never;
|
|
92
|
+
resume_selector?: never;
|
|
93
|
+
pre_bound_identity?: never;
|
|
94
|
+
expected_identity?: never;
|
|
95
|
+
capability_evidence?: never;
|
|
96
|
+
assignment_digest?: never;
|
|
97
|
+
input_revision?: never;
|
|
98
|
+
} | {
|
|
99
|
+
ok: false;
|
|
100
|
+
reason: string;
|
|
101
|
+
checks: Record<string, unknown>[];
|
|
102
|
+
required_skills?: never;
|
|
103
|
+
required_tools?: never;
|
|
104
|
+
preflight?: never;
|
|
105
|
+
state?: never;
|
|
106
|
+
detail?: never;
|
|
107
|
+
expected?: never;
|
|
108
|
+
actual?: never;
|
|
109
|
+
state_revision?: never;
|
|
110
|
+
owner_epoch?: never;
|
|
111
|
+
attempt_state?: never;
|
|
112
|
+
resources?: never;
|
|
113
|
+
mode?: never;
|
|
114
|
+
launch_kind?: never;
|
|
115
|
+
resume_selector?: never;
|
|
116
|
+
pre_bound_identity?: never;
|
|
117
|
+
expected_identity?: never;
|
|
118
|
+
capability_evidence?: never;
|
|
119
|
+
assignment_digest?: never;
|
|
120
|
+
input_revision?: never;
|
|
121
|
+
} | {
|
|
122
|
+
ok: false;
|
|
123
|
+
reason: string;
|
|
124
|
+
checks: Record<string, unknown>[];
|
|
125
|
+
expected: number;
|
|
126
|
+
actual: number;
|
|
127
|
+
required_skills?: never;
|
|
128
|
+
required_tools?: never;
|
|
129
|
+
preflight?: never;
|
|
130
|
+
state?: never;
|
|
131
|
+
detail?: never;
|
|
132
|
+
state_revision?: never;
|
|
133
|
+
owner_epoch?: never;
|
|
134
|
+
attempt_state?: never;
|
|
135
|
+
resources?: never;
|
|
136
|
+
mode?: never;
|
|
137
|
+
launch_kind?: never;
|
|
138
|
+
resume_selector?: never;
|
|
139
|
+
pre_bound_identity?: never;
|
|
140
|
+
expected_identity?: never;
|
|
141
|
+
capability_evidence?: never;
|
|
142
|
+
assignment_digest?: never;
|
|
143
|
+
input_revision?: never;
|
|
144
|
+
} | {
|
|
145
|
+
ok: false;
|
|
146
|
+
reason: string;
|
|
147
|
+
checks: Record<string, unknown>[];
|
|
148
|
+
expected: import("./types.js").Identity;
|
|
149
|
+
actual: import("./types.js").Identity & {
|
|
150
|
+
harness: string;
|
|
151
|
+
cwd: string;
|
|
152
|
+
surface: string;
|
|
153
|
+
configuration_id: string;
|
|
154
|
+
};
|
|
155
|
+
required_skills?: never;
|
|
156
|
+
required_tools?: never;
|
|
157
|
+
preflight?: never;
|
|
158
|
+
state?: never;
|
|
159
|
+
detail?: never;
|
|
160
|
+
state_revision?: never;
|
|
161
|
+
owner_epoch?: never;
|
|
162
|
+
attempt_state?: never;
|
|
163
|
+
resources?: never;
|
|
164
|
+
mode?: never;
|
|
165
|
+
launch_kind?: never;
|
|
166
|
+
resume_selector?: never;
|
|
167
|
+
pre_bound_identity?: never;
|
|
168
|
+
expected_identity?: never;
|
|
169
|
+
capability_evidence?: never;
|
|
170
|
+
assignment_digest?: never;
|
|
171
|
+
input_revision?: never;
|
|
172
|
+
} | {
|
|
173
|
+
ok: false;
|
|
174
|
+
reason: string;
|
|
175
|
+
checks: Record<string, unknown>[];
|
|
176
|
+
expected: string;
|
|
177
|
+
actual: string;
|
|
178
|
+
detail: string;
|
|
179
|
+
required_skills?: never;
|
|
180
|
+
required_tools?: never;
|
|
181
|
+
preflight?: never;
|
|
182
|
+
state?: never;
|
|
183
|
+
state_revision?: never;
|
|
184
|
+
owner_epoch?: never;
|
|
185
|
+
attempt_state?: never;
|
|
186
|
+
resources?: never;
|
|
187
|
+
mode?: never;
|
|
188
|
+
launch_kind?: never;
|
|
189
|
+
resume_selector?: never;
|
|
190
|
+
pre_bound_identity?: never;
|
|
191
|
+
expected_identity?: never;
|
|
192
|
+
capability_evidence?: never;
|
|
193
|
+
assignment_digest?: never;
|
|
194
|
+
input_revision?: never;
|
|
195
|
+
} | {
|
|
196
|
+
ok: false;
|
|
197
|
+
reason: string;
|
|
198
|
+
checks: Record<string, unknown>[];
|
|
199
|
+
required_skills: number;
|
|
200
|
+
required_tools: number;
|
|
201
|
+
preflight?: never;
|
|
202
|
+
state?: never;
|
|
203
|
+
detail?: never;
|
|
204
|
+
expected?: never;
|
|
205
|
+
actual?: never;
|
|
206
|
+
state_revision?: never;
|
|
207
|
+
owner_epoch?: never;
|
|
208
|
+
attempt_state?: never;
|
|
209
|
+
resources?: never;
|
|
210
|
+
mode?: never;
|
|
211
|
+
launch_kind?: never;
|
|
212
|
+
resume_selector?: never;
|
|
213
|
+
pre_bound_identity?: never;
|
|
214
|
+
expected_identity?: never;
|
|
215
|
+
capability_evidence?: never;
|
|
216
|
+
assignment_digest?: never;
|
|
217
|
+
input_revision?: never;
|
|
218
|
+
} | {
|
|
219
|
+
required_skills?: never;
|
|
220
|
+
required_tools?: never;
|
|
221
|
+
ok: false;
|
|
222
|
+
reason: string;
|
|
223
|
+
checks: Record<string, unknown>[];
|
|
224
|
+
preflight: {
|
|
225
|
+
status: string;
|
|
226
|
+
errors: string[];
|
|
227
|
+
blockers: never[];
|
|
228
|
+
warnings: never[];
|
|
229
|
+
task_id?: never;
|
|
230
|
+
assignment_id?: never;
|
|
231
|
+
attempt?: never;
|
|
232
|
+
checked_at?: never;
|
|
233
|
+
limits?: never;
|
|
234
|
+
} | {
|
|
235
|
+
status: string;
|
|
236
|
+
task_id: string;
|
|
237
|
+
assignment_id: string;
|
|
238
|
+
attempt: number;
|
|
239
|
+
checked_at: string;
|
|
240
|
+
errors: never[];
|
|
241
|
+
blockers: import("./preflight.js").Check[];
|
|
242
|
+
warnings: import("./preflight.js").Check[];
|
|
243
|
+
limits: string[];
|
|
244
|
+
};
|
|
245
|
+
state?: never;
|
|
246
|
+
detail?: never;
|
|
247
|
+
expected?: never;
|
|
248
|
+
actual?: never;
|
|
249
|
+
state_revision?: never;
|
|
250
|
+
owner_epoch?: never;
|
|
251
|
+
attempt_state?: never;
|
|
252
|
+
resources?: never;
|
|
253
|
+
mode?: never;
|
|
254
|
+
launch_kind?: never;
|
|
255
|
+
resume_selector?: never;
|
|
256
|
+
pre_bound_identity?: never;
|
|
257
|
+
expected_identity?: never;
|
|
258
|
+
capability_evidence?: never;
|
|
259
|
+
assignment_digest?: never;
|
|
260
|
+
input_revision?: never;
|
|
261
|
+
} | {
|
|
262
|
+
required_skills?: never;
|
|
263
|
+
required_tools?: never;
|
|
264
|
+
preflight?: never;
|
|
265
|
+
ok: false;
|
|
266
|
+
reason: string;
|
|
267
|
+
checks: Record<string, unknown>[];
|
|
268
|
+
state: string;
|
|
269
|
+
detail?: never;
|
|
270
|
+
expected?: never;
|
|
271
|
+
actual?: never;
|
|
272
|
+
state_revision?: never;
|
|
273
|
+
owner_epoch?: never;
|
|
274
|
+
attempt_state?: never;
|
|
275
|
+
resources?: never;
|
|
276
|
+
mode?: never;
|
|
277
|
+
launch_kind?: never;
|
|
278
|
+
resume_selector?: never;
|
|
279
|
+
pre_bound_identity?: never;
|
|
280
|
+
expected_identity?: never;
|
|
281
|
+
capability_evidence?: never;
|
|
282
|
+
assignment_digest?: never;
|
|
283
|
+
input_revision?: never;
|
|
284
|
+
} | {
|
|
285
|
+
required_skills?: never;
|
|
286
|
+
required_tools?: never;
|
|
287
|
+
preflight?: never;
|
|
288
|
+
state?: never;
|
|
289
|
+
ok: false;
|
|
290
|
+
reason: string;
|
|
291
|
+
checks: Record<string, unknown>[];
|
|
292
|
+
expected: (string | null)[];
|
|
293
|
+
actual: string;
|
|
294
|
+
detail?: never;
|
|
295
|
+
state_revision?: never;
|
|
296
|
+
owner_epoch?: never;
|
|
297
|
+
attempt_state?: never;
|
|
298
|
+
resources?: never;
|
|
299
|
+
mode?: never;
|
|
300
|
+
launch_kind?: never;
|
|
301
|
+
resume_selector?: never;
|
|
302
|
+
pre_bound_identity?: never;
|
|
303
|
+
expected_identity?: never;
|
|
304
|
+
capability_evidence?: never;
|
|
305
|
+
assignment_digest?: never;
|
|
306
|
+
input_revision?: never;
|
|
307
|
+
} | {
|
|
308
|
+
required_skills?: never;
|
|
309
|
+
required_tools?: never;
|
|
310
|
+
preflight?: never;
|
|
311
|
+
state?: never;
|
|
312
|
+
ok: false;
|
|
313
|
+
reason: string;
|
|
314
|
+
checks: Record<string, unknown>[];
|
|
315
|
+
resources: Record<string, unknown>[];
|
|
316
|
+
detail: string;
|
|
317
|
+
expected?: never;
|
|
318
|
+
actual?: never;
|
|
319
|
+
state_revision?: never;
|
|
320
|
+
owner_epoch?: never;
|
|
321
|
+
attempt_state?: never;
|
|
322
|
+
mode?: never;
|
|
323
|
+
launch_kind?: never;
|
|
324
|
+
resume_selector?: never;
|
|
325
|
+
pre_bound_identity?: never;
|
|
326
|
+
expected_identity?: never;
|
|
327
|
+
capability_evidence?: never;
|
|
328
|
+
assignment_digest?: never;
|
|
329
|
+
input_revision?: never;
|
|
330
|
+
} | {
|
|
331
|
+
required_skills?: never;
|
|
332
|
+
required_tools?: never;
|
|
333
|
+
preflight?: never;
|
|
334
|
+
state?: never;
|
|
335
|
+
detail?: never;
|
|
336
|
+
ok: false;
|
|
337
|
+
reason: string;
|
|
338
|
+
checks: Record<string, unknown>[];
|
|
339
|
+
resources: Record<string, unknown>[];
|
|
340
|
+
expected: number | undefined;
|
|
341
|
+
actual: number;
|
|
342
|
+
state_revision?: never;
|
|
343
|
+
owner_epoch?: never;
|
|
344
|
+
attempt_state?: never;
|
|
345
|
+
mode?: never;
|
|
346
|
+
launch_kind?: never;
|
|
347
|
+
resume_selector?: never;
|
|
348
|
+
pre_bound_identity?: never;
|
|
349
|
+
expected_identity?: never;
|
|
350
|
+
capability_evidence?: never;
|
|
351
|
+
assignment_digest?: never;
|
|
352
|
+
input_revision?: never;
|
|
353
|
+
} | {
|
|
354
|
+
required_skills?: never;
|
|
355
|
+
required_tools?: never;
|
|
356
|
+
preflight?: never;
|
|
357
|
+
state?: never;
|
|
358
|
+
detail?: never;
|
|
359
|
+
expected?: never;
|
|
360
|
+
actual?: never;
|
|
361
|
+
ok: false;
|
|
362
|
+
reason: string;
|
|
363
|
+
checks: Record<string, unknown>[];
|
|
364
|
+
resources: Record<string, unknown>[];
|
|
365
|
+
state_revision?: never;
|
|
366
|
+
owner_epoch?: never;
|
|
367
|
+
attempt_state?: never;
|
|
368
|
+
mode?: never;
|
|
369
|
+
launch_kind?: never;
|
|
370
|
+
resume_selector?: never;
|
|
371
|
+
pre_bound_identity?: never;
|
|
372
|
+
expected_identity?: never;
|
|
373
|
+
capability_evidence?: never;
|
|
374
|
+
assignment_digest?: never;
|
|
375
|
+
input_revision?: never;
|
|
376
|
+
} | {
|
|
377
|
+
required_skills?: never;
|
|
378
|
+
required_tools?: never;
|
|
379
|
+
preflight?: never;
|
|
380
|
+
state?: never;
|
|
381
|
+
detail?: never;
|
|
382
|
+
expected?: never;
|
|
383
|
+
actual?: never;
|
|
384
|
+
reason?: never;
|
|
385
|
+
ok: true;
|
|
386
|
+
checks: Record<string, unknown>[];
|
|
387
|
+
state_revision: number;
|
|
388
|
+
owner_epoch: number | null;
|
|
389
|
+
attempt_state: string;
|
|
390
|
+
resources: Record<string, unknown>[];
|
|
391
|
+
mode: string;
|
|
392
|
+
launch_kind: string;
|
|
393
|
+
resume_selector: string | null;
|
|
394
|
+
pre_bound_identity: string | null;
|
|
395
|
+
expected_identity: string | null;
|
|
396
|
+
capability_evidence: string;
|
|
397
|
+
assignment_digest: string;
|
|
398
|
+
input_revision: string | null;
|
|
399
|
+
};
|
|
400
|
+
/** True when an existing claim covers the requested range (claim is equal to or above it). */
|
|
401
|
+
export declare function hasPendingCancellation(record: TaskRecord, subtaskId: string, attempt: number): boolean;
|
|
402
|
+
export declare function claimCovers(claim: Resource, requested: Resource): boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Atomically reserve the launch. A second launcher cannot reserve the same attempt, and the
|
|
405
|
+
* reservation distinguishes a first launch from a continuation, so "already started" is a
|
|
406
|
+
* recorded fact rather than an assumption.
|
|
407
|
+
*/
|
|
408
|
+
export declare function reserveLaunch(taskRoot: string, { reservation, expectRevision, clock, }: {
|
|
409
|
+
reservation: ReservationInput;
|
|
410
|
+
expectRevision?: number;
|
|
411
|
+
clock?: number;
|
|
412
|
+
}): {
|
|
413
|
+
[key: string]: unknown;
|
|
414
|
+
ok: false;
|
|
415
|
+
reason: string;
|
|
416
|
+
} | {
|
|
417
|
+
ok: true;
|
|
418
|
+
reservation_id: string;
|
|
419
|
+
state_revision: number;
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* Settle a launch reservation and persist what actually happened.
|
|
423
|
+
*
|
|
424
|
+
* Outcomes are deliberately distinguished:
|
|
425
|
+
* exited / exited_nonzero the process ran; the attempt keeps a recorded native run, so a
|
|
426
|
+
* later `first` launch is refused with `already_launched`
|
|
427
|
+
* timed_out / spawn_failed the process may be alive or may have started; the attempt moves to
|
|
428
|
+
* `unknown` with an uncertainty, so nothing may be dispatched over it
|
|
429
|
+
* until it is reconciled
|
|
430
|
+
* not_started nothing was spawned (a validation failure); the reservation is
|
|
431
|
+
* released and the attempt is left exactly as it was
|
|
432
|
+
*/
|
|
433
|
+
export declare function classifyIdentity({ ran, observed, expected, capabilityEvidence, }: {
|
|
434
|
+
ran: boolean;
|
|
435
|
+
observed?: string | null;
|
|
436
|
+
expected?: string | null;
|
|
437
|
+
capabilityEvidence?: string | null;
|
|
438
|
+
}): {
|
|
439
|
+
status: string;
|
|
440
|
+
confirmed: boolean;
|
|
441
|
+
};
|
|
442
|
+
export declare function settleLaunch(taskRoot: string, { reservationId, outcome, exitCode, sessionId, runId, evidenceRef, runner, detail, expectedIdentity, capabilityEvidence, identityStatus, cleanExit, clock, }: SettleOptions): {
|
|
443
|
+
[key: string]: unknown;
|
|
444
|
+
ok: false;
|
|
445
|
+
reason: string;
|
|
446
|
+
} | {
|
|
447
|
+
ok: true;
|
|
448
|
+
outcome: string;
|
|
449
|
+
result: Record<string, unknown> | null;
|
|
450
|
+
};
|