@intentic/sandbox-contract 1.312.0 → 1.313.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/README.md +26 -3
- package/dist/chores/index.d.ts +0 -1
- package/dist/chores/index.d.ts.map +1 -1
- package/dist/chores/index.js +0 -1
- package/dist/chores/index.js.map +1 -1
- package/dist/contracts/accounts.contract.d.ts +57 -0
- package/dist/contracts/accounts.contract.d.ts.map +1 -1
- package/dist/contracts/agent.contract.d.ts +436 -0
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agent.contract.js +11 -1
- package/dist/contracts/agent.contract.js.map +1 -1
- package/dist/contracts/agents.contract.d.ts +123 -96
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/capabilities.contract.js +1 -1
- package/dist/contracts/capabilities.contract.js.map +1 -1
- package/dist/contracts/device.contract.d.ts +19 -4
- package/dist/contracts/device.contract.d.ts.map +1 -1
- package/dist/contracts/device.contract.js +1 -1
- package/dist/contracts/device.contract.js.map +1 -1
- package/dist/contracts/extensions.contract.d.ts +11 -0
- package/dist/contracts/extensions.contract.d.ts.map +1 -1
- package/dist/contracts/git.contract.d.ts +2 -0
- package/dist/contracts/git.contract.d.ts.map +1 -1
- package/dist/contracts/personas.contract.d.ts +2 -0
- package/dist/contracts/personas.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +138 -0
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.js +1 -0
- package/dist/contracts/secrets.contract.js.map +1 -1
- package/dist/contracts/sessions.contract.d.ts +59 -0
- package/dist/contracts/sessions.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.d.ts +12 -8
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.js +2 -2
- package/dist/contracts/settings.contract.js.map +1 -1
- package/dist/contracts/system.contract.d.ts +139 -19
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/translator.contract.d.ts +72 -0
- package/dist/contracts/translator.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.d.ts +85 -14
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/documents/index.d.ts +1 -0
- package/dist/documents/index.d.ts.map +1 -1
- package/dist/documents/index.js +1 -0
- package/dist/documents/index.js.map +1 -1
- package/dist/documents/read.d.ts +24 -0
- package/dist/documents/read.d.ts.map +1 -0
- package/dist/documents/read.js +81 -0
- package/dist/documents/read.js.map +1 -0
- package/dist/events/agent-events.d.ts +235 -0
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-events.js +3 -0
- package/dist/events/agent-events.js.map +1 -1
- package/dist/events/child-run.d.ts +9 -0
- package/dist/events/child-run.d.ts.map +1 -0
- package/dist/events/child-run.js +41 -0
- package/dist/events/child-run.js.map +1 -0
- package/dist/events/errands.d.ts +5 -0
- package/dist/events/errands.d.ts.map +1 -0
- package/dist/events/errands.js +19 -0
- package/dist/events/errands.js.map +1 -0
- package/dist/events/requests.d.ts +152 -0
- package/dist/events/requests.d.ts.map +1 -1
- package/dist/events/requests.js +26 -1
- package/dist/events/requests.js.map +1 -1
- package/dist/events/system-events.d.ts +8 -12
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/transcript.d.ts +387 -0
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/events/transcript.js +3 -0
- package/dist/events/transcript.js.map +1 -1
- package/dist/front/browser-wire.d.ts +6 -0
- package/dist/front/browser-wire.d.ts.map +1 -0
- package/dist/front/browser-wire.js +4 -0
- package/dist/front/browser-wire.js.map +1 -0
- package/dist/front/front-wire.d.ts +6 -0
- package/dist/front/front-wire.d.ts.map +1 -0
- package/dist/front/front-wire.js +5 -0
- package/dist/front/front-wire.js.map +1 -0
- package/dist/front/generated/browser-wire.d.ts +19 -0
- package/dist/front/generated/browser-wire.d.ts.map +1 -0
- package/dist/front/generated/browser-wire.js +2 -0
- package/dist/front/generated/browser-wire.js.map +1 -0
- package/dist/front/generated/wire.d.ts +36 -30
- package/dist/front/generated/wire.d.ts.map +1 -1
- package/dist/ids/conversation-ids.d.ts +1 -0
- package/dist/ids/conversation-ids.d.ts.map +1 -1
- package/dist/ids/conversation-ids.js +2 -2
- package/dist/ids/conversation-ids.js.map +1 -1
- package/dist/ids/session-names.d.ts +3 -0
- package/dist/ids/session-names.d.ts.map +1 -1
- package/dist/ids/session-names.js +3 -0
- package/dist/ids/session-names.js.map +1 -1
- package/dist/index.d.ts +1036 -168
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/models/agent-catalog.d.ts.map +1 -1
- package/dist/models/agent-catalog.js +4 -6
- package/dist/models/agent-catalog.js.map +1 -1
- package/dist/models/agent-runtimes.d.ts +2 -1
- package/dist/models/agent-runtimes.d.ts.map +1 -1
- package/dist/models/agent-runtimes.js +7 -1
- package/dist/models/agent-runtimes.js.map +1 -1
- package/dist/models/plan-pools.d.ts +22 -1
- package/dist/models/plan-pools.d.ts.map +1 -1
- package/dist/models/plan-pools.js +86 -0
- package/dist/models/plan-pools.js.map +1 -1
- package/dist/policy/request-status.d.ts +1 -1
- package/dist/policy/request-status.d.ts.map +1 -1
- package/dist/policy/request-status.js +4 -11
- package/dist/policy/request-status.js.map +1 -1
- package/dist/policy/reserved-servers.d.ts.map +1 -1
- package/dist/policy/reserved-servers.js +2 -1
- package/dist/policy/reserved-servers.js.map +1 -1
- package/dist/policy/turned-away.d.ts.map +1 -1
- package/dist/policy/turned-away.js +1 -0
- package/dist/policy/turned-away.js.map +1 -1
- package/dist/protocol/edge-verdict.d.ts +2 -1
- package/dist/protocol/edge-verdict.d.ts.map +1 -1
- package/dist/protocol/edge-verdict.js +1 -1
- package/dist/protocol/edge-verdict.js.map +1 -1
- package/dist/protocol/ingress-contract.d.ts +1 -1
- package/dist/protocol/ingress-contract.d.ts.map +1 -1
- package/dist/protocol/ingress-contract.js +1 -1
- package/dist/protocol/ingress-contract.js.map +1 -1
- package/dist/protocol/raw-routes.d.ts +18 -40
- package/dist/protocol/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw-routes.js +5 -16
- package/dist/protocol/raw-routes.js.map +1 -1
- package/dist/protocol/route-meta.d.ts +20 -0
- package/dist/protocol/route-meta.d.ts.map +1 -1
- package/dist/protocol/route-meta.js +16 -0
- package/dist/protocol/route-meta.js.map +1 -1
- package/dist/protocol/tunnel-bulk.d.ts +2 -0
- package/dist/protocol/tunnel-bulk.d.ts.map +1 -0
- package/dist/protocol/tunnel-bulk.js +3 -0
- package/dist/protocol/tunnel-bulk.js.map +1 -0
- package/dist/protocol/x402.d.ts +17 -0
- package/dist/protocol/x402.d.ts.map +1 -0
- package/dist/protocol/x402.js +37 -0
- package/dist/protocol/x402.js.map +1 -0
- package/dist/schemas/agent.d.ts +25 -0
- package/dist/schemas/agent.d.ts.map +1 -1
- package/dist/schemas/agent.js +14 -2
- package/dist/schemas/agent.js.map +1 -1
- package/dist/schemas/agents.d.ts +17 -18
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/agents.js +16 -3
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/automations.d.ts +4 -6
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/devices.d.ts +132 -7
- package/dist/schemas/devices.d.ts.map +1 -1
- package/dist/schemas/devices.js +43 -18
- package/dist/schemas/devices.js.map +1 -1
- package/dist/schemas/extension-updates.d.ts +22 -0
- package/dist/schemas/extension-updates.d.ts.map +1 -1
- package/dist/schemas/extension-updates.js +4 -0
- package/dist/schemas/extension-updates.js.map +1 -1
- package/dist/schemas/git/git.d.ts +3 -0
- package/dist/schemas/git/git.d.ts.map +1 -1
- package/dist/schemas/hosts.d.ts +29 -5
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +20 -7
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/keep-warm.d.ts +2 -12
- package/dist/schemas/keep-warm.d.ts.map +1 -1
- package/dist/schemas/keep-warm.js +8 -10
- package/dist/schemas/keep-warm.js.map +1 -1
- package/dist/schemas/metrics.d.ts +22 -0
- package/dist/schemas/metrics.d.ts.map +1 -1
- package/dist/schemas/metrics.js +18 -3
- package/dist/schemas/metrics.js.map +1 -1
- package/dist/schemas/personas.d.ts +3 -0
- package/dist/schemas/personas.d.ts.map +1 -1
- package/dist/schemas/personas.js +9 -0
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/providers/plan-limits.d.ts +140 -0
- package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
- package/dist/schemas/providers/plan-limits.js +47 -1
- package/dist/schemas/providers/plan-limits.js.map +1 -1
- package/dist/schemas/providers/provider-oauth.d.ts +57 -0
- package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
- package/dist/schemas/providers/provider-oauth.js +6 -1
- package/dist/schemas/providers/provider-oauth.js.map +1 -1
- package/dist/schemas/settings-history.d.ts +28 -1
- package/dist/schemas/settings-history.d.ts.map +1 -1
- package/dist/schemas/settings-history.js +35 -1
- package/dist/schemas/settings-history.js.map +1 -1
- package/dist/schemas/settings.d.ts +184 -4
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +31 -23
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/speaker.d.ts +36 -0
- package/dist/schemas/speaker.d.ts.map +1 -0
- package/dist/schemas/speaker.js +62 -0
- package/dist/schemas/speaker.js.map +1 -0
- package/dist/schemas/state-plan.d.ts +46 -0
- package/dist/schemas/state-plan.d.ts.map +1 -0
- package/dist/schemas/state-plan.js +31 -0
- package/dist/schemas/state-plan.js.map +1 -0
- package/dist/schemas/system.d.ts +48 -8
- package/dist/schemas/system.d.ts.map +1 -1
- package/dist/schemas/system.js +10 -14
- package/dist/schemas/system.js.map +1 -1
- package/dist/schemas/workspace/mainline.d.ts +206 -64
- package/dist/schemas/workspace/mainline.d.ts.map +1 -1
- package/dist/schemas/workspace/mainline.js +73 -25
- package/dist/schemas/workspace/mainline.js.map +1 -1
- package/dist/state/contract-lock.d.ts +1 -0
- package/dist/state/contract-lock.d.ts.map +1 -1
- package/dist/state/contract-lock.js +47 -1
- package/dist/state/contract-lock.js.map +1 -1
- package/dist/state/definition.d.ts +24 -16
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/fix-stance.d.ts +1 -1
- package/dist/state/fix-stance.d.ts.map +1 -1
- package/dist/state/fix-stance.js +2 -1
- package/dist/state/fix-stance.js.map +1 -1
- package/dist/state/history-state.d.ts.map +1 -1
- package/dist/state/history-state.js +2 -0
- package/dist/state/history-state.js.map +1 -1
- package/dist/state/landed-commit.d.ts +1 -0
- package/dist/state/landed-commit.d.ts.map +1 -1
- package/dist/state/landed-commit.js +2 -0
- package/dist/state/landed-commit.js.map +1 -1
- package/dist/state/red-streak.d.ts +7 -0
- package/dist/state/red-streak.d.ts.map +1 -0
- package/dist/state/red-streak.js +11 -0
- package/dist/state/red-streak.js.map +1 -0
- package/dist/state/workspace-state.d.ts +1 -0
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +6 -2
- package/dist/state/workspace-state.js.map +1 -1
- package/dist/text/shell-regions.d.ts +1 -0
- package/dist/text/shell-regions.d.ts.map +1 -1
- package/dist/text/shell-regions.js +1 -1
- package/dist/text/shell-regions.js.map +1 -1
- package/dist/text/transcript-fold.d.ts.map +1 -1
- package/dist/text/transcript-fold.js +14 -7
- package/dist/text/transcript-fold.js.map +1 -1
- package/package.json +28 -29
- package/src/chores/index.ts +0 -1
- package/src/contracts/agent.contract.ts +14 -0
- package/src/contracts/capabilities.contract.ts +2 -2
- package/src/contracts/device.contract.ts +5 -3
- package/src/contracts/secrets.contract.ts +2 -0
- package/src/contracts/settings.contract.ts +2 -1
- package/src/documents/conversions.ts +3 -3
- package/src/documents/index.ts +3 -1
- package/src/documents/read.ts +114 -0
- package/src/events/agent-events.ts +5 -0
- package/src/events/child-run.test.ts +81 -0
- package/src/events/child-run.ts +73 -0
- package/src/events/errands.test.ts +22 -0
- package/src/events/errands.ts +27 -0
- package/src/events/requests.ts +40 -1
- package/src/events/transcript.ts +8 -0
- package/src/front/browser-wire.ts +20 -0
- package/src/front/front-wire.ts +15 -0
- package/src/front/generated/browser-wire.json +138 -0
- package/src/front/generated/browser-wire.ts +16 -0
- package/src/front/generated/front-wire.json +793 -0
- package/src/front/generated/tunnel.json +38 -0
- package/src/front/generated/wire.ts +21 -24
- package/src/front/wire-manifests.test.ts +61 -0
- package/src/ids/conversation-ids.ts +6 -5
- package/src/ids/session-names.ts +7 -0
- package/src/index.ts +8 -1
- package/src/models/agent-catalog.test.ts +6 -4
- package/src/models/agent-catalog.ts +4 -6
- package/src/models/agent-runtimes.ts +22 -7
- package/src/models/capability-ledger.test.ts +2 -0
- package/src/models/plan-pools.test.ts +121 -2
- package/src/models/plan-pools.ts +152 -2
- package/src/policy/request-status.ts +4 -12
- package/src/policy/reserved-servers.test.ts +6 -0
- package/src/policy/reserved-servers.ts +13 -10
- package/src/policy/turned-away.ts +3 -0
- package/src/protocol/edge-verdict.ts +13 -11
- package/src/protocol/ingress-contract.fixture.json +13 -0
- package/src/protocol/ingress-contract.ts +9 -5
- package/src/protocol/raw-routes.ts +10 -21
- package/src/protocol/route-meta.ts +36 -1
- package/src/protocol/tunnel-bulk.test.ts +37 -0
- package/src/protocol/tunnel-bulk.ts +7 -0
- package/src/protocol/x402.test.ts +29 -0
- package/src/protocol/x402.ts +61 -0
- package/src/schemas/agent.ts +28 -3
- package/src/schemas/agents.ts +32 -6
- package/src/schemas/automations.ts +4 -2
- package/src/schemas/devices.ts +106 -39
- package/src/schemas/extension-updates.ts +6 -0
- package/src/schemas/hosts.ts +62 -19
- package/src/schemas/ic-shape-args.test.ts +64 -0
- package/src/schemas/keep-warm.test.ts +6 -13
- package/src/schemas/keep-warm.ts +15 -20
- package/src/schemas/metrics.ts +26 -3
- package/src/schemas/personas.ts +15 -0
- package/src/schemas/providers/plan-limits.ts +71 -1
- package/src/schemas/providers/provider-oauth.ts +10 -1
- package/src/schemas/settings-history.ts +50 -3
- package/src/schemas/settings.test.ts +54 -1
- package/src/schemas/settings.ts +49 -31
- package/src/schemas/speaker.ts +89 -0
- package/src/schemas/state-plan.test.ts +69 -0
- package/src/schemas/state-plan.ts +47 -0
- package/src/schemas/system.ts +20 -16
- package/src/schemas/workspace/mainline.test.ts +28 -0
- package/src/schemas/workspace/mainline.ts +111 -44
- package/src/state/contract-lock.test.ts +65 -4
- package/src/state/contract-lock.ts +70 -2
- package/src/state/fix-stance.test.ts +8 -0
- package/src/state/fix-stance.ts +3 -3
- package/src/state/history-state.ts +5 -1
- package/src/state/landed-commit.test.ts +12 -1
- package/src/state/landed-commit.ts +5 -0
- package/src/state/red-streak.test.ts +28 -0
- package/src/state/red-streak.ts +28 -0
- package/src/state/workspace-state.test.ts +7 -1
- package/src/state/workspace-state.ts +10 -2
- package/src/text/shell-regions.test.ts +38 -0
- package/src/text/shell-regions.ts +3 -3
- package/src/text/transcript-fold.test.ts +13 -0
- package/src/text/transcript-fold.ts +17 -8
- package/dist/chores/fix-deps.d.ts +0 -10
- package/dist/chores/fix-deps.d.ts.map +0 -1
- package/dist/chores/fix-deps.js +0 -19
- package/dist/chores/fix-deps.js.map +0 -1
- package/dist/front/terminal-frames.d.ts +0 -17
- package/dist/front/terminal-frames.d.ts.map +0 -1
- package/dist/front/terminal-frames.js +0 -79
- package/dist/front/terminal-frames.js.map +0 -1
- package/dist/protocol/tunnel-lanes.d.ts +0 -10
- package/dist/protocol/tunnel-lanes.d.ts.map +0 -1
- package/dist/protocol/tunnel-lanes.js +0 -16
- package/dist/protocol/tunnel-lanes.js.map +0 -1
- package/dist/protocol/upgrade-relay.d.ts +0 -4
- package/dist/protocol/upgrade-relay.d.ts.map +0 -1
- package/dist/protocol/upgrade-relay.js +0 -25
- package/dist/protocol/upgrade-relay.js.map +0 -1
- package/src/chores/fix-deps.ts +0 -23
- package/src/front/terminal-frames.fixture.json +0 -55
- package/src/front/terminal-frames.test.ts +0 -63
- package/src/front/terminal-frames.ts +0 -102
- package/src/protocol/tunnel-lanes.json +0 -136
- package/src/protocol/tunnel-lanes.test.ts +0 -30
- package/src/protocol/tunnel-lanes.ts +0 -32
- package/src/protocol/upgrade-relay.ts +0 -28
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { heredocBodies } from "./shell-regions.js";
|
|
2
|
+
|
|
3
|
+
// The one heredoc scan the policy classifier and the daemon's command readers share, pinned by exact offset.
|
|
4
|
+
|
|
5
|
+
const bodiesOf = (command: string): string[] => heredocBodies(command).map(({ start, end }) => command.slice(start, end));
|
|
6
|
+
|
|
7
|
+
test("a body starts on the line after its opener, not at the newline, and ends where its terminator's line starts", () => {
|
|
8
|
+
expect(heredocBodies("cat <<EOF\nx\nEOF")).toEqual([{ start: 10, end: 12 }]);
|
|
9
|
+
const command = "cat > f <<'EOF'\nline one\nline two\nEOF\nls";
|
|
10
|
+
expect(heredocBodies(command)).toEqual([{ start: command.indexOf("line one"), end: command.indexOf("EOF\nls") }]);
|
|
11
|
+
expect(bodiesOf(command)).toEqual(["line one\nline two\n"]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("`<<` ends only at a terminator in the first column: an indented one is body, as bash reads it", () => {
|
|
15
|
+
const command = "cat <<EOF\n x\n EOF\n\tEOF\nrm -rf /";
|
|
16
|
+
expect(heredocBodies(command)).toEqual([{ start: 10, end: command.length }]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("`<<-` ends at a tab-indented terminator", () => {
|
|
20
|
+
const command = "cat <<-EOF\n\tx\n\tEOF\nls";
|
|
21
|
+
expect(heredocBodies(command)).toEqual([{ start: 11, end: 14 }]);
|
|
22
|
+
expect(bodiesOf(command)).toEqual(["\tx\n"]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("the terminator is the whole word on its line, quoted delimiters included", () => {
|
|
26
|
+
expect(bodiesOf("cat <<EOF\nEOFX\nxEOF\nEOF\nls")).toEqual(["EOFX\nxEOF\n"]);
|
|
27
|
+
expect(bodiesOf(`cat <<'END'\n$HOME\nEND`)).toEqual(["$HOME\n"]);
|
|
28
|
+
expect(bodiesOf(`cat <<"END"\n$HOME\nEND`)).toEqual(["$HOME\n"]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("an unterminated body runs to the end of the command, and an opener with no line after it has none", () => {
|
|
32
|
+
expect(heredocBodies("cat <<'EOF'\nrm -rf /")).toEqual([{ start: 12, end: 20 }]);
|
|
33
|
+
expect(heredocBodies("cat <<EOF")).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("every heredoc in the command is found, in order", () => {
|
|
37
|
+
expect(bodiesOf("cat <<A >a\n1\nA\ncat <<-B >b\n\t2\n\tB\nls")).toEqual(["1\n", "\t2\n"]);
|
|
38
|
+
});
|
|
@@ -30,9 +30,8 @@ const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
|
|
|
30
30
|
// `<<EOF`, `<<-EOF`, quoted or not; the delimiter's quoting only affects expansion, not classification here.
|
|
31
31
|
const HEREDOC_OPEN = /<<-?\s*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/g;
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
const heredocBodies = (command: string): CommandSpan[] => {
|
|
33
|
+
// Heredoc bodies in order, each from the line after its opener to its terminator's line; as in bash, only `<<-` indents that.
|
|
34
|
+
export const heredocBodies = (command: string): CommandSpan[] => {
|
|
36
35
|
const bodies: CommandSpan[] = [];
|
|
37
36
|
for (const open of command.matchAll(HEREDOC_OPEN)) {
|
|
38
37
|
const indented = command.slice(open.index, open.index + 3).startsWith("<<-");
|
|
@@ -158,6 +157,7 @@ const scanWords = (command: string, skip: readonly CommandSpan[]): ShellWord[] =
|
|
|
158
157
|
// Unsorted and possibly overlapping; callers only ask containment of them. Computed once per command by the classifier
|
|
159
158
|
// and shared across every table.
|
|
160
159
|
export const inertRegions = (command: string): CommandSpan[] => {
|
|
160
|
+
// First, in a pass of their own: a body can hold anything, and an odd quote count in it would desync the word scanner.
|
|
161
161
|
const bodies = heredocBodies(command);
|
|
162
162
|
const regions: CommandSpan[] = [...bodies];
|
|
163
163
|
const words = scanWords(command, bodies);
|
|
@@ -43,6 +43,19 @@ describe("foldTurn", () => {
|
|
|
43
43
|
]);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
// The sandbox's composed words (a land's breakage sent back into the live turn) are not the owner's: the row says who
|
|
47
|
+
// spoke them and what for, and a person's steer carries neither.
|
|
48
|
+
it("writes the sandbox's steer down with its speaker and errand, and a person's with neither", () => {
|
|
49
|
+
const events: AgentEvent[] = [
|
|
50
|
+
{ kind: "steer", text: "the land broke main", sentAt: SENT_AT + 1, voice: "sandbox", errand: "land-breakage" },
|
|
51
|
+
{ kind: "steer", text: "and the docs", sentAt: SENT_AT + 2 },
|
|
52
|
+
];
|
|
53
|
+
expect(foldOf("ship it", events).slice(1)).toEqual([
|
|
54
|
+
{ role: "user", text: "the land broke main", sentAt: SENT_AT + 1, speaker: { kind: "sandbox" }, errand: "land-breakage" },
|
|
55
|
+
{ role: "user", text: "and the docs", sentAt: SENT_AT + 2 },
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
|
|
46
59
|
it("does not retire a bubble that has written no prose", () => {
|
|
47
60
|
const events: AgentEvent[] = [
|
|
48
61
|
{ kind: "tool_call", id: "t1", name: "Read", category: "read", status: "completed" },
|
|
@@ -129,7 +129,7 @@ const undelivered = (unattended: boolean): string =>
|
|
|
129
129
|
const memoryPress = (event: Extract<AgentEvent, { kind: "error" }>): "sendAnyway" | "sandboxMemory" =>
|
|
130
130
|
event.memory === undefined ? "sendAnyway" : "sandboxMemory";
|
|
131
131
|
|
|
132
|
-
// A memory hold is asked once and never again that spell (
|
|
132
|
+
// A memory hold is asked once and never again that spell (resource-budget.ts), so the next send always runs. A turn the
|
|
133
133
|
// sandbox started itself (a fix press, a peer's message, a re-run) was never in a composer: its message stays above, and
|
|
134
134
|
// the press asks the sandbox to run the turn it kept rather than sending a queue that holds nothing.
|
|
135
135
|
const heldRow = (event: Extract<AgentEvent, { kind: "error" }>): TranscriptRow => {
|
|
@@ -455,13 +455,22 @@ export class TranscriptFold {
|
|
|
455
455
|
return this.pushRow(unspoken);
|
|
456
456
|
}
|
|
457
457
|
// A steer also closes the bubble, or the next answer would print over it mid-call.
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
458
|
+
const row: TranscriptRow = { role: "user", text: event.text, sentAt: event.sentAt };
|
|
459
|
+
if (event.attachments !== undefined) {
|
|
460
|
+
row.attachments = [...event.attachments];
|
|
461
|
+
}
|
|
462
|
+
if (event.messageId !== undefined) {
|
|
463
|
+
row.messageId = event.messageId;
|
|
464
|
+
}
|
|
465
|
+
// The sandbox's own words say so on the row, so a reader never shows them as the owner's; an agent's words
|
|
466
|
+
// come as their own card (agentWords), which names the agent.
|
|
467
|
+
if (event.voice === "sandbox") {
|
|
468
|
+
row.speaker = { kind: "sandbox" };
|
|
469
|
+
}
|
|
470
|
+
if (event.errand !== undefined) {
|
|
471
|
+
row.errand = event.errand;
|
|
472
|
+
}
|
|
473
|
+
const patches = this.pushRow(row);
|
|
465
474
|
// Anchors pair by position with the checkpoints only a person's steer reserves.
|
|
466
475
|
if (event.voice === undefined) {
|
|
467
476
|
this.steerRows.push(this.rows.length - 1);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const FIX_DEPS_AUTOMATION: {
|
|
2
|
-
readonly id: "fix-dependency-breakage";
|
|
3
|
-
readonly title: "Fix what a dependency change broke";
|
|
4
|
-
readonly event: "deps.broken";
|
|
5
|
-
readonly holdForSeconds: 60;
|
|
6
|
-
readonly guard: `test "$(printf '%s' "$AUTOMATION_PAYLOAD" | jq -r '.deps.attempt // 1')" -le 2`;
|
|
7
|
-
readonly guardNote: "stops after 2 attempts";
|
|
8
|
-
readonly prompt: string;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=fix-deps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix-deps.d.ts","sourceRoot":"","sources":["../../src/chores/fix-deps.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;aAC5B,EAAE,EAAE,yBAAyB;aAC7B,KAAK,EAAE,oCAAoC;aAC3C,KAAK,EAAE,aAAa;aACpB,cAAc,EAAE,EAAE;aAClB,KAAK,EAAE,gFAAgF;aACvF,SAAS,EAAE,wBAAwB;aACnC,MAAM;CAWA,CAAC"}
|
package/dist/chores/fix-deps.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const FIX_DEPS_AUTOMATION = {
|
|
2
|
-
id: "fix-dependency-breakage",
|
|
3
|
-
title: "Fix what a dependency change broke",
|
|
4
|
-
event: "deps.broken",
|
|
5
|
-
holdForSeconds: 60,
|
|
6
|
-
guard: `test "$(printf '%s' "$AUTOMATION_PAYLOAD" | jq -r '.deps.attempt // 1')" -le 2`,
|
|
7
|
-
guardNote: "stops after 2 attempts",
|
|
8
|
-
prompt: "A landed change drifted this workspace's dependencies; the daemon reinstalled them and ran the project's own checks, " +
|
|
9
|
-
"and they failed. The payload names the project (`deps.project`), the check command (`deps.command`), how it exited " +
|
|
10
|
-
"(`deps.exitCode`) and the tail of its output (`deps.logTail`); the full log is in the project's `--verify` terminal.\n\n" +
|
|
11
|
-
"Re-run only what failed to see it first-hand (the failing package's tests or typecheck, not the whole check command), then fix the ROOT CAUSE. That usually means updating call " +
|
|
12
|
-
"sites, types or tests to match what actually changed: never loosening or deleting the checks, pinning or downgrading " +
|
|
13
|
-
"dependencies just to silence them, or editing generated files. If the breakage needs a decision only the owner can " +
|
|
14
|
-
"make (an intentional breaking upgrade, a license change, a dependency that should be dropped), stop and say exactly " +
|
|
15
|
-
"that instead of guessing.\n\n" +
|
|
16
|
-
"Finish by re-running what failed and reporting what was broken, what you changed, and whether it passes now; the " +
|
|
17
|
-
"daemon runs the whole check again once your fix lands.",
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=fix-deps.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fix-deps.js","sourceRoot":"","sources":["../../src/chores/fix-deps.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,EAAE,EAAE,yBAAyB;IAC7B,KAAK,EAAE,oCAAoC;IAC3C,KAAK,EAAE,aAAa;IACpB,cAAc,EAAE,EAAE;IAClB,KAAK,EAAE,gFAAgF;IACvF,SAAS,EAAE,wBAAwB;IACnC,MAAM,EACF,uHAAuH;QACvH,qHAAqH;QACrH,0HAA0H;QAC1H,kLAAkL;QAClL,uHAAuH;QACvH,qHAAqH;QACrH,sHAAsH;QACtH,+BAA+B;QAC/B,mHAAmH;QACnH,wDAAwD;CACtD,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { TerminalUpgrade } from "./generated/wire.js";
|
|
2
|
-
export declare const TERMINAL_UPGRADE: TerminalUpgrade;
|
|
3
|
-
export declare const WEBTRANSPORT_PATH = "/system/transport";
|
|
4
|
-
export type TerminalFrame = {
|
|
5
|
-
readonly kind: "pane" | "ping" | "pong";
|
|
6
|
-
readonly bytes: Uint8Array;
|
|
7
|
-
} | {
|
|
8
|
-
readonly kind: "message";
|
|
9
|
-
readonly text: string;
|
|
10
|
-
} | {
|
|
11
|
-
readonly kind: "close";
|
|
12
|
-
readonly code?: number;
|
|
13
|
-
readonly reason: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const encodeTerminalFrame: (frame: TerminalFrame) => Uint8Array;
|
|
16
|
-
export declare const terminalFrameReader: (maxBytes: number) => ((chunk: Uint8Array) => TerminalFrame[]);
|
|
17
|
-
//# sourceMappingURL=terminal-frames.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-frames.d.ts","sourceRoot":"","sources":["../../src/front/terminal-frames.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,eAAO,MAAM,gBAAgB,EAAE,eAAqC,CAAC;AAIrE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAOrD,MAAM,MAAM,aAAa,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAEnD;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAwBlF,eAAO,MAAM,mBAAmB,UAAW,aAAa,KAAG,UAO1D,CAAC;AAuBF,eAAO,MAAM,mBAAmB,aAAc,MAAM,KAAG,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,aAAa,EAAE,CA2B7F,CAAC"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export const TERMINAL_UPGRADE = "intentic-terminal";
|
|
2
|
-
export const WEBTRANSPORT_PATH = "/system/transport";
|
|
3
|
-
const HEADER_BYTES = 5;
|
|
4
|
-
const KINDS = ["pane", "message", "close", "ping", "pong"];
|
|
5
|
-
const utf8 = new TextEncoder();
|
|
6
|
-
const strictUtf8 = new TextDecoder("utf-8", { fatal: true });
|
|
7
|
-
const payloadOf = (frame) => {
|
|
8
|
-
switch (frame.kind) {
|
|
9
|
-
case "message":
|
|
10
|
-
return utf8.encode(frame.text);
|
|
11
|
-
case "close": {
|
|
12
|
-
if (frame.code === undefined) {
|
|
13
|
-
return new Uint8Array(0);
|
|
14
|
-
}
|
|
15
|
-
const reason = utf8.encode(frame.reason);
|
|
16
|
-
const payload = new Uint8Array(2 + reason.length);
|
|
17
|
-
new DataView(payload.buffer).setUint16(0, frame.code);
|
|
18
|
-
payload.set(reason, 2);
|
|
19
|
-
return payload;
|
|
20
|
-
}
|
|
21
|
-
default:
|
|
22
|
-
return frame.bytes;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
export const encodeTerminalFrame = (frame) => {
|
|
26
|
-
const payload = payloadOf(frame);
|
|
27
|
-
const encoded = new Uint8Array(HEADER_BYTES + payload.length);
|
|
28
|
-
encoded[0] = KINDS.indexOf(frame.kind);
|
|
29
|
-
new DataView(encoded.buffer).setUint32(1, payload.length);
|
|
30
|
-
encoded.set(payload, HEADER_BYTES);
|
|
31
|
-
return encoded;
|
|
32
|
-
};
|
|
33
|
-
const frameOf = (kind, payload) => {
|
|
34
|
-
switch (kind) {
|
|
35
|
-
case "message":
|
|
36
|
-
return { kind, text: strictUtf8.decode(payload) };
|
|
37
|
-
case "close": {
|
|
38
|
-
if (payload.length === 0) {
|
|
39
|
-
return { kind, reason: "" };
|
|
40
|
-
}
|
|
41
|
-
if (payload.length < 2) {
|
|
42
|
-
throw new Error("a close frame's code is two bytes");
|
|
43
|
-
}
|
|
44
|
-
const code = new DataView(payload.buffer, payload.byteOffset, 2).getUint16(0);
|
|
45
|
-
return { kind, code, reason: strictUtf8.decode(payload.subarray(2)) };
|
|
46
|
-
}
|
|
47
|
-
default:
|
|
48
|
-
return { kind, bytes: payload };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
export const terminalFrameReader = (maxBytes) => {
|
|
52
|
-
let pending = new Uint8Array(0);
|
|
53
|
-
return (chunk) => {
|
|
54
|
-
const joined = new Uint8Array(pending.length + chunk.length);
|
|
55
|
-
joined.set(pending);
|
|
56
|
-
joined.set(chunk, pending.length);
|
|
57
|
-
const view = new DataView(joined.buffer);
|
|
58
|
-
const frames = [];
|
|
59
|
-
let at = 0;
|
|
60
|
-
while (joined.length - at >= HEADER_BYTES) {
|
|
61
|
-
const kind = KINDS[joined[at] ?? KINDS.length];
|
|
62
|
-
if (kind === undefined) {
|
|
63
|
-
throw new Error(`no terminal frame is of kind ${joined[at]}`);
|
|
64
|
-
}
|
|
65
|
-
const length = view.getUint32(at + 1);
|
|
66
|
-
if (length > maxBytes) {
|
|
67
|
-
throw new Error(`a terminal frame of ${length} bytes is past ${maxBytes}`);
|
|
68
|
-
}
|
|
69
|
-
if (joined.length - at - HEADER_BYTES < length) {
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
frames.push(frameOf(kind, joined.subarray(at + HEADER_BYTES, at + HEADER_BYTES + length)));
|
|
73
|
-
at += HEADER_BYTES + length;
|
|
74
|
-
}
|
|
75
|
-
pending = joined.slice(at);
|
|
76
|
-
return frames;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=terminal-frames.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-frames.js","sourceRoot":"","sources":["../../src/front/terminal-frames.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type TunnelLane = "interactive" | "bulk";
|
|
2
|
-
export declare const INGRESS_LANE_HEADER = "x-intentic-lane";
|
|
3
|
-
export declare const tunnelLaneNamed: (header: string | string[] | undefined) => TunnelLane;
|
|
4
|
-
export declare const tunnelLaneOf: (host: string, method: string, path: string) => TunnelLane;
|
|
5
|
-
export declare const tunnelLaneTable: () => {
|
|
6
|
-
readonly method: string;
|
|
7
|
-
readonly path: string;
|
|
8
|
-
readonly lane: TunnelLane;
|
|
9
|
-
}[];
|
|
10
|
-
//# sourceMappingURL=tunnel-lanes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-lanes.d.ts","sourceRoot":"","sources":["../../src/protocol/tunnel-lanes.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,MAAM,CAAC;AAGhD,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,eAAO,MAAM,eAAe,WAAY,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,KAAG,UAA0D,CAAC;AAInI,eAAO,MAAM,YAAY,SAAU,MAAM,UAAU,MAAM,QAAQ,MAAM,KAAG,UAOzE,CAAC;AAIF,eAAO,MAAM,eAAe,QAAO;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,EACR,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { sandboxSubdomain } from "../ids/hostnames.js";
|
|
2
|
-
import { hostOwnerId } from "./ingress-contract.js";
|
|
3
|
-
import { RAW_ROUTE_LIST } from "./raw-routes.js";
|
|
4
|
-
import { servedRoute } from "./routes.js";
|
|
5
|
-
export const INGRESS_LANE_HEADER = "x-intentic-lane";
|
|
6
|
-
export const tunnelLaneNamed = (header) => (header === "bulk" ? "bulk" : "interactive");
|
|
7
|
-
export const tunnelLaneOf = (host, method, path) => {
|
|
8
|
-
const id = hostOwnerId(host);
|
|
9
|
-
const label = host.split(":")[0]?.split(".")[0] ?? "";
|
|
10
|
-
if (id === undefined || label !== sandboxSubdomain(id)) {
|
|
11
|
-
return "bulk";
|
|
12
|
-
}
|
|
13
|
-
return servedRoute(RAW_ROUTE_LIST, [], method, path)?.meta.lane ?? "interactive";
|
|
14
|
-
};
|
|
15
|
-
export const tunnelLaneTable = () => RAW_ROUTE_LIST.map(({ method, path, meta }) => ({ method, path, lane: meta.lane ?? "interactive" }));
|
|
16
|
-
//# sourceMappingURL=tunnel-lanes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-lanes.js","sourceRoot":"","sources":["../../src/protocol/tunnel-lanes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAU1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqC,EAAc,EAAE,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;AAInI,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,MAAc,EAAE,IAAY,EAAc,EAAE;IACnF,MAAM,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACtD,IAAI,EAAE,KAAK,SAAS,IAAI,KAAK,KAAK,gBAAgB,CAAC,EAAE,CAAC,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,OAAO,WAAW,CAAC,cAAc,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,IAAI,aAAa,CAAC;AACrF,CAAC,CAAC;AAIF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAoF,EAAE,CACjH,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-relay.d.ts","sourceRoot":"","sources":["../../src/protocol/upgrade-relay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,eAAO,MAAM,YAAY,aAAc,aAAa,UAAU,MAAM,QAAQ,MAAM,KAAG,IAuBpF,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const relayUpgrade = (upstream, socket, head) => {
|
|
2
|
-
upstream.on("error", () => socket.destroy());
|
|
3
|
-
upstream.on("response", (answer) => {
|
|
4
|
-
socket.end(`HTTP/1.1 ${answer.statusCode ?? 502} ${answer.statusMessage ?? ""}\r\n\r\n`);
|
|
5
|
-
});
|
|
6
|
-
upstream.on("upgrade", (answer, upstreamSocket, upstreamHead) => {
|
|
7
|
-
const lines = [];
|
|
8
|
-
for (let index = 0; index < answer.rawHeaders.length; index += 2) {
|
|
9
|
-
lines.push(`${answer.rawHeaders[index]}: ${answer.rawHeaders[index + 1]}`);
|
|
10
|
-
}
|
|
11
|
-
socket.write(`HTTP/1.1 101 Switching Protocols\r\n${lines.join("\r\n")}\r\n\r\n`);
|
|
12
|
-
if (upstreamHead.length > 0) {
|
|
13
|
-
socket.write(upstreamHead);
|
|
14
|
-
}
|
|
15
|
-
if (head.length > 0) {
|
|
16
|
-
upstreamSocket.write(head);
|
|
17
|
-
}
|
|
18
|
-
upstreamSocket.on("error", () => socket.destroy());
|
|
19
|
-
socket.on("error", () => upstreamSocket.destroy());
|
|
20
|
-
upstreamSocket.pipe(socket);
|
|
21
|
-
socket.pipe(upstreamSocket);
|
|
22
|
-
});
|
|
23
|
-
upstream.end();
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=upgrade-relay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-relay.js","sourceRoot":"","sources":["../../src/protocol/upgrade-relay.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAuB,EAAE,MAAc,EAAE,IAAY,EAAQ,EAAE;IACxF,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE;QAC/B,MAAM,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,UAAU,IAAI,GAAG,IAAI,MAAM,CAAC,aAAa,IAAI,EAAE,UAAU,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,EAAE;QAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAC/D,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,uCAAuC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAClF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClB,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC;AACnB,CAAC,CAAC"}
|
package/src/chores/fix-deps.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Automations catalogue template for repairing dependency breakage; nothing creates it until the owner picks it. Wakes
|
|
2
|
-
// on `deps.broken`, whose payload carries `deps.project`, `deps.command`, `deps.exitCode`, `deps.logTail` and
|
|
3
|
-
// `deps.attempt` (consecutive reds since the last green). Once created, each fire holds for `holdForSeconds` before
|
|
4
|
-
// starting, cancellable, never while another agent is mid-turn.
|
|
5
|
-
export const FIX_DEPS_AUTOMATION = {
|
|
6
|
-
id: "fix-dependency-breakage",
|
|
7
|
-
title: "Fix what a dependency change broke",
|
|
8
|
-
event: "deps.broken",
|
|
9
|
-
holdForSeconds: 60,
|
|
10
|
-
guard: `test "$(printf '%s' "$AUTOMATION_PAYLOAD" | jq -r '.deps.attempt // 1')" -le 2`,
|
|
11
|
-
guardNote: "stops after 2 attempts",
|
|
12
|
-
prompt:
|
|
13
|
-
"A landed change drifted this workspace's dependencies; the daemon reinstalled them and ran the project's own checks, " +
|
|
14
|
-
"and they failed. The payload names the project (`deps.project`), the check command (`deps.command`), how it exited " +
|
|
15
|
-
"(`deps.exitCode`) and the tail of its output (`deps.logTail`); the full log is in the project's `--verify` terminal.\n\n" +
|
|
16
|
-
"Re-run only what failed to see it first-hand (the failing package's tests or typecheck, not the whole check command), then fix the ROOT CAUSE. That usually means updating call " +
|
|
17
|
-
"sites, types or tests to match what actually changed: never loosening or deleting the checks, pinning or downgrading " +
|
|
18
|
-
"dependencies just to silence them, or editing generated files. If the breakage needs a decision only the owner can " +
|
|
19
|
-
"make (an intentional breaking upgrade, a license change, a dependency that should be dropped), stop and say exactly " +
|
|
20
|
-
"that instead of guessing.\n\n" +
|
|
21
|
-
"Finish by re-running what failed and reporting what was broken, what you changed, and whether it passes now; the " +
|
|
22
|
-
"daemon runs the whole check again once your fix lands.",
|
|
23
|
-
} as const;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"session": "/system/transport",
|
|
3
|
-
"upgrade": "intentic-terminal",
|
|
4
|
-
"frames": [
|
|
5
|
-
{
|
|
6
|
-
"encoded": "00000000081b5b33316d68c3a9",
|
|
7
|
-
"frame": {
|
|
8
|
-
"kind": "pane",
|
|
9
|
-
"bytes": "1b5b33316d68c3a9"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"encoded": "010000001c7b2274797065223a22696e707574222c2264617461223a22c582227d",
|
|
14
|
-
"frame": {
|
|
15
|
-
"kind": "message",
|
|
16
|
-
"text": "{\"type\":\"input\",\"data\":\"ł\"}"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"encoded": "020000001703f0617574686f72697a6174696f6e207265766f6b6564",
|
|
21
|
-
"frame": {
|
|
22
|
-
"kind": "close",
|
|
23
|
-
"code": 1008,
|
|
24
|
-
"reason": "authorization revoked"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"encoded": "0200000000",
|
|
29
|
-
"frame": {
|
|
30
|
-
"kind": "close",
|
|
31
|
-
"reason": ""
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"encoded": "0300000000",
|
|
36
|
-
"frame": {
|
|
37
|
-
"kind": "ping",
|
|
38
|
-
"bytes": ""
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"encoded": "040000000101",
|
|
43
|
-
"frame": {
|
|
44
|
-
"kind": "pong",
|
|
45
|
-
"bytes": "01"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
"unreadable": [
|
|
50
|
-
"0500000000",
|
|
51
|
-
"01ffffffff",
|
|
52
|
-
"020000000103",
|
|
53
|
-
"0100000002c328"
|
|
54
|
-
]
|
|
55
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { TERMINAL_UPGRADE, type TerminalFrame, WEBTRANSPORT_PATH, encodeTerminalFrame, terminalFrameReader } from "./terminal-frames.js";
|
|
3
|
-
|
|
4
|
-
interface FixtureFrame {
|
|
5
|
-
readonly kind: TerminalFrame["kind"];
|
|
6
|
-
readonly bytes?: string;
|
|
7
|
-
readonly text?: string;
|
|
8
|
-
readonly code?: number;
|
|
9
|
-
readonly reason?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const FIXTURE = JSON.parse(readFileSync(new URL("./terminal-frames.fixture.json", import.meta.url), "utf8")) as {
|
|
13
|
-
session: string;
|
|
14
|
-
upgrade: string;
|
|
15
|
-
frames: { encoded: string; frame: FixtureFrame }[];
|
|
16
|
-
unreadable: string[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const hex = (value: string): Uint8Array => Uint8Array.from(value.match(/../g) ?? [], (pair) => Number.parseInt(pair, 16));
|
|
20
|
-
|
|
21
|
-
const frameOf = ({ kind, bytes, text, code, reason }: FixtureFrame): TerminalFrame => {
|
|
22
|
-
if (kind === "message") {
|
|
23
|
-
return { kind, text: text ?? "" };
|
|
24
|
-
}
|
|
25
|
-
if (kind === "close") {
|
|
26
|
-
return code === undefined ? { kind, reason: reason ?? "" } : { kind, code, reason: reason ?? "" };
|
|
27
|
-
}
|
|
28
|
-
return { kind, bytes: hex(bytes ?? "") };
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const MAX = 16 * 1024 * 1024;
|
|
32
|
-
|
|
33
|
-
test("the session's path and the upgrade are the ones the edge and the front answer", () => {
|
|
34
|
-
expect(FIXTURE.session).toBe(WEBTRANSPORT_PATH);
|
|
35
|
-
expect(FIXTURE.upgrade).toBe(TERMINAL_UPGRADE);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("every frame the shared fixture names encodes to its bytes and reads back", () => {
|
|
39
|
-
expect(FIXTURE.frames.length).toBeGreaterThan(5);
|
|
40
|
-
for (const { encoded, frame } of FIXTURE.frames) {
|
|
41
|
-
expect(encodeTerminalFrame(frameOf(frame))).toEqual(hex(encoded));
|
|
42
|
-
expect(terminalFrameReader(MAX)(hex(encoded))).toEqual([frameOf(frame)]);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("frames read the same however the stream's chunks cut them", () => {
|
|
47
|
-
const whole = hex(FIXTURE.frames.map(({ encoded }) => encoded).join(""));
|
|
48
|
-
const expected = FIXTURE.frames.map(({ frame }) => frameOf(frame));
|
|
49
|
-
for (const size of [1, 2, 3, 7, whole.length]) {
|
|
50
|
-
const read = terminalFrameReader(MAX);
|
|
51
|
-
const frames: TerminalFrame[] = [];
|
|
52
|
-
for (let at = 0; at < whole.length; at += size) {
|
|
53
|
-
frames.push(...read(whole.slice(at, at + size)));
|
|
54
|
-
}
|
|
55
|
-
expect(frames).toEqual(expected);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("a frame no front sends ends the stream", () => {
|
|
60
|
-
for (const encoded of FIXTURE.unreadable) {
|
|
61
|
-
expect(() => terminalFrameReader(MAX)(hex(encoded))).toThrow();
|
|
62
|
-
}
|
|
63
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// A terminal's messages on a stream no WebSocket rides (a WebTransport one): a kind byte, a big-endian u32 length, then
|
|
2
|
-
// that many bytes, one WebSocket message's worth each. The front's Rust codec reads the fixture this file's test reads.
|
|
3
|
-
|
|
4
|
-
import type { TerminalUpgrade } from "./generated/wire.js";
|
|
5
|
-
|
|
6
|
-
export const TERMINAL_UPGRADE: TerminalUpgrade = "intentic-terminal";
|
|
7
|
-
|
|
8
|
-
// Where a browser opens its WebTransport session, on the address of the sandbox the session's streams reach; the edge
|
|
9
|
-
// answers it, never the sandbox.
|
|
10
|
-
export const WEBTRANSPORT_PATH = "/system/transport";
|
|
11
|
-
|
|
12
|
-
const HEADER_BYTES = 5;
|
|
13
|
-
|
|
14
|
-
// Indexed by the kind byte.
|
|
15
|
-
const KINDS = ["pane", "message", "close", "ping", "pong"] as const;
|
|
16
|
-
|
|
17
|
-
export type TerminalFrame =
|
|
18
|
-
| { readonly kind: "pane" | "ping" | "pong"; readonly bytes: Uint8Array }
|
|
19
|
-
| { readonly kind: "message"; readonly text: string }
|
|
20
|
-
// No code is a close that names none, as a WebSocket's may.
|
|
21
|
-
| { readonly kind: "close"; readonly code?: number; readonly reason: string };
|
|
22
|
-
|
|
23
|
-
const utf8 = new TextEncoder();
|
|
24
|
-
const strictUtf8 = new TextDecoder("utf-8", { fatal: true });
|
|
25
|
-
|
|
26
|
-
const payloadOf = (frame: TerminalFrame): Uint8Array => {
|
|
27
|
-
switch (frame.kind) {
|
|
28
|
-
case "message":
|
|
29
|
-
return utf8.encode(frame.text);
|
|
30
|
-
case "close": {
|
|
31
|
-
if (frame.code === undefined) {
|
|
32
|
-
return new Uint8Array(0);
|
|
33
|
-
}
|
|
34
|
-
const reason = utf8.encode(frame.reason);
|
|
35
|
-
const payload = new Uint8Array(2 + reason.length);
|
|
36
|
-
new DataView(payload.buffer).setUint16(0, frame.code);
|
|
37
|
-
payload.set(reason, 2);
|
|
38
|
-
return payload;
|
|
39
|
-
}
|
|
40
|
-
default:
|
|
41
|
-
return frame.bytes;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const encodeTerminalFrame = (frame: TerminalFrame): Uint8Array => {
|
|
46
|
-
const payload = payloadOf(frame);
|
|
47
|
-
const encoded = new Uint8Array(HEADER_BYTES + payload.length);
|
|
48
|
-
encoded[0] = KINDS.indexOf(frame.kind);
|
|
49
|
-
new DataView(encoded.buffer).setUint32(1, payload.length);
|
|
50
|
-
encoded.set(payload, HEADER_BYTES);
|
|
51
|
-
return encoded;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const frameOf = (kind: (typeof KINDS)[number], payload: Uint8Array): TerminalFrame => {
|
|
55
|
-
switch (kind) {
|
|
56
|
-
case "message":
|
|
57
|
-
return { kind, text: strictUtf8.decode(payload) };
|
|
58
|
-
case "close": {
|
|
59
|
-
if (payload.length === 0) {
|
|
60
|
-
return { kind, reason: "" };
|
|
61
|
-
}
|
|
62
|
-
if (payload.length < 2) {
|
|
63
|
-
throw new Error("a close frame's code is two bytes");
|
|
64
|
-
}
|
|
65
|
-
const code = new DataView(payload.buffer, payload.byteOffset, 2).getUint16(0);
|
|
66
|
-
return { kind, code, reason: strictUtf8.decode(payload.subarray(2)) };
|
|
67
|
-
}
|
|
68
|
-
default:
|
|
69
|
-
return { kind, bytes: payload };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Whole frames out of a stream's chunks however the chunks cut them. Throws on a kind, a length past `maxBytes` or a
|
|
74
|
-
// payload no front sends, since nothing after it on the stream can be framed.
|
|
75
|
-
export const terminalFrameReader = (maxBytes: number): ((chunk: Uint8Array) => TerminalFrame[]) => {
|
|
76
|
-
let pending = new Uint8Array(0);
|
|
77
|
-
return (chunk) => {
|
|
78
|
-
const joined = new Uint8Array(pending.length + chunk.length);
|
|
79
|
-
joined.set(pending);
|
|
80
|
-
joined.set(chunk, pending.length);
|
|
81
|
-
const view = new DataView(joined.buffer);
|
|
82
|
-
const frames: TerminalFrame[] = [];
|
|
83
|
-
let at = 0;
|
|
84
|
-
while (joined.length - at >= HEADER_BYTES) {
|
|
85
|
-
const kind = KINDS[joined[at] ?? KINDS.length];
|
|
86
|
-
if (kind === undefined) {
|
|
87
|
-
throw new Error(`no terminal frame is of kind ${joined[at]}`);
|
|
88
|
-
}
|
|
89
|
-
const length = view.getUint32(at + 1);
|
|
90
|
-
if (length > maxBytes) {
|
|
91
|
-
throw new Error(`a terminal frame of ${length} bytes is past ${maxBytes}`);
|
|
92
|
-
}
|
|
93
|
-
if (joined.length - at - HEADER_BYTES < length) {
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
frames.push(frameOf(kind, joined.subarray(at + HEADER_BYTES, at + HEADER_BYTES + length)));
|
|
97
|
-
at += HEADER_BYTES + length;
|
|
98
|
-
}
|
|
99
|
-
pending = joined.slice(at);
|
|
100
|
-
return frames;
|
|
101
|
-
};
|
|
102
|
-
};
|