@intentic/sandbox-contract 1.310.0 → 1.312.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 +43 -159
- package/dist/chores/chores.js +6 -6
- package/dist/chores/chores.js.map +1 -1
- package/dist/chores/fix-deps.d.ts.map +1 -1
- package/dist/chores/fix-deps.js +3 -2
- package/dist/chores/fix-deps.js.map +1 -1
- package/dist/chores/prompt.d.ts.map +1 -1
- package/dist/chores/prompt.js +3 -2
- package/dist/chores/prompt.js.map +1 -1
- package/dist/contracts/accounts.contract.d.ts +15 -0
- package/dist/contracts/accounts.contract.d.ts.map +1 -1
- package/dist/contracts/agent.contract.d.ts +15 -0
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +1228 -32
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.js +42 -3
- package/dist/contracts/agents.contract.js.map +1 -1
- package/dist/contracts/capabilities.contract.d.ts +2 -0
- package/dist/contracts/capabilities.contract.d.ts.map +1 -1
- package/dist/contracts/device.contract.d.ts +2 -0
- package/dist/contracts/device.contract.d.ts.map +1 -1
- package/dist/contracts/extensions.contract.d.ts +2 -0
- package/dist/contracts/extensions.contract.d.ts.map +1 -1
- package/dist/contracts/offload.contract.d.ts +107 -0
- package/dist/contracts/offload.contract.d.ts.map +1 -0
- package/dist/contracts/offload.contract.js +53 -0
- package/dist/contracts/offload.contract.js.map +1 -0
- package/dist/contracts/ports.contract.d.ts +5 -0
- package/dist/contracts/ports.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +111 -0
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.js +3 -1
- package/dist/contracts/runner.contract.js.map +1 -1
- package/dist/contracts/settings.contract.d.ts +16 -0
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +154 -0
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/translator.contract.d.ts +16 -0
- package/dist/contracts/translator.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.d.ts +146 -0
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.js +40 -3
- package/dist/contracts/workspace.contract.js.map +1 -1
- package/dist/documents/conversions.d.ts +81 -0
- package/dist/documents/conversions.d.ts.map +1 -0
- package/dist/documents/conversions.js +213 -0
- package/dist/documents/conversions.js.map +1 -0
- package/dist/documents/index.d.ts +3 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +3 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/passthrough.d.ts +13 -0
- package/dist/documents/passthrough.d.ts.map +1 -0
- package/dist/documents/passthrough.js +101 -0
- package/dist/documents/passthrough.js.map +1 -0
- package/dist/events/agent-events.d.ts +20 -0
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-events.js +6 -1
- package/dist/events/agent-events.js.map +1 -1
- package/dist/events/land-breakage.d.ts +3 -0
- package/dist/events/land-breakage.d.ts.map +1 -1
- package/dist/events/land-breakage.js +3 -0
- package/dist/events/land-breakage.js.map +1 -1
- package/dist/events/land-conflict.d.ts +3 -0
- package/dist/events/land-conflict.d.ts.map +1 -0
- package/dist/events/land-conflict.js +4 -0
- package/dist/events/land-conflict.js.map +1 -0
- package/dist/events/system-events.d.ts +114 -0
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/system-events.js +3 -1
- package/dist/events/system-events.js.map +1 -1
- package/dist/events/transcript.d.ts +5 -0
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/events/transcript.js +9 -1
- package/dist/events/transcript.js.map +1 -1
- package/dist/events/verify-nudge.d.ts.map +1 -1
- package/dist/events/verify-nudge.js.map +1 -1
- package/dist/front/generated/wire.d.ts +137 -0
- package/dist/front/generated/wire.d.ts.map +1 -0
- package/dist/front/generated/wire.js +2 -0
- package/dist/front/generated/wire.js.map +1 -0
- package/dist/front/terminal-frames.d.ts +17 -0
- package/dist/front/terminal-frames.d.ts.map +1 -0
- package/dist/front/terminal-frames.js +79 -0
- package/dist/front/terminal-frames.js.map +1 -0
- package/dist/ids/conversation-ids.d.ts +2 -0
- package/dist/ids/conversation-ids.d.ts.map +1 -1
- package/dist/ids/conversation-ids.js +2 -0
- package/dist/ids/conversation-ids.js.map +1 -1
- package/dist/index.d.ts +1773 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/policy/command-run.d.ts +1 -1
- package/dist/policy/command-run.d.ts.map +1 -1
- package/dist/policy/command-run.js +7 -4
- package/dist/policy/command-run.js.map +1 -1
- package/dist/protocol/container-requirements.d.ts +0 -1
- package/dist/protocol/container-requirements.d.ts.map +1 -1
- package/dist/protocol/container-requirements.js +1 -2
- package/dist/protocol/container-requirements.js.map +1 -1
- package/dist/protocol/ingress-contract.d.ts +0 -11
- package/dist/protocol/ingress-contract.d.ts.map +1 -1
- package/dist/protocol/raw-routes.d.ts +36 -4
- package/dist/protocol/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw-routes.js +18 -13
- package/dist/protocol/raw-routes.js.map +1 -1
- package/dist/protocol/route-meta.d.ts +2 -0
- package/dist/protocol/route-meta.d.ts.map +1 -1
- package/dist/protocol/route-meta.js.map +1 -1
- package/dist/protocol/runner-protocol.d.ts +34 -0
- package/dist/protocol/runner-protocol.d.ts.map +1 -1
- package/dist/protocol/runner-protocol.js +33 -0
- package/dist/protocol/runner-protocol.js.map +1 -1
- package/dist/protocol/tunnel-lanes.d.ts +10 -0
- package/dist/protocol/tunnel-lanes.d.ts.map +1 -0
- package/dist/protocol/tunnel-lanes.js +16 -0
- package/dist/protocol/tunnel-lanes.js.map +1 -0
- package/dist/schemas/activity.d.ts.map +1 -1
- package/dist/schemas/activity.js.map +1 -1
- package/dist/schemas/agents.d.ts +145 -3
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/agents.js +43 -9
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/automations.d.ts +43 -0
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/capabilities.d.ts +3 -0
- package/dist/schemas/capabilities.d.ts.map +1 -1
- package/dist/schemas/capabilities.js +4 -0
- package/dist/schemas/capabilities.js.map +1 -1
- package/dist/schemas/devices.d.ts +34 -6
- package/dist/schemas/devices.d.ts.map +1 -1
- package/dist/schemas/devices.js +8 -6
- package/dist/schemas/devices.js.map +1 -1
- package/dist/schemas/extension-updates.d.ts +4 -0
- package/dist/schemas/extension-updates.d.ts.map +1 -1
- package/dist/schemas/git/git.d.ts +16 -0
- package/dist/schemas/git/git.d.ts.map +1 -1
- package/dist/schemas/git/git.js +1 -0
- package/dist/schemas/git/git.js.map +1 -1
- package/dist/schemas/hosts.d.ts +8 -0
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +3 -0
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/keep-warm.d.ts +68 -0
- package/dist/schemas/keep-warm.d.ts.map +1 -0
- package/dist/schemas/keep-warm.js +74 -0
- package/dist/schemas/keep-warm.js.map +1 -0
- package/dist/schemas/metrics.d.ts +7 -0
- package/dist/schemas/metrics.d.ts.map +1 -1
- package/dist/schemas/metrics.js +1 -0
- package/dist/schemas/metrics.js.map +1 -1
- package/dist/schemas/offload.d.ts +62 -0
- package/dist/schemas/offload.d.ts.map +1 -0
- package/dist/schemas/offload.js +23 -0
- package/dist/schemas/offload.js.map +1 -0
- package/dist/schemas/personas.js +3 -3
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/ports.d.ts +10 -0
- package/dist/schemas/ports.d.ts.map +1 -1
- package/dist/schemas/ports.js +8 -0
- package/dist/schemas/ports.js.map +1 -1
- package/dist/schemas/providers/plan-limits.d.ts +29 -0
- package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
- package/dist/schemas/providers/plan-limits.js +7 -0
- package/dist/schemas/providers/plan-limits.js.map +1 -1
- package/dist/schemas/providers/provider-oauth.d.ts +15 -0
- package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
- package/dist/schemas/providers/provider-oauth.js +4 -0
- package/dist/schemas/providers/provider-oauth.js.map +1 -1
- package/dist/schemas/providers/usage.d.ts +6 -0
- package/dist/schemas/providers/usage.d.ts.map +1 -1
- package/dist/schemas/providers/usage.js +4 -0
- package/dist/schemas/providers/usage.js.map +1 -1
- package/dist/schemas/settings-history.d.ts +28 -0
- package/dist/schemas/settings-history.d.ts.map +1 -0
- package/dist/schemas/settings-history.js +39 -0
- package/dist/schemas/settings-history.js.map +1 -0
- package/dist/schemas/settings.d.ts +8 -0
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +33 -3
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/system.d.ts +24 -0
- package/dist/schemas/system.d.ts.map +1 -1
- package/dist/schemas/system.js +15 -0
- package/dist/schemas/system.js.map +1 -1
- package/dist/schemas/workspace/mainline.d.ts +371 -0
- package/dist/schemas/workspace/mainline.d.ts.map +1 -0
- package/dist/schemas/workspace/mainline.js +134 -0
- package/dist/schemas/workspace/mainline.js.map +1 -0
- package/dist/schemas/workspace/workspace-tree.d.ts +23 -0
- package/dist/schemas/workspace/workspace-tree.d.ts.map +1 -1
- package/dist/schemas/workspace/workspace-tree.js +34 -0
- package/dist/schemas/workspace/workspace-tree.js.map +1 -1
- package/dist/state/definition.d.ts +36 -4
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/definition.js.map +1 -1
- package/dist/state/fix-stance.d.ts.map +1 -1
- package/dist/state/fix-stance.js +1 -0
- 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 +5 -0
- package/dist/state/history-state.js.map +1 -1
- package/dist/state/runtime-state.d.ts +6 -0
- package/dist/state/runtime-state.d.ts.map +1 -1
- package/dist/state/runtime-state.js +2 -0
- package/dist/state/runtime-state.js.map +1 -1
- package/dist/state/workspace-state.d.ts +22 -1
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +27 -1
- package/dist/state/workspace-state.js.map +1 -1
- package/dist/text/transcript-fold.d.ts +3 -0
- package/dist/text/transcript-fold.d.ts.map +1 -1
- package/dist/text/transcript-fold.js +30 -8
- package/dist/text/transcript-fold.js.map +1 -1
- package/dist/time/zone.d.ts +1 -0
- package/dist/time/zone.d.ts.map +1 -1
- package/dist/time/zone.js +5 -0
- package/dist/time/zone.js.map +1 -1
- package/package.json +34 -22
- package/src/chores/chores.ts +6 -6
- package/src/chores/fix-deps.ts +3 -2
- package/src/chores/prompt.ts +3 -2
- package/src/contracts/agents.contract.ts +50 -3
- package/src/contracts/offload.contract.ts +60 -0
- package/src/contracts/runner.contract.ts +7 -1
- package/src/contracts/workspace.contract.ts +54 -2
- package/src/documents/conversions.ts +402 -0
- package/src/documents/index.ts +5 -0
- package/src/documents/passthrough.ts +139 -0
- package/src/events/agent-events.ts +9 -1
- package/src/events/land-breakage.ts +12 -0
- package/src/events/land-conflict.ts +12 -0
- package/src/events/system-events.ts +9 -3
- package/src/events/transcript.ts +14 -3
- package/src/events/verify-nudge.ts +4 -3
- package/src/front/generated/wire.ts +104 -0
- package/src/front/terminal-frames.fixture.json +55 -0
- package/src/front/terminal-frames.test.ts +63 -0
- package/src/front/terminal-frames.ts +102 -0
- package/src/ids/conversation-ids.ts +7 -0
- package/src/ids/hostnames.fixture.json +20 -0
- package/src/ids/hostnames.test.ts +20 -0
- package/src/index.ts +8 -1
- package/src/policy/command-run.test.ts +35 -0
- package/src/policy/command-run.ts +10 -5
- package/src/protocol/container-requirements.test.ts +2 -3
- package/src/protocol/container-requirements.ts +1 -7
- package/src/protocol/ingress-contract.fixture.json +77 -0
- package/src/protocol/ingress-contract.test.ts +18 -26
- package/src/protocol/ingress-contract.ts +3 -22
- package/src/protocol/raw-routes.ts +21 -14
- package/src/protocol/route-meta.ts +4 -0
- package/src/protocol/runner-protocol.ts +53 -0
- package/src/protocol/tunnel-lanes.json +136 -0
- package/src/protocol/tunnel-lanes.test.ts +30 -0
- package/src/protocol/tunnel-lanes.ts +32 -0
- package/src/schemas/activity.ts +3 -1
- package/src/schemas/agents.ts +66 -10
- package/src/schemas/capabilities.ts +6 -0
- package/src/schemas/devices.ts +16 -9
- package/src/schemas/git/git.ts +5 -0
- package/src/schemas/hosts.ts +8 -0
- package/src/schemas/keep-warm.test.ts +68 -0
- package/src/schemas/keep-warm.ts +124 -0
- package/src/schemas/metrics.ts +2 -0
- package/src/schemas/offload.ts +44 -0
- package/src/schemas/personas.ts +3 -3
- package/src/schemas/ports.ts +10 -0
- package/src/schemas/providers/plan-limits.ts +13 -0
- package/src/schemas/providers/provider-oauth.ts +6 -0
- package/src/schemas/providers/usage.ts +7 -0
- package/src/schemas/settings-history.ts +61 -0
- package/src/schemas/settings.ts +70 -19
- package/src/schemas/system.ts +17 -0
- package/src/schemas/workspace/mainline.ts +201 -0
- package/src/schemas/workspace/workspace-tree.ts +47 -0
- package/src/state/definition.ts +3 -2
- package/src/state/fix-stance.test.ts +14 -0
- package/src/state/fix-stance.ts +2 -0
- package/src/state/history-state.ts +15 -0
- package/src/state/runtime-state.ts +8 -0
- package/src/state/workspace-state.ts +35 -1
- package/src/text/transcript-fold.test.ts +53 -1
- package/src/text/transcript-fold.ts +53 -10
- package/src/time/zone.ts +7 -0
- package/src/webext/index.ts +1 -1
- package/dist/protocol/ingress-protocol.d.ts +0 -30
- package/dist/protocol/ingress-protocol.d.ts.map +0 -1
- package/dist/protocol/ingress-protocol.js +0 -285
- package/dist/protocol/ingress-protocol.js.map +0 -1
- package/dist/protocol/terminal-protocol.d.ts +0 -18
- package/dist/protocol/terminal-protocol.d.ts.map +0 -1
- package/dist/protocol/terminal-protocol.js +0 -2
- package/dist/protocol/terminal-protocol.js.map +0 -1
- package/dist/protocol/tunnel-heartbeat.d.ts +0 -19
- package/dist/protocol/tunnel-heartbeat.d.ts.map +0 -1
- package/dist/protocol/tunnel-heartbeat.js +0 -41
- package/dist/protocol/tunnel-heartbeat.js.map +0 -1
- package/src/protocol/ingress-protocol.test.ts +0 -535
- package/src/protocol/ingress-protocol.ts +0 -448
- package/src/protocol/terminal-protocol.ts +0 -13
- package/src/protocol/tunnel-heartbeat.test.ts +0 -75
- package/src/protocol/tunnel-heartbeat.ts +0 -67
|
@@ -2,6 +2,8 @@ import { STATE_DIR } from "@intentic/constants";
|
|
|
2
2
|
import type { AgentEvent } from "../events/agent-events.js";
|
|
3
3
|
import type { TranscriptPatch, TranscriptRow } from "../events/transcript.js";
|
|
4
4
|
import { watchWakePrompt } from "../events/watch-wake.js";
|
|
5
|
+
import { LAND_CONFLICT_OPENING } from "../events/land-conflict.js";
|
|
6
|
+
import { RESUME_NOTES } from "../events/resume.js";
|
|
5
7
|
import { childReportPrompt, peerMessagePrompt } from "../events/agent-words.js";
|
|
6
8
|
import { applyTranscriptPatch, foldTurn, TranscriptFold, userRow } from "./transcript-fold.js";
|
|
7
9
|
|
|
@@ -249,6 +251,25 @@ describe("foldTurn", () => {
|
|
|
249
251
|
);
|
|
250
252
|
});
|
|
251
253
|
|
|
254
|
+
// A resolve turn exists because the branch couldn't rebase; its own opening rebase failing the same way is that
|
|
255
|
+
// errand said twice, one row under itself. Any other turn still hears it, and a resolve turn still hears what moved.
|
|
256
|
+
it("leaves the blocked rebase out of a land-conflict turn's notice, and only that", () => {
|
|
257
|
+
const blocked: AgentEvent = { kind: "worktree", branch: "agent/x", base: "abc1234", sync: { commits: 0, blocked: ["intentic"] } };
|
|
258
|
+
const resolve = `${LAND_CONFLICT_OPENING}\n\n1. \`git add -A && git commit\``;
|
|
259
|
+
expect(foldOf(resolve, [blocked])).toEqual(openingOf(resolve));
|
|
260
|
+
expect(foldOf(`${RESUME_NOTES.restart}\n\n${resolve}`, [blocked]).slice(1)).toEqual([]);
|
|
261
|
+
expect(foldOf("go", [blocked]).slice(1)).toEqual([
|
|
262
|
+
{
|
|
263
|
+
role: "notice",
|
|
264
|
+
text: "Couldn't rebase onto your workspace in intentic: the turn is running from the older base, so its land may need a resolve.",
|
|
265
|
+
},
|
|
266
|
+
]);
|
|
267
|
+
const mixed: AgentEvent = { kind: "worktree", branch: "agent/x", base: "abc1234", sync: { commits: 3, blocked: ["intentic"] } };
|
|
268
|
+
expect(foldOf(resolve, [mixed]).slice(1)).toEqual([
|
|
269
|
+
{ role: "notice", text: "Your workspace moved on while this agent waited, its branch was rebased onto your latest 3 commits." },
|
|
270
|
+
]);
|
|
271
|
+
});
|
|
272
|
+
|
|
252
273
|
it("stamps the checkpoint and the preamble's notes on the turn's user row", () => {
|
|
253
274
|
const events: AgentEvent[] = [
|
|
254
275
|
{ kind: "checkpoint", id: "snap-1", index: 4 },
|
|
@@ -439,7 +460,7 @@ describe("patches", () => {
|
|
|
439
460
|
"append",
|
|
440
461
|
"tool",
|
|
441
462
|
"tool",
|
|
442
|
-
"
|
|
463
|
+
"toolThinking",
|
|
443
464
|
"tool",
|
|
444
465
|
"replace",
|
|
445
466
|
"append",
|
|
@@ -451,6 +472,37 @@ describe("patches", () => {
|
|
|
451
472
|
]);
|
|
452
473
|
});
|
|
453
474
|
|
|
475
|
+
// A subagent thinks a token at a time; sending the spawning card whole each time would resend every child it holds.
|
|
476
|
+
it("sends a subagent's reasoning as its words alone, onto the card that spawned it", () => {
|
|
477
|
+
const fold = new TranscriptFold(openingOf("go"));
|
|
478
|
+
fold.apply({ kind: "tool_call", id: "task-1", name: "Agent", category: "other", status: "in_progress" });
|
|
479
|
+
fold.apply({ kind: "tool_call", id: "t2", name: "Read", category: "read", status: "completed", parentToolUseId: "task-1" });
|
|
480
|
+
expect(fold.apply({ kind: "thinking", text: "the handler", parentToolUseId: "task-1" })).toEqual([
|
|
481
|
+
{ op: "toolThinking", index: 1, id: "task-1", text: "the handler" },
|
|
482
|
+
]);
|
|
483
|
+
expect(fold.apply({ kind: "thinking", text: "", parentToolUseId: "task-1" })).toEqual([]);
|
|
484
|
+
expect(fold.rows[1]?.tools?.[0]?.thinking).toBe("the handler");
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it("send a delegation's card without its subtree or thinking, and a client keeps the ones it has", () => {
|
|
488
|
+
const events: AgentEvent[] = [
|
|
489
|
+
{ kind: "tool_call", id: "task-1", name: "Agent", category: "other", status: "in_progress" },
|
|
490
|
+
{ kind: "tool_call", id: "t2", name: "Read", category: "read", status: "in_progress", parentToolUseId: "task-1" },
|
|
491
|
+
{ kind: "thinking", text: "in", parentToolUseId: "task-1" },
|
|
492
|
+
{ kind: "thinking", text: "ner", parentToolUseId: "task-1" },
|
|
493
|
+
{ kind: "tool_call_update", id: "task-1", status: "completed" },
|
|
494
|
+
];
|
|
495
|
+
const { folded, applied, patches } = replay(openingOf("go"), events);
|
|
496
|
+
expect(applied).toEqual(folded);
|
|
497
|
+
expect(patches.filter((patch) => patch.op === "toolThinking")).toEqual([
|
|
498
|
+
{ op: "toolThinking", index: 1, id: "task-1", text: "in" },
|
|
499
|
+
{ op: "toolThinking", index: 1, id: "task-1", text: "ner" },
|
|
500
|
+
]);
|
|
501
|
+
const update = patches.at(-1);
|
|
502
|
+
expect(update?.op === "tool" ? update.tool : undefined).toEqual({ id: "task-1", name: "Agent", category: "other", status: "completed" });
|
|
503
|
+
expect(applied[1]?.tools?.[0]).toMatchObject({ status: "completed", thinking: "inner", children: [{ id: "t2" }] });
|
|
504
|
+
});
|
|
505
|
+
|
|
454
506
|
// The other half of the wake's delivery: a live turn takes it as a steer. It is the daemon's own words either way,
|
|
455
507
|
// so it must not become a user row here, and must not leave a rewind anchor pointing at a message nobody sent.
|
|
456
508
|
it("writes a watch's wake into a live turn as a notice, and never as a steer to rewind to", () => {
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
type TranscriptTool,
|
|
12
12
|
} from "../events/transcript.js";
|
|
13
13
|
import { contextTrimLine } from "../schemas/context-trim.js";
|
|
14
|
+
import { keptWarmLine } from "../schemas/keep-warm.js";
|
|
15
|
+
import { isLandConflict } from "../events/land-conflict.js";
|
|
14
16
|
import { turnedAwayCode } from "../policy/turned-away.js";
|
|
15
17
|
import { mentionedPathTokens } from "./mentions.js";
|
|
16
18
|
import { unspokenPromptRow } from "../events/agent-words.js";
|
|
@@ -21,6 +23,9 @@ import { unspokenPromptRow } from "../events/agent-words.js";
|
|
|
21
23
|
|
|
22
24
|
export type TurnEnding = "settled" | "stopped";
|
|
23
25
|
|
|
26
|
+
// A compaction's row, live and restored from the provider's store alike.
|
|
27
|
+
export const COMPACTED_NOTICE = "Context compacted to free up space.";
|
|
28
|
+
|
|
24
29
|
// Where a tool card lives: its row, and the parent card it nests under when it's a helper's own call.
|
|
25
30
|
interface CardPlace {
|
|
26
31
|
readonly tool: TranscriptTool;
|
|
@@ -32,6 +37,9 @@ interface CardPlace {
|
|
|
32
37
|
const defined = <T extends object>(value: T): Partial<T> =>
|
|
33
38
|
Object.fromEntries(Object.entries(value).filter(([, field]) => field !== undefined)) as Partial<T>;
|
|
34
39
|
|
|
40
|
+
// A card's own fields: what a `tool` patch carries, so a delegation's growing subtree never rides one.
|
|
41
|
+
const ownFields = ({ children: _children, thinking: _thinking, ...own }: TranscriptTool): TranscriptTool => own;
|
|
42
|
+
|
|
35
43
|
const cardOf = (event: Extract<AgentEvent, { kind: "tool_call" }>): TranscriptTool => ({
|
|
36
44
|
id: event.id,
|
|
37
45
|
name: event.name,
|
|
@@ -296,7 +304,16 @@ export class TranscriptFold {
|
|
|
296
304
|
}
|
|
297
305
|
case "usage": {
|
|
298
306
|
// Lands on the last assistant bubble and closes it: a steered turn's stream can carry several turns.
|
|
299
|
-
const {
|
|
307
|
+
const {
|
|
308
|
+
kind: _kind,
|
|
309
|
+
account: _account,
|
|
310
|
+
cacheReadTokens: _read,
|
|
311
|
+
cacheCreationTokens: _written,
|
|
312
|
+
openingCacheReadTokens: _openingRead,
|
|
313
|
+
openingCacheCreationTokens: _openingWritten,
|
|
314
|
+
promptFingerprint: _fingerprint,
|
|
315
|
+
...usage
|
|
316
|
+
} = event;
|
|
300
317
|
const index = this.rows.findLastIndex((row) => row.role === "assistant");
|
|
301
318
|
const closed = this.closeBubble();
|
|
302
319
|
if (index === -1) {
|
|
@@ -318,16 +335,21 @@ export class TranscriptFold {
|
|
|
318
335
|
case "preamble":
|
|
319
336
|
// Collapses the daemon's preamble notes onto the user row; an empty note list is not a disclosure.
|
|
320
337
|
return event.notes.length === 0 ? [] : this.stampOpener((row) => (row.notes = [...event.notes]));
|
|
338
|
+
case "prompt_cache": {
|
|
339
|
+
// Only a conversation the sandbox kept warm gets a row: every other turn's cache is its own business.
|
|
340
|
+
const line = keptWarmLine(event);
|
|
341
|
+
return line === undefined ? [] : this.pushRow({ role: "notice", text: line });
|
|
342
|
+
}
|
|
321
343
|
case "context_trim":
|
|
322
344
|
// A row of its own rather than a stamp on the message: what was left out is not part of what was sent,
|
|
323
345
|
// and the fold beside the message only ever lists notes that actually rode.
|
|
324
346
|
return this.pushRow({ role: "notice", text: contextTrimLine(event) });
|
|
325
347
|
case "worktree":
|
|
326
|
-
return event.sync === undefined ? [] : this.
|
|
348
|
+
return event.sync === undefined ? [] : this.synced(event.sync);
|
|
327
349
|
case "landed":
|
|
328
350
|
return this.pushRow(landedRow(event));
|
|
329
351
|
case "compact":
|
|
330
|
-
return this.pushRow({ role: "notice", text:
|
|
352
|
+
return this.pushRow({ role: "notice", text: COMPACTED_NOTICE });
|
|
331
353
|
case "error":
|
|
332
354
|
// Keeps a refusal (no prose from the provider) from reading as a session that ended mid-question.
|
|
333
355
|
// A refusal that ran nothing takes its message back out ahead of the notice standing in for it.
|
|
@@ -518,10 +540,13 @@ export class TranscriptFold {
|
|
|
518
540
|
if (place === undefined || parent === undefined) {
|
|
519
541
|
return [];
|
|
520
542
|
}
|
|
543
|
+
// Only the new words travel: the card whole, children and all, would go out again for every token.
|
|
521
544
|
if (event.kind === "thinking") {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
545
|
+
if (event.text.length === 0) {
|
|
546
|
+
return [];
|
|
547
|
+
}
|
|
548
|
+
place.tool.thinking = `${place.tool.thinking ?? ""}${event.text}`;
|
|
549
|
+
return [{ op: "toolThinking", index: place.row, id: parent, text: event.text }];
|
|
525
550
|
}
|
|
526
551
|
if (event.kind === "tool_call") {
|
|
527
552
|
const child = cardOf(event);
|
|
@@ -590,7 +615,15 @@ export class TranscriptFold {
|
|
|
590
615
|
return [];
|
|
591
616
|
}
|
|
592
617
|
mutate(place.tool);
|
|
593
|
-
return [{ op: "tool", index: place.row, tool: structuredClone(place.tool), ...(place.parent === undefined ? {} : { parent: place.parent }) }];
|
|
618
|
+
return [{ op: "tool", index: place.row, tool: structuredClone(ownFields(place.tool)), ...(place.parent === undefined ? {} : { parent: place.parent }) }];
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// The rebase notice, less what a resolve turn was sent to fix: that turn opens because the branch couldn't rebase, so
|
|
622
|
+
// saying so again one row under its own errand only repeats it. What did move is still told.
|
|
623
|
+
private synced(sync: { commits: number; blocked: readonly string[] }): TranscriptPatch[] {
|
|
624
|
+
const opener = this.opener === undefined ? undefined : this.rows[this.opener];
|
|
625
|
+
const text = syncLine(opener !== undefined && isLandConflict(opener.text) ? { ...sync, blocked: [] } : sync);
|
|
626
|
+
return text === "" ? [] : this.pushRow({ role: "notice", text });
|
|
594
627
|
}
|
|
595
628
|
|
|
596
629
|
private stampOpener(mutate: (row: TranscriptRow) => void): TranscriptPatch[] {
|
|
@@ -637,15 +670,25 @@ export const applyTranscriptPatch = (rows: readonly TranscriptRow[], patch: Tran
|
|
|
637
670
|
return rows.map((row, index) => (index === patch.index ? { ...row, text: `${row.text}${patch.text}` } : row));
|
|
638
671
|
case "thinking":
|
|
639
672
|
return rows.map((row, index) => (index === patch.index ? { ...row, thinking: `${row.thinking ?? ""}${patch.text}` } : row));
|
|
673
|
+
case "toolThinking":
|
|
674
|
+
return rows.map((row, index) => (index === patch.index ? { ...row, tools: [...appendToolThinking(row.tools ?? [], patch.id, patch.text)] } : row));
|
|
640
675
|
case "tool":
|
|
641
676
|
return rows.map((row, index) => (index === patch.index ? { ...row, tools: upsertTool(row.tools ?? [], patch.tool, patch.parent) } : row));
|
|
642
677
|
}
|
|
643
678
|
};
|
|
644
679
|
|
|
645
|
-
//
|
|
646
|
-
|
|
680
|
+
// Appends a delegated subagent's reasoning onto the card with this id, wherever it nests.
|
|
681
|
+
export const appendToolThinking = (tools: readonly TranscriptTool[], id: string, text: string): readonly TranscriptTool[] =>
|
|
682
|
+
mapTool(tools, id, (card) => ({ ...card, thinking: `${card.thinking ?? ""}${text}` }));
|
|
683
|
+
|
|
684
|
+
// Replaces the tool with this id anywhere in the tree, keeping the nested calls and thinking it already holds, or appends
|
|
685
|
+
// it under `parent`, or at top level with no parent or no match.
|
|
647
686
|
export const upsertTool = (tools: readonly TranscriptTool[], tool: TranscriptTool, parent: string | undefined): TranscriptTool[] => {
|
|
648
|
-
const replaced = mapTool(tools, tool.id, () =>
|
|
687
|
+
const replaced = mapTool(tools, tool.id, (current) => ({
|
|
688
|
+
...tool,
|
|
689
|
+
...(current.children === undefined ? {} : { children: current.children }),
|
|
690
|
+
...(current.thinking === undefined ? {} : { thinking: current.thinking }),
|
|
691
|
+
}));
|
|
649
692
|
if (replaced !== tools) {
|
|
650
693
|
return [...replaced];
|
|
651
694
|
}
|
package/src/time/zone.ts
CHANGED
|
@@ -108,6 +108,13 @@ const offsetMinutes = (at: number, zone: Zone): number => {
|
|
|
108
108
|
return (match[1] === "-" ? -1 : 1) * (Number(match[2]) * 60 + Number(match[3]));
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
+
/** The instant the calendar day after the one `at` falls on begins, in a named zone: where `civilDayIn` next changes. */
|
|
112
|
+
export const nextDayStartIn = (at: number, zone: Zone): number => {
|
|
113
|
+
const [year = 0, month = 1, day = 1] = civilDayIn(at, zone).split("-").map(Number);
|
|
114
|
+
const midnightUtc = Date.UTC(year, month - 1, day + 1);
|
|
115
|
+
return midnightUtc - offsetMinutes(midnightUtc, zone) * 60_000;
|
|
116
|
+
};
|
|
117
|
+
|
|
111
118
|
/** Whether two zones are showing the same wall clock right now — which is when naming one on screen would be noise. */
|
|
112
119
|
export const sameClock = (a: Zone, b: Zone, at: number = Date.now()): boolean => a === b || offsetMinutes(at, a) === offsetMinutes(at, b);
|
|
113
120
|
|
package/src/webext/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// `src/index.ts` reaches every schema and contract in the repo, and the extension's bundle is uploaded to a store,
|
|
3
3
|
// where ~400 kB of the daemon's unrelated wire surface is both dead weight and something a reviewer has to account for.
|
|
4
4
|
// Nothing here may import that barrel, or the saving is silently undone — `pnpm --filter @intentic/webext build`
|
|
5
|
-
//
|
|
5
|
+
// checks the bundle against the ceiling in _devices/webext/scripts/size-budget.mjs.
|
|
6
6
|
export { webextContract } from "../contracts/webext.contract.js";
|
|
7
7
|
export * from "../protocol/webext-links.js";
|
|
8
8
|
export * from "../protocol/webext-protocol.js";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type IncomingMessage, type ServerResponse } from "node:http";
|
|
2
|
-
import { Duplex } from "node:stream";
|
|
3
|
-
export declare const INITIAL_WINDOW_SIZE: number;
|
|
4
|
-
export declare const CONNECTION_WINDOW_SIZE: number;
|
|
5
|
-
export interface IngressSession {
|
|
6
|
-
readonly forwardRequest: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
7
|
-
readonly forwardUpgrade: (request: IncomingMessage, socket: Duplex, head: Buffer) => Promise<void>;
|
|
8
|
-
readonly close: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const openIngressSession: (duplex: Duplex) => Promise<IngressSession>;
|
|
11
|
-
export interface ServeIngressSessionOptions {
|
|
12
|
-
readonly targetPort: number;
|
|
13
|
-
}
|
|
14
|
-
export interface IngressSessionServer {
|
|
15
|
-
readonly close: () => void;
|
|
16
|
-
}
|
|
17
|
-
export declare const serveIngressSession: (duplex: Duplex, options: ServeIngressSessionOptions) => Promise<IngressSessionServer>;
|
|
18
|
-
export interface TunnelWebSocket {
|
|
19
|
-
readonly send: (data: Buffer, options: {
|
|
20
|
-
binary: boolean;
|
|
21
|
-
}, callback: (error?: Error) => void) => void;
|
|
22
|
-
readonly close: () => void;
|
|
23
|
-
readonly on: {
|
|
24
|
-
(event: `message`, listener: (data: unknown) => void): unknown;
|
|
25
|
-
(event: `close`, listener: () => void): unknown;
|
|
26
|
-
(event: `error`, listener: (error: Error) => void): unknown;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare const webSocketDuplex: (socket: TunnelWebSocket) => Duplex;
|
|
30
|
-
//# sourceMappingURL=ingress-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ingress-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/ingress-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,eAAe,EAA4B,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAU7H,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuGrC,eAAO,MAAM,mBAAmB,QAAc,CAAC;AAK/C,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAyE9D,MAAM,WAAW,cAAc;IAI3B,QAAQ,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAG/F,QAAQ,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnG,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC9B;AAID,eAAO,MAAM,kBAAkB,WAAkB,MAAM,KAAG,OAAO,CAAC,cAAc,CAuG/E,CAAC;AAIF,MAAM,WAAW,0BAA0B;IAEvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IAGjC,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC9B;AAID,eAAO,MAAM,mBAAmB,WAAkB,MAAM,WAAW,0BAA0B,KAAG,OAAO,CAAC,oBAAoB,CAuF3H,CAAC;AAKF,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;IACvG,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,EAAE;QACT,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC;QAC/D,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;QAChD,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC;KAC/D,CAAC;CACL;AAED,eAAO,MAAM,eAAe,WAAY,eAAe,KAAG,MAoBzD,CAAC"}
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
import { Agent, request as h1Request } from "node:http";
|
|
2
|
-
import { connect as h2Connect, constants, createServer as createH2Server, } from "node:http2";
|
|
3
|
-
import { createServer as createNetServer, connect as netConnect } from "node:net";
|
|
4
|
-
import { Duplex } from "node:stream";
|
|
5
|
-
const HOP_BY_HOP = new Set([
|
|
6
|
-
"connection",
|
|
7
|
-
"host",
|
|
8
|
-
"http2-settings",
|
|
9
|
-
"keep-alive",
|
|
10
|
-
"proxy-authenticate",
|
|
11
|
-
"proxy-authorization",
|
|
12
|
-
"proxy-connection",
|
|
13
|
-
"te",
|
|
14
|
-
"trailer",
|
|
15
|
-
"transfer-encoding",
|
|
16
|
-
"upgrade",
|
|
17
|
-
]);
|
|
18
|
-
const endToEnd = (headers) => {
|
|
19
|
-
const kept = {};
|
|
20
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
21
|
-
if (value !== undefined && !name.startsWith(":") && !HOP_BY_HOP.has(name)) {
|
|
22
|
-
kept[name] = value;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return kept;
|
|
26
|
-
};
|
|
27
|
-
const UPGRADE_METHOD_HEADER = "x-ingress-method";
|
|
28
|
-
const UPGRADE_PATH_HEADER = "x-ingress-path";
|
|
29
|
-
const UPGRADE_HEADER_PREFIX = "x-ingress-h-";
|
|
30
|
-
const upgradeEnvelope = (request, authority) => {
|
|
31
|
-
const envelope = {
|
|
32
|
-
[constants.HTTP2_HEADER_METHOD]: constants.HTTP2_METHOD_CONNECT,
|
|
33
|
-
[constants.HTTP2_HEADER_AUTHORITY]: authority,
|
|
34
|
-
[UPGRADE_METHOD_HEADER]: request.method ?? "GET",
|
|
35
|
-
[UPGRADE_PATH_HEADER]: request.url ?? "/",
|
|
36
|
-
};
|
|
37
|
-
for (const [name, value] of Object.entries(request.headers)) {
|
|
38
|
-
if (value !== undefined) {
|
|
39
|
-
envelope[`${UPGRADE_HEADER_PREFIX}${name}`] = value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return envelope;
|
|
43
|
-
};
|
|
44
|
-
const upgradeHead = (headers) => {
|
|
45
|
-
const rebuilt = {};
|
|
46
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
47
|
-
if (value !== undefined && name.startsWith(UPGRADE_HEADER_PREFIX)) {
|
|
48
|
-
rebuilt[name.slice(UPGRADE_HEADER_PREFIX.length)] = value;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
method: single(headers[UPGRADE_METHOD_HEADER]) ?? "GET",
|
|
53
|
-
path: single(headers[UPGRADE_PATH_HEADER]) ?? "/",
|
|
54
|
-
headers: rebuilt,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
const single = (value) => (Array.isArray(value) ? value[0] : value);
|
|
58
|
-
const serializeHead = (response, drop, add) => {
|
|
59
|
-
const lines = [`HTTP/${response.httpVersion} ${String(response.statusCode)} ${response.statusMessage ?? ""}`];
|
|
60
|
-
for (let index = 0; index + 1 < response.rawHeaders.length; index += 2) {
|
|
61
|
-
const name = response.rawHeaders[index];
|
|
62
|
-
if (!drop.has(name.toLowerCase())) {
|
|
63
|
-
lines.push(`${name}: ${response.rawHeaders[index + 1]}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return Buffer.from(`${[...lines, ...add].join("\r\n")}\r\n\r\n`, "latin1");
|
|
67
|
-
};
|
|
68
|
-
const DECLINED_UPGRADE_DROP = new Set(["connection", "keep-alive", "transfer-encoding"]);
|
|
69
|
-
const DECLINED_UPGRADE_ADD = ["connection: close"];
|
|
70
|
-
const NOTHING_DROPPED = new Set();
|
|
71
|
-
const MAX_SESSION_MEMORY_MB = 128;
|
|
72
|
-
export const INITIAL_WINDOW_SIZE = 1024 * 1024;
|
|
73
|
-
export const CONNECTION_WINDOW_SIZE = 2 * INITIAL_WINDOW_SIZE;
|
|
74
|
-
const PEER_MAX_CONCURRENT_STREAMS = 256;
|
|
75
|
-
const LOOPBACK = "127.0.0.1";
|
|
76
|
-
const splice = (left, right) => {
|
|
77
|
-
left.pipe(right);
|
|
78
|
-
right.pipe(left);
|
|
79
|
-
const fail = () => {
|
|
80
|
-
left.destroy();
|
|
81
|
-
right.destroy();
|
|
82
|
-
};
|
|
83
|
-
left.on("error", fail);
|
|
84
|
-
right.on("error", fail);
|
|
85
|
-
left.on("close", () => {
|
|
86
|
-
if (!right.writableFinished) {
|
|
87
|
-
right.destroy();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
right.on("close", () => {
|
|
91
|
-
if (!left.writableFinished) {
|
|
92
|
-
left.destroy();
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
const loopbackBridge = async () => {
|
|
97
|
-
const listener = createNetServer();
|
|
98
|
-
try {
|
|
99
|
-
await new Promise((resolve, reject) => {
|
|
100
|
-
listener.once("error", reject);
|
|
101
|
-
listener.listen(0, LOOPBACK, resolve);
|
|
102
|
-
});
|
|
103
|
-
const accepted = new Promise((resolve, reject) => {
|
|
104
|
-
listener.once("connection", resolve);
|
|
105
|
-
listener.once("error", reject);
|
|
106
|
-
});
|
|
107
|
-
const tunnel = netConnect(listener.address().port, LOOPBACK);
|
|
108
|
-
await new Promise((resolve, reject) => {
|
|
109
|
-
tunnel.once("connect", resolve);
|
|
110
|
-
tunnel.once("error", reject);
|
|
111
|
-
});
|
|
112
|
-
const session = await accepted;
|
|
113
|
-
if (session.remotePort !== tunnel.localPort) {
|
|
114
|
-
session.destroy();
|
|
115
|
-
tunnel.destroy();
|
|
116
|
-
throw new Error("the loopback bridge accepted a connection that was not its own");
|
|
117
|
-
}
|
|
118
|
-
session.setNoDelay(true);
|
|
119
|
-
tunnel.setNoDelay(true);
|
|
120
|
-
return { session, tunnel };
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
listener.close();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
export const openIngressSession = async (duplex) => {
|
|
127
|
-
const bridge = await loopbackBridge();
|
|
128
|
-
splice(bridge.tunnel, duplex);
|
|
129
|
-
const session = h2Connect("http://tunnel.invalid", {
|
|
130
|
-
createConnection: () => bridge.session,
|
|
131
|
-
maxSessionMemory: MAX_SESSION_MEMORY_MB,
|
|
132
|
-
peerMaxConcurrentStreams: PEER_MAX_CONCURRENT_STREAMS,
|
|
133
|
-
settings: { initialWindowSize: INITIAL_WINDOW_SIZE },
|
|
134
|
-
});
|
|
135
|
-
session.on("error", () => duplex.destroy());
|
|
136
|
-
session.on("close", () => duplex.destroy());
|
|
137
|
-
session.once("connect", () => session.setLocalWindowSize(CONNECTION_WINDOW_SIZE));
|
|
138
|
-
const authorityOf = (request) => {
|
|
139
|
-
const host = request.headers.host;
|
|
140
|
-
if (host === undefined || host === "") {
|
|
141
|
-
throw new Error("an ingress request is routed by its Host header, and this one has none");
|
|
142
|
-
}
|
|
143
|
-
return host;
|
|
144
|
-
};
|
|
145
|
-
const forwardRequest = (request, response) => new Promise((resolve, reject) => {
|
|
146
|
-
const authority = authorityOf(request);
|
|
147
|
-
const stream = session.request({
|
|
148
|
-
[constants.HTTP2_HEADER_METHOD]: request.method ?? "GET",
|
|
149
|
-
[constants.HTTP2_HEADER_PATH]: request.url ?? "/",
|
|
150
|
-
[constants.HTTP2_HEADER_AUTHORITY]: authority,
|
|
151
|
-
[constants.HTTP2_HEADER_SCHEME]: "https",
|
|
152
|
-
...endToEnd(request.headers),
|
|
153
|
-
}, { endStream: false });
|
|
154
|
-
request.pipe(stream);
|
|
155
|
-
response.on("close", () => {
|
|
156
|
-
if (!response.writableFinished) {
|
|
157
|
-
stream.close(constants.NGHTTP2_CANCEL);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
stream.on("response", (headers) => {
|
|
161
|
-
if (response.destroyed) {
|
|
162
|
-
stream.close(constants.NGHTTP2_CANCEL);
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
response.writeHead(Number(headers[constants.HTTP2_HEADER_STATUS] ?? 502), endToEnd(headers));
|
|
166
|
-
stream.pipe(response);
|
|
167
|
-
});
|
|
168
|
-
stream.on("error", reject);
|
|
169
|
-
response.on("finish", resolve);
|
|
170
|
-
stream.on("close", () => {
|
|
171
|
-
if (!response.writableEnded) {
|
|
172
|
-
reject(new Error("the tunnel closed the stream before the response was complete"));
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
const forwardUpgrade = (request, socket, head) => new Promise((resolve, reject) => {
|
|
177
|
-
const stream = session.request(upgradeEnvelope(request, authorityOf(request)), { endStream: false });
|
|
178
|
-
stream.on("error", reject);
|
|
179
|
-
stream.once("response", (headers) => {
|
|
180
|
-
const status = Number(headers[constants.HTTP2_HEADER_STATUS]);
|
|
181
|
-
if (status !== constants.HTTP_STATUS_OK) {
|
|
182
|
-
stream.close(constants.NGHTTP2_CANCEL);
|
|
183
|
-
reject(new Error(`the tunnel refused an upgrade with :status ${String(status)}`));
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (head.length > 0) {
|
|
187
|
-
stream.write(head);
|
|
188
|
-
}
|
|
189
|
-
splice(stream, socket);
|
|
190
|
-
resolve();
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
return {
|
|
194
|
-
forwardRequest,
|
|
195
|
-
forwardUpgrade,
|
|
196
|
-
close: () => {
|
|
197
|
-
session.close(() => bridge.tunnel.destroy());
|
|
198
|
-
bridge.tunnel.end();
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
export const serveIngressSession = async (duplex, options) => {
|
|
203
|
-
const bridge = await loopbackBridge();
|
|
204
|
-
splice(bridge.tunnel, duplex);
|
|
205
|
-
const agent = new Agent({ keepAlive: true, maxSockets: PEER_MAX_CONCURRENT_STREAMS });
|
|
206
|
-
const server = createH2Server({
|
|
207
|
-
maxSessionMemory: MAX_SESSION_MEMORY_MB,
|
|
208
|
-
settings: { initialWindowSize: INITIAL_WINDOW_SIZE },
|
|
209
|
-
});
|
|
210
|
-
server.on("sessionError", () => duplex.destroy());
|
|
211
|
-
server.on("clientError", () => duplex.destroy());
|
|
212
|
-
server.on("error", () => duplex.destroy());
|
|
213
|
-
server.on("session", (session) => session.setLocalWindowSize(CONNECTION_WINDOW_SIZE));
|
|
214
|
-
const forwardToLoopback = (stream, headers) => {
|
|
215
|
-
const local = h1Request({
|
|
216
|
-
host: LOOPBACK,
|
|
217
|
-
port: options.targetPort,
|
|
218
|
-
method: single(headers[constants.HTTP2_HEADER_METHOD]) ?? "GET",
|
|
219
|
-
path: single(headers[constants.HTTP2_HEADER_PATH]) ?? "/",
|
|
220
|
-
headers: { host: single(headers[constants.HTTP2_HEADER_AUTHORITY]) ?? "", ...endToEnd(headers) },
|
|
221
|
-
agent,
|
|
222
|
-
});
|
|
223
|
-
stream.pipe(local);
|
|
224
|
-
local.on("response", (response) => {
|
|
225
|
-
stream.respond({ [constants.HTTP2_HEADER_STATUS]: response.statusCode ?? 502, ...endToEnd(response.headers) });
|
|
226
|
-
response.pipe(stream);
|
|
227
|
-
});
|
|
228
|
-
local.on("error", () => stream.close(constants.NGHTTP2_INTERNAL_ERROR));
|
|
229
|
-
stream.on("error", () => local.destroy());
|
|
230
|
-
stream.on("aborted", () => local.destroy());
|
|
231
|
-
};
|
|
232
|
-
const spliceUpgrade = (stream, headers) => {
|
|
233
|
-
const head = upgradeHead(headers);
|
|
234
|
-
const local = h1Request({ host: LOOPBACK, port: options.targetPort, method: head.method, path: head.path, headers: head.headers, agent: false });
|
|
235
|
-
local.on("upgrade", (response, socket, first) => {
|
|
236
|
-
stream.respond({ [constants.HTTP2_HEADER_STATUS]: constants.HTTP_STATUS_OK });
|
|
237
|
-
stream.write(serializeHead(response, NOTHING_DROPPED, []));
|
|
238
|
-
if (first.length > 0) {
|
|
239
|
-
stream.write(first);
|
|
240
|
-
}
|
|
241
|
-
splice(stream, socket);
|
|
242
|
-
});
|
|
243
|
-
local.on("response", (response) => {
|
|
244
|
-
stream.respond({ [constants.HTTP2_HEADER_STATUS]: constants.HTTP_STATUS_OK });
|
|
245
|
-
stream.write(serializeHead(response, DECLINED_UPGRADE_DROP, DECLINED_UPGRADE_ADD));
|
|
246
|
-
response.pipe(stream);
|
|
247
|
-
});
|
|
248
|
-
local.on("error", () => stream.close(constants.NGHTTP2_CONNECT_ERROR));
|
|
249
|
-
local.end();
|
|
250
|
-
};
|
|
251
|
-
server.on("stream", (stream, headers) => {
|
|
252
|
-
if (headers[constants.HTTP2_HEADER_METHOD] === constants.HTTP2_METHOD_CONNECT) {
|
|
253
|
-
spliceUpgrade(stream, headers);
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
forwardToLoopback(stream, headers);
|
|
257
|
-
});
|
|
258
|
-
server.emit("connection", bridge.session);
|
|
259
|
-
return {
|
|
260
|
-
close: () => {
|
|
261
|
-
agent.destroy();
|
|
262
|
-
server.close();
|
|
263
|
-
bridge.tunnel.end();
|
|
264
|
-
},
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
export const webSocketDuplex = (socket) => {
|
|
268
|
-
const duplex = new Duplex({
|
|
269
|
-
read: () => { },
|
|
270
|
-
write: (chunk, _encoding, callback) => {
|
|
271
|
-
socket.send(chunk, { binary: true }, (error) => callback(error ?? null));
|
|
272
|
-
},
|
|
273
|
-
final: (callback) => {
|
|
274
|
-
socket.close();
|
|
275
|
-
callback();
|
|
276
|
-
},
|
|
277
|
-
});
|
|
278
|
-
socket.on(`message`, (data) => {
|
|
279
|
-
duplex.push(Buffer.isBuffer(data) ? data : Buffer.from(data));
|
|
280
|
-
});
|
|
281
|
-
socket.on(`close`, () => duplex.push(null));
|
|
282
|
-
socket.on(`error`, (error) => duplex.destroy(error));
|
|
283
|
-
return duplex;
|
|
284
|
-
};
|
|
285
|
-
//# sourceMappingURL=ingress-protocol.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ingress-protocol.js","sourceRoot":"","sources":["../../src/protocol/ingress-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,SAAS,EAAuE,MAAM,WAAW,CAAC;AAC7H,OAAO,EAEH,OAAO,IAAI,SAAS,EACpB,SAAS,EACT,YAAY,IAAI,cAAc,GAGjC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAoB,YAAY,IAAI,eAAe,EAAE,OAAO,IAAI,UAAU,EAAe,MAAM,UAAU,CAAC;AACjH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,MAAM,UAAU,GAAG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AE,GAAG,EAAE,GAAE,CAAC;QACd,KAAK,EAAE,CAAC,KAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;YAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC;QAC7E,CAAC;QAED,KAAK,EAAE,CAAC,QAAQ,EAAE,EAAE;YAChB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,QAAQ,EAAE,CAAC;QACf,CAAC;KACJ,CAAC,CAAC;IAGH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,IAAa,EAAE,EAAE;QACnC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type TerminalClientMessage = {
|
|
2
|
-
readonly type: "input";
|
|
3
|
-
readonly data: string;
|
|
4
|
-
} | {
|
|
5
|
-
readonly type: "resize";
|
|
6
|
-
readonly cols: number;
|
|
7
|
-
readonly rows: number;
|
|
8
|
-
} | {
|
|
9
|
-
readonly type: "ping";
|
|
10
|
-
};
|
|
11
|
-
export type TerminalServerMessage = {
|
|
12
|
-
readonly type: "exit";
|
|
13
|
-
readonly code: number;
|
|
14
|
-
readonly reason?: string;
|
|
15
|
-
} | {
|
|
16
|
-
readonly type: "pong";
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=terminal-protocol.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-protocol.d.ts","sourceRoot":"","sources":["../../src/protocol/terminal-protocol.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,qBAAqB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAGhC,MAAM,MAAM,qBAAqB,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-protocol.js","sourceRoot":"","sources":["../../src/protocol/terminal-protocol.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const PING_INTERVAL_MS = 15000;
|
|
2
|
-
export declare const DEAD_AFTER_MS = 45000;
|
|
3
|
-
export interface HeartbeatOptions {
|
|
4
|
-
readonly ping: () => void;
|
|
5
|
-
readonly onDead: () => void;
|
|
6
|
-
readonly now?: () => number;
|
|
7
|
-
readonly deadAfterMs?: number;
|
|
8
|
-
}
|
|
9
|
-
export interface Heartbeat {
|
|
10
|
-
readonly saw: () => void;
|
|
11
|
-
readonly tick: () => void;
|
|
12
|
-
readonly stop: () => void;
|
|
13
|
-
readonly alive: () => boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare const createHeartbeat: (options: HeartbeatOptions) => Heartbeat;
|
|
16
|
-
export declare const startHeartbeat: (options: HeartbeatOptions & {
|
|
17
|
-
readonly intervalMs?: number;
|
|
18
|
-
}) => Heartbeat;
|
|
19
|
-
//# sourceMappingURL=tunnel-heartbeat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-heartbeat.d.ts","sourceRoot":"","sources":["../../src/protocol/tunnel-heartbeat.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,QAAS,CAAC;AACvC,eAAO,MAAM,aAAa,QAAS,CAAC;AAEpC,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,SAAS;IAEtB,QAAQ,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC;IAEzB,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,eAAe,YAAa,gBAAgB,KAAG,SA4B3D,CAAC;AAGF,eAAO,MAAM,cAAc,YAAa,gBAAgB,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,KAAG,SAW7F,CAAC"}
|