@promptdriven/runtime-client 0.0.0-stage → 1.1.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/LICENSE +7 -0
- package/README.md +42 -2
- package/package.json +28 -4
- package/src/index.mjs +1 -0
- package/src/runtime/agent-ask.mjs +187 -0
- package/src/runtime/agent-chat.mjs +152 -0
- package/src/runtime/agent-coverage.mjs +97 -0
- package/src/runtime/agent-guide.mjs +152 -0
- package/src/runtime/agent-judge.mjs +71 -0
- package/src/runtime/agent-packet.mjs +62 -0
- package/src/runtime/agent-project.mjs +93 -0
- package/src/runtime/contract-refs.mjs +519 -0
- package/src/runtime/contracts.mjs +138 -0
- package/src/runtime/index.mjs +974 -0
- package/src/runtime/lint-call-preflight.mjs +19 -0
- package/src/runtime/lint-compatibility-display.mjs +62 -0
- package/src/runtime/live-local-bridge.mjs +178 -0
- package/src/runtime/live-local.mjs +181 -0
- package/src/runtime/product-composition.mjs +384 -0
- package/src/runtime/run-program.mjs +797 -0
- package/src/runtime/runtime-binding-plan.mjs +145 -0
- package/src/runtime/runtime-bindings.mjs +81 -0
- package/src/runtime/runtime-check-plan.mjs +411 -0
- package/src/runtime/runtime-client.mjs +8114 -0
- package/src/runtime/runtime-lint-receipt.mjs +25 -0
- package/src/runtime/runtime-markdown.mjs +215 -0
- package/src/runtime/runtime-outcome.mjs +468 -0
- package/src/runtime/runtime-output.mjs +752 -0
- package/src/runtime/runtime-preflight.mjs +3832 -0
- package/src/runtime/runtime-slots.mjs +462 -0
- package/src/runtime/runtime-workspace-migration.mjs +70 -0
- package/src/runtime/runtime-workspace.mjs +52 -0
- package/src/runtime/scenario-json.mjs +257 -0
- package/src/runtime/secret-redaction.mjs +54 -0
- package/src/runtime/try-doors.mjs +597 -0
- package/src/runtime/try-http.mjs +285 -0
- package/src/runtime/try-mcp.mjs +223 -0
- package/src/runtime/try-session.mjs +95 -0
- package/src/runtime/try-update-policy.mjs +43 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Generated from prompts/cli/try-update-policy.prompt.md.
|
|
2
|
+
const categories = ['tests', 'approvals'];
|
|
3
|
+
const validRevisions = value => value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
4
|
+
&& categories.every(key => Number.isSafeInteger(value[key]) && value[key] >= 0);
|
|
5
|
+
const deadline = (now, delay) => Math.min(Number.MAX_SAFE_INTEGER, now + delay);
|
|
6
|
+
|
|
7
|
+
export function advanceTryUpdates({ state, event, now, watchMs }) {
|
|
8
|
+
const fresh = desired => ({ desired, acknowledged: -1, target: null, retryAt: 0, nextAt: 0, missing: false });
|
|
9
|
+
let next = state === null ? null : { ...state, tests: { ...state.tests }, approvals: { ...state.approvals } };
|
|
10
|
+
let error = null, read = [], postApprovals = false;
|
|
11
|
+
const end = () => { next.mode = 'ended'; for (const category of categories) next[category].target = null; next.deliveryInFlight = false; };
|
|
12
|
+
if (event.kind === 'connect' && next === null) {
|
|
13
|
+
const valid = !event.advertised || validRevisions(event.revisions);
|
|
14
|
+
next = { mode: event.advertised ? 'notifications' : 'legacy', tests: fresh(valid && event.advertised ? event.revisions.tests : 0), approvals: fresh(valid && event.advertised ? event.revisions.approvals : 0), deliveryPending: false, deliveryInFlight: false, deliveryRetryAt: 0 };
|
|
15
|
+
if (!valid) { error = 'invalid-update-revisions'; end(); }
|
|
16
|
+
} else if (next.mode !== 'ended') {
|
|
17
|
+
if (event.kind === 'notice' && next.mode === 'notifications') {
|
|
18
|
+
if (!validRevisions(event.revisions) || categories.some(key => event.revisions[key] < next[key].desired)) { error = 'invalid-update-revisions'; end(); }
|
|
19
|
+
else for (const category of categories) next[category].desired = event.revisions[category];
|
|
20
|
+
} else if (event.kind === 'plan') {
|
|
21
|
+
for (const category of categories) {
|
|
22
|
+
const item = next[category];
|
|
23
|
+
if (!item.missing && item.target === null && now >= item.retryAt && (next.mode === 'notifications' ? item.desired > item.acknowledged : now >= item.nextAt)) {
|
|
24
|
+
item.target = item.desired; read.push(category);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (next.deliveryPending && !next.deliveryInFlight && now >= next.deliveryRetryAt) { next.deliveryInFlight = true; postApprovals = true; }
|
|
28
|
+
} else if (event.kind === 'complete') {
|
|
29
|
+
const item = next[event.category];
|
|
30
|
+
if (item.target !== null) {
|
|
31
|
+
if (event.outcome === 'success') { item.acknowledged = item.target; item.retryAt = 0; item.nextAt = deadline(now, watchMs); }
|
|
32
|
+
else if (event.outcome === 'retry') item.retryAt = deadline(now, event.retryMs);
|
|
33
|
+
else if (event.outcome === 'missing') item.missing = true;
|
|
34
|
+
else if (event.outcome === 'ended') end();
|
|
35
|
+
item.target = null;
|
|
36
|
+
}
|
|
37
|
+
} else if (event.kind === 'delivery') {
|
|
38
|
+
next.deliveryPending = event.pending; next.deliveryInFlight = false;
|
|
39
|
+
next.deliveryRetryAt = event.pending ? deadline(now, event.retryMs) : 0;
|
|
40
|
+
} else if (event.kind === 'end') end();
|
|
41
|
+
}
|
|
42
|
+
return { state: next, read, postApprovals, pollRevisions: next.mode === 'notifications' ? Object.fromEntries(categories.map(key => [key, next[key].missing ? null : next[key].acknowledged])) : null, error };
|
|
43
|
+
}
|