@openscout/protocol 0.2.64 → 0.2.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +103 -52
- package/dist/a2a.d.ts +224 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +225 -0
- package/dist/activity.d.ts +70 -0
- package/dist/activity.d.ts.map +1 -0
- package/dist/activity.js +1 -0
- package/dist/actors.d.ts +7 -3
- package/dist/actors.d.ts.map +1 -0
- package/dist/actors.js +15 -1
- package/dist/agent-broker-feed.d.ts +84 -0
- package/dist/agent-broker-feed.d.ts.map +1 -0
- package/dist/agent-broker-feed.js +1 -0
- package/dist/agent-identity.d.ts +23 -0
- package/dist/agent-identity.d.ts.map +1 -0
- package/dist/agent-identity.js +122 -8
- package/dist/agent-runs.d.ts +191 -0
- package/dist/agent-runs.d.ts.map +1 -0
- package/dist/agent-runs.js +365 -0
- package/dist/assigned-roles.d.ts +205 -0
- package/dist/assigned-roles.d.ts.map +1 -0
- package/dist/assigned-roles.js +228 -0
- package/dist/broker-routes.d.ts +40 -0
- package/dist/broker-routes.d.ts.map +1 -0
- package/dist/broker-routes.js +56 -0
- package/dist/budget.d.ts +65 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +19 -0
- package/dist/capability-matrix.d.ts +230 -0
- package/dist/capability-matrix.d.ts.map +1 -0
- package/dist/capability-matrix.js +304 -0
- package/dist/channel-identity.d.ts +40 -0
- package/dist/channel-identity.d.ts.map +1 -0
- package/dist/channel-identity.js +108 -0
- package/dist/collaboration.d.ts +45 -16
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +39 -23
- package/dist/common.d.ts +4 -3
- package/dist/common.d.ts.map +1 -0
- package/dist/conversations.d.ts +1 -0
- package/dist/conversations.d.ts.map +1 -0
- package/dist/cursor-transport.d.ts +22 -0
- package/dist/cursor-transport.d.ts.map +1 -0
- package/dist/cursor-transport.js +10 -0
- package/dist/debug-attach.d.ts +29 -0
- package/dist/debug-attach.d.ts.map +1 -0
- package/dist/debug-attach.js +6 -0
- package/dist/deliveries.d.ts +16 -2
- package/dist/deliveries.d.ts.map +1 -0
- package/dist/durable-actions.d.ts +94 -0
- package/dist/durable-actions.d.ts.map +1 -0
- package/dist/durable-actions.js +1 -0
- package/dist/events.d.ts +27 -1
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +14 -1
- package/dist/harness-feature-support.d.ts +76 -0
- package/dist/harness-feature-support.d.ts.map +1 -0
- package/dist/harness-feature-support.js +29 -0
- package/dist/host-integrations.d.ts +22 -0
- package/dist/host-integrations.d.ts.map +1 -0
- package/dist/host-integrations.js +64 -0
- package/dist/inbox.d.ts +50 -0
- package/dist/inbox.d.ts.map +1 -0
- package/dist/inbox.js +9 -0
- package/dist/index.d.ts +35 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -2
- package/dist/invocations.d.ts +119 -4
- package/dist/invocations.d.ts.map +1 -0
- package/dist/invocations.js +201 -1
- package/dist/mesh.d.ts +98 -0
- package/dist/mesh.d.ts.map +1 -0
- package/dist/mesh.js +18 -1
- package/dist/messages.d.ts +3 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/native-interactions.d.ts +30 -0
- package/dist/native-interactions.d.ts.map +1 -0
- package/dist/native-interactions.js +51 -0
- package/dist/observed-status.d.ts +33 -0
- package/dist/observed-status.d.ts.map +1 -0
- package/dist/observed-status.js +6 -0
- package/dist/orchestrator-prompt.d.ts +10 -0
- package/dist/orchestrator-prompt.d.ts.map +1 -0
- package/dist/orchestrator-prompt.js +36 -0
- package/dist/permission-policy.d.ts +5 -0
- package/dist/permission-policy.d.ts.map +1 -0
- package/dist/permission-policy.js +15 -0
- package/dist/provisional-agent-names.d.ts +30 -0
- package/dist/provisional-agent-names.d.ts.map +1 -0
- package/dist/provisional-agent-names.js +224 -0
- package/dist/read-receipts.d.ts +12 -0
- package/dist/read-receipts.d.ts.map +1 -0
- package/dist/read-receipts.js +1 -0
- package/dist/relay-agent-card.d.ts +10 -0
- package/dist/relay-agent-card.d.ts.map +1 -0
- package/dist/rendezvous.d.ts +97 -0
- package/dist/rendezvous.d.ts.map +1 -0
- package/dist/rendezvous.js +35 -0
- package/dist/reserved-vocabulary.d.ts +21 -0
- package/dist/reserved-vocabulary.d.ts.map +1 -0
- package/dist/reserved-vocabulary.js +101 -0
- package/dist/route-aliases.d.ts +112 -0
- package/dist/route-aliases.d.ts.map +1 -0
- package/dist/route-aliases.js +1 -0
- package/dist/runtime-catalog-contract.d.ts +39 -0
- package/dist/runtime-catalog-contract.d.ts.map +1 -0
- package/dist/runtime-catalog-contract.js +17 -0
- package/dist/runtime-catalog.d.ts +11 -0
- package/dist/runtime-catalog.d.ts.map +1 -0
- package/dist/runtime-catalog.generated.d.ts +230 -0
- package/dist/runtime-catalog.generated.d.ts.map +1 -0
- package/dist/runtime-catalog.generated.js +299 -0
- package/dist/runtime-catalog.js +192 -0
- package/dist/runtime-execution.d.ts +161 -0
- package/dist/runtime-execution.d.ts.map +1 -0
- package/dist/runtime-execution.js +327 -0
- package/dist/runtime-profiles.d.ts +12 -0
- package/dist/runtime-profiles.d.ts.map +1 -0
- package/dist/runtime-profiles.js +20 -0
- package/dist/scout-agent-card.d.ts +10 -0
- package/dist/scout-agent-card.d.ts.map +1 -0
- package/dist/scout-composer.d.ts +27 -0
- package/dist/scout-composer.d.ts.map +1 -0
- package/dist/scout-composer.js +192 -0
- package/dist/scout-delivery.d.ts +99 -4
- package/dist/scout-delivery.d.ts.map +1 -0
- package/dist/scout-dispatch.d.ts +40 -3
- package/dist/scout-dispatch.d.ts.map +1 -0
- package/dist/scout-reply-context.d.ts +1 -0
- package/dist/scout-reply-context.d.ts.map +1 -0
- package/dist/session-display-state.d.ts +132 -0
- package/dist/session-display-state.d.ts.map +1 -0
- package/dist/session-display-state.js +94 -0
- package/dist/terminal-host-topology.d.ts +119 -0
- package/dist/terminal-host-topology.d.ts.map +1 -0
- package/dist/terminal-host-topology.js +21 -0
- package/dist/terminal-sessions.d.ts +142 -0
- package/dist/terminal-sessions.d.ts.map +1 -0
- package/dist/terminal-sessions.js +81 -0
- package/dist/terminal-surface-id.d.ts +73 -0
- package/dist/terminal-surface-id.d.ts.map +1 -0
- package/dist/terminal-surface-id.js +162 -0
- package/dist/terminal-workspaces.d.ts +199 -0
- package/dist/terminal-workspaces.d.ts.map +1 -0
- package/dist/terminal-workspaces.js +287 -0
- package/dist/thread-events.d.ts +1 -0
- package/dist/thread-events.d.ts.map +1 -0
- package/dist/time.d.ts +16 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +33 -0
- package/dist/transports.d.ts +1 -0
- package/dist/transports.d.ts.map +1 -0
- package/package.json +37 -9
- package/src/a2a.ts +471 -0
- package/src/activity.ts +113 -0
- package/src/actors.ts +42 -8
- package/src/agent-broker-feed.ts +102 -0
- package/src/agent-identity.ts +143 -8
- package/src/agent-runs.ts +675 -0
- package/src/assigned-roles.ts +437 -0
- package/src/broker-routes.ts +62 -0
- package/src/budget.ts +88 -0
- package/src/capability-matrix.ts +648 -0
- package/src/channel-identity.ts +147 -0
- package/src/collaboration.ts +78 -48
- package/src/common.ts +24 -5
- package/src/cursor-transport.ts +34 -0
- package/src/debug-attach.ts +38 -0
- package/src/deliveries.ts +16 -1
- package/src/durable-actions.ts +125 -0
- package/src/events.ts +31 -0
- package/src/harness-feature-support.ts +116 -0
- package/src/host-integrations.ts +104 -0
- package/src/inbox.ts +68 -0
- package/src/index.ts +34 -2
- package/src/invocations.ts +351 -4
- package/src/mesh.ts +130 -0
- package/src/messages.ts +2 -0
- package/src/native-interactions.ts +100 -0
- package/src/observed-status.ts +90 -0
- package/src/orchestrator-prompt.ts +47 -0
- package/src/permission-policy.ts +21 -0
- package/src/provisional-agent-names.ts +272 -0
- package/src/read-receipts.ts +12 -0
- package/src/relay-agent-card.ts +73 -63
- package/src/rendezvous.ts +154 -0
- package/src/reserved-vocabulary.ts +135 -0
- package/src/route-aliases.ts +130 -0
- package/src/runtime-catalog-contract.ts +60 -0
- package/src/runtime-catalog.generated.ts +300 -0
- package/src/runtime-catalog.md +21 -0
- package/src/runtime-catalog.ts +193 -0
- package/src/runtime-catalog.v1.json +81 -0
- package/src/runtime-execution.ts +545 -0
- package/src/runtime-profiles.ts +37 -0
- package/src/scout-agent-card.ts +10 -0
- package/src/scout-composer.ts +249 -0
- package/src/scout-delivery.ts +113 -3
- package/src/scout-dispatch.ts +33 -2
- package/src/session-display-state.ts +202 -0
- package/src/terminal-host-topology.ts +132 -0
- package/src/terminal-sessions.ts +187 -0
- package/src/terminal-surface-id.ts +189 -0
- package/src/terminal-workspaces.ts +455 -0
- package/src/time.ts +49 -0
- package/dist/agent-address.d.ts +0 -1
- package/dist/agent-address.js +0 -1
- package/dist/agent-selectors.d.ts +0 -1
- package/dist/agent-selectors.js +0 -1
- package/src/agent-address.ts +0 -1
- package/src/agent-identity.test.ts +0 -435
- package/src/agent-selectors.ts +0 -1
- package/src/scout-agent-card.test.ts +0 -54
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-workspaces.d.ts","sourceRoot":"","sources":["../src/terminal-workspaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAErF,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElF;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,iFAAiF;IACjF,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,GAAG,IA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AAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,2BAA2B,CAAC;IACpC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,MAAM,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,+BAA+B,EAAE,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,uBAAuB,EAClC,KAAK,EAAE;IACL,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC3C,KAAK,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAC7C,iDAAiD;IACjD,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GACA,2BAA2B,CAS7B;AAwKD,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAGxE"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Durable terminal workspaces.
|
|
3
|
+
*
|
|
4
|
+
* A workspace is a named, server-owned arrangement of agent-CLI tiles. It is
|
|
5
|
+
* the Scout object the three clients had each invented privately —
|
|
6
|
+
* `openscout.terminal.workspaces.v1` in localStorage,
|
|
7
|
+
* `scout.terminals.workspaces.v1` in UserDefaults, and nothing at all on iOS —
|
|
8
|
+
* with the same version number, the same idea, and no synchronization.
|
|
9
|
+
*
|
|
10
|
+
* Where this stands TODAY, so nobody reads more into it than is built: the web
|
|
11
|
+
* client treats the record as its source of truth, seeding its deck from it and
|
|
12
|
+
* writing changes back. macOS still keeps its own UserDefaults store and has no
|
|
13
|
+
* reference to `/api/terminal-workspaces`, and iOS has nothing. "One workspace
|
|
14
|
+
* on all three clients" is the direction this type exists to make possible, not
|
|
15
|
+
* something it has delivered; the other two clients follow.
|
|
16
|
+
*
|
|
17
|
+
* The load-bearing design decision is that a cell stores INTENT, not just a
|
|
18
|
+
* binding. A saved cell that only remembers "tmux session scout-tmux-cell-7"
|
|
19
|
+
* is worth nothing after a reboot: tmux is empty and the name resolves to
|
|
20
|
+
* nothing. A cell that also remembers which host to use, what directory, and
|
|
21
|
+
* how to resume the harness can be rebuilt. This is the same conclusion
|
|
22
|
+
* tmux-resurrect/continuum reached — persist intent and replay it, never
|
|
23
|
+
* process state — and what macOS's `restoreCommandLine` already does in a
|
|
24
|
+
* cruder form.
|
|
25
|
+
*/
|
|
26
|
+
import { terminalSurfaceMatchesId, terminalSurfaceNodeId, terminalSurfaceNodeScopeMatches, } from "./terminal-sessions.js";
|
|
27
|
+
import { parseTerminalSurfaceId } from "./terminal-surface-id.js";
|
|
28
|
+
/** Highest column count a workspace may reopen with. */
|
|
29
|
+
export const TERMINAL_WORKSPACE_MAX_COLUMNS = 6;
|
|
30
|
+
export const TERMINAL_WORKSPACE_DEFAULT_COLUMNS = 2;
|
|
31
|
+
/**
|
|
32
|
+
* The layout a workspace should open with, folding a pre-layout record forward.
|
|
33
|
+
*
|
|
34
|
+
* A record written before layouts existed carries only a column count, so the
|
|
35
|
+
* mode is inferred from how that count relates to the cells: one cell is solo,
|
|
36
|
+
* a count that fits every cell on one row is lanes, anything else was a grid.
|
|
37
|
+
*/
|
|
38
|
+
export function terminalWorkspaceLayoutOf(input) {
|
|
39
|
+
if (input.layout?.mode) {
|
|
40
|
+
return {
|
|
41
|
+
mode: input.layout.mode,
|
|
42
|
+
...(input.layout.columns === undefined ? {} : { columns: normalizeTerminalWorkspaceColumnCount(input.layout.columns) }),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const cellCount = input.cellCount ?? 0;
|
|
46
|
+
const columns = normalizeTerminalWorkspaceColumns(input.columns ?? TERMINAL_WORKSPACE_DEFAULT_COLUMNS);
|
|
47
|
+
if (cellCount <= 1)
|
|
48
|
+
return { mode: "solo" };
|
|
49
|
+
if (columns >= cellCount)
|
|
50
|
+
return { mode: "lanes", columns };
|
|
51
|
+
return { mode: "grid", columns };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Column count to render with.
|
|
55
|
+
*
|
|
56
|
+
* Solo is always one. A dynamic lane count is the tile count, so every tile
|
|
57
|
+
* gets its own lane; a dynamic grid is the squarest arrangement that holds
|
|
58
|
+
* them. Both clamp, because past a handful of columns a terminal is too narrow
|
|
59
|
+
* to read.
|
|
60
|
+
*/
|
|
61
|
+
export function resolveTerminalWorkspaceColumns(layout, input) {
|
|
62
|
+
const tileCount = Math.max(1, Math.floor(input.tileCount) || 1);
|
|
63
|
+
if (layout.mode === "solo")
|
|
64
|
+
return 1;
|
|
65
|
+
if (layout.columns === undefined || layout.columns === "dynamic") {
|
|
66
|
+
const dynamic = layout.mode === "lanes" ? tileCount : Math.ceil(Math.sqrt(tileCount));
|
|
67
|
+
return Math.max(1, Math.min(TERMINAL_WORKSPACE_MAX_COLUMNS, dynamic));
|
|
68
|
+
}
|
|
69
|
+
return normalizeTerminalWorkspaceColumns(layout.columns);
|
|
70
|
+
}
|
|
71
|
+
export function normalizeTerminalWorkspaceColumnCount(value) {
|
|
72
|
+
return value === "dynamic" ? "dynamic" : normalizeTerminalWorkspaceColumns(value);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read a stored `layout_json` column back, or null when there is nothing
|
|
76
|
+
* trustworthy in it.
|
|
77
|
+
*
|
|
78
|
+
* Every store that persists a workspace decodes the layout through this, and
|
|
79
|
+
* that is the point: `layout_json` was added to the schema and then read by one
|
|
80
|
+
* handle and ignored by the other, so a layout written through the web server
|
|
81
|
+
* came back as `null` through the runtime store. One decoder means one answer.
|
|
82
|
+
*
|
|
83
|
+
* The mode is validated rather than trusted. It flows straight into the
|
|
84
|
+
* client's grid resolver, so a value that is not one of the three shapes must
|
|
85
|
+
* become "no stored layout" — which folds forward from the column count — and
|
|
86
|
+
* not a mode nothing can render.
|
|
87
|
+
*/
|
|
88
|
+
export function parseTerminalWorkspaceLayoutJson(value) {
|
|
89
|
+
if (!value)
|
|
90
|
+
return null;
|
|
91
|
+
let parsed;
|
|
92
|
+
try {
|
|
93
|
+
parsed = JSON.parse(value);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (!parsed || typeof parsed !== "object")
|
|
99
|
+
return null;
|
|
100
|
+
const candidate = parsed;
|
|
101
|
+
const mode = candidate.mode;
|
|
102
|
+
if (mode !== "solo" && mode !== "lanes" && mode !== "grid")
|
|
103
|
+
return null;
|
|
104
|
+
return {
|
|
105
|
+
mode,
|
|
106
|
+
...(candidate.columns === undefined
|
|
107
|
+
? {}
|
|
108
|
+
: { columns: normalizeTerminalWorkspaceColumnCount(candidate.columns) }),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function terminalWorkspaceLayoutLabel(layout) {
|
|
112
|
+
if (layout.mode === "solo")
|
|
113
|
+
return "Solo";
|
|
114
|
+
const shape = layout.mode === "lanes" ? "Lanes" : "Grid";
|
|
115
|
+
return layout.columns === undefined || layout.columns === "dynamic"
|
|
116
|
+
? `${shape} · dynamic`
|
|
117
|
+
: `${shape} · ${layout.columns} column${layout.columns === 1 ? "" : "s"}`;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Map every saved cell to a live surface, a restorable-but-dead one, or an
|
|
121
|
+
* unavailable one.
|
|
122
|
+
*
|
|
123
|
+
* This is the only honest answer to a reboot. tmux and zellij sessions do not
|
|
124
|
+
* survive a restart; a workspace that stored intent can rebuild itself, and one
|
|
125
|
+
* that stored only a session name cannot. Judgement lives here, on the server
|
|
126
|
+
* side of the wire, so all three clients inherit the same answer instead of
|
|
127
|
+
* each re-deriving it — and it never fabricates a record: a cell with nothing
|
|
128
|
+
* to rebuild from reports `unavailable` and says why.
|
|
129
|
+
*/
|
|
130
|
+
export function reconcileTerminalWorkspace(workspace, input) {
|
|
131
|
+
const cells = workspace.cells.map((cell) => resolveTerminalWorkspaceCell(cell, input));
|
|
132
|
+
return {
|
|
133
|
+
workspaceId: workspace.id,
|
|
134
|
+
cells,
|
|
135
|
+
liveCount: cells.filter((cell) => cell.status === "live").length,
|
|
136
|
+
revivableCount: cells.filter((cell) => cell.status === "revivable").length,
|
|
137
|
+
unavailableCount: cells.filter((cell) => cell.status === "unavailable").length,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function resolveTerminalWorkspaceCell(cell, input) {
|
|
141
|
+
const live = findLiveSurface(cell, input.sessions, input.localNodeId?.trim() || null);
|
|
142
|
+
if (live) {
|
|
143
|
+
return {
|
|
144
|
+
cellId: cell.id,
|
|
145
|
+
status: "live",
|
|
146
|
+
surfaceId: live.surface.surfaceId ?? cell.surfaceId ?? null,
|
|
147
|
+
terminalSessionId: live.session.id,
|
|
148
|
+
surface: live.surface,
|
|
149
|
+
detail: "Running",
|
|
150
|
+
revive: null,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const hostId = cell.intent.hostId ?? input.defaultHostId ?? null;
|
|
154
|
+
const sessionName = cell.intent.sessionName?.trim() || null;
|
|
155
|
+
if (!hostId || !sessionName) {
|
|
156
|
+
return unavailable(cell, "This tile was saved without enough detail to reopen it.");
|
|
157
|
+
}
|
|
158
|
+
const host = input.hosts.find((candidate) => candidate.id === hostId) ?? null;
|
|
159
|
+
if (!host) {
|
|
160
|
+
return unavailable(cell, `This tile needs ${hostId}, which Scout does not know about.`);
|
|
161
|
+
}
|
|
162
|
+
if (!host.installed) {
|
|
163
|
+
return unavailable(cell, `This tile needs ${hostId}, which is not installed here.`);
|
|
164
|
+
}
|
|
165
|
+
if (!host.canCreate) {
|
|
166
|
+
return unavailable(cell, `Scout cannot reopen ${hostId} sessions for you; open it there and come back.`);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
cellId: cell.id,
|
|
170
|
+
status: "revivable",
|
|
171
|
+
surfaceId: cell.surfaceId ?? null,
|
|
172
|
+
terminalSessionId: cell.terminalSessionId ?? null,
|
|
173
|
+
surface: null,
|
|
174
|
+
detail: "Not running. Scout can start it again.",
|
|
175
|
+
revive: {
|
|
176
|
+
hostId,
|
|
177
|
+
sessionName,
|
|
178
|
+
cwd: cell.intent.cwd?.trim() || null,
|
|
179
|
+
resumeCommand: cell.intent.resumeCommand?.trim() || null,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function unavailable(cell, detail) {
|
|
184
|
+
return {
|
|
185
|
+
cellId: cell.id,
|
|
186
|
+
status: "unavailable",
|
|
187
|
+
surfaceId: cell.surfaceId ?? null,
|
|
188
|
+
terminalSessionId: cell.terminalSessionId ?? null,
|
|
189
|
+
surface: null,
|
|
190
|
+
detail,
|
|
191
|
+
revive: null,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Whether a record is an OBSERVATION of the host rather than something Scout
|
|
196
|
+
* wrote down once. Only an observation can prove a surface is running.
|
|
197
|
+
*/
|
|
198
|
+
function isHostObservedRecord(session) {
|
|
199
|
+
// `metadata.registryState` is the pre-`origin` signal; both are honoured
|
|
200
|
+
// until every writer has moved over.
|
|
201
|
+
return session.origin === "discovered" || session.metadata?.registryState === "discovered";
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A cell binds to a live surface by durable handle first. The intent's session
|
|
205
|
+
* name is the fallback, because a surface re-created under the same name on the
|
|
206
|
+
* same host IS the tile's session — that is the whole point of stable per-cell
|
|
207
|
+
* names — while a record id is not enough on its own, since ids move when a
|
|
208
|
+
* discovered session is renamed.
|
|
209
|
+
*
|
|
210
|
+
* Two rules make the answer an observation instead of a memory, and a review
|
|
211
|
+
* reproduced what happens without them.
|
|
212
|
+
*
|
|
213
|
+
* Only a host-observed record can establish "live". A registry record is
|
|
214
|
+
* written once, at intake, with `state: "live"` baked in, and it is never
|
|
215
|
+
* updated again — so after a reboot every saved tile still resolved to
|
|
216
|
+
* `{status: "live", detail: "Running"}` against a host that had nothing on it.
|
|
217
|
+
* Scout was reporting its own filing cabinet back to the operator as the state
|
|
218
|
+
* of their machine.
|
|
219
|
+
*
|
|
220
|
+
* And only `state === "live"` counts. `detached` means different things per
|
|
221
|
+
* host — for tmux it is a running session with no client, for herdr it is a
|
|
222
|
+
* session whose server is STOPPED — so accepting "anything but exited" reported
|
|
223
|
+
* stopped herdr sessions as running. Hosts that stay attachable while detached
|
|
224
|
+
* report `live` from their adapter, so requiring it costs nothing and stops
|
|
225
|
+
* that.
|
|
226
|
+
*
|
|
227
|
+
* When an observation is found, the registry record for the same surface is
|
|
228
|
+
* preferred as the cell's record: it carries the harness and resume command a
|
|
229
|
+
* discovered record cannot know. The SURFACE always comes from the observation,
|
|
230
|
+
* because that is the one with the current state.
|
|
231
|
+
*
|
|
232
|
+
* The third rule is that a machine only speaks for itself. The name fallback is
|
|
233
|
+
* matched under the same node scoping as the handle, because otherwise it
|
|
234
|
+
* quietly reopened the hole the handle matcher closed: a cell scoped to `node-b`
|
|
235
|
+
* whose intent named `scout-tmux-cell-1` bound to THIS host's session of that
|
|
236
|
+
* name, so `node-a` and `node-b` both reported the one discovered session
|
|
237
|
+
* Running. One observed session never proves more than one node's workspace
|
|
238
|
+
* live.
|
|
239
|
+
*/
|
|
240
|
+
function findLiveSurface(cell, sessions, localNodeId) {
|
|
241
|
+
const observedSessions = sessions.filter(isHostObservedRecord);
|
|
242
|
+
const handle = cell.surfaceId?.trim() || null;
|
|
243
|
+
const sessionName = cell.intent.sessionName?.trim() || null;
|
|
244
|
+
const hostId = cell.intent.hostId ?? null;
|
|
245
|
+
// The cell's node is whatever its durable handle names; a cell with only an
|
|
246
|
+
// intent names no machine and keeps matching wherever it lands.
|
|
247
|
+
const cellNodeId = parseTerminalSurfaceId(handle)?.nodeId ?? null;
|
|
248
|
+
const matches = (surface) => {
|
|
249
|
+
if (surface.state !== "live")
|
|
250
|
+
return false;
|
|
251
|
+
if (handle && terminalSurfaceMatchesId(surface, handle, { localNodeId }))
|
|
252
|
+
return true;
|
|
253
|
+
if (!sessionName || surface.sessionName !== sessionName)
|
|
254
|
+
return false;
|
|
255
|
+
if (hostId && surface.backend !== hostId)
|
|
256
|
+
return false;
|
|
257
|
+
return terminalSurfaceNodeScopeMatches({
|
|
258
|
+
handleNodeId: cellNodeId,
|
|
259
|
+
surfaceNodeId: terminalSurfaceNodeId(surface),
|
|
260
|
+
localNodeId,
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
for (const session of observedSessions) {
|
|
264
|
+
const surface = session.surfaces.find(matches);
|
|
265
|
+
if (!surface)
|
|
266
|
+
continue;
|
|
267
|
+
// Under the same node rule: a registry record from another machine that
|
|
268
|
+
// happens to hold this session name is not the identity of the session
|
|
269
|
+
// observed here, and lending it would put a foreign record id on a local
|
|
270
|
+
// surface.
|
|
271
|
+
const registryRecord = sessions.find((candidate) => !isHostObservedRecord(candidate)
|
|
272
|
+
&& candidate.surfaces.some((known) => known.backend === surface.backend
|
|
273
|
+
&& known.sessionName === surface.sessionName
|
|
274
|
+
&& terminalSurfaceNodeScopeMatches({
|
|
275
|
+
handleNodeId: terminalSurfaceNodeId(known),
|
|
276
|
+
surfaceNodeId: terminalSurfaceNodeId(surface),
|
|
277
|
+
localNodeId,
|
|
278
|
+
})));
|
|
279
|
+
return { session: registryRecord ?? session, surface };
|
|
280
|
+
}
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
export function normalizeTerminalWorkspaceColumns(value) {
|
|
284
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
285
|
+
return TERMINAL_WORKSPACE_DEFAULT_COLUMNS;
|
|
286
|
+
return Math.max(1, Math.min(TERMINAL_WORKSPACE_MAX_COLUMNS, Math.floor(value)));
|
|
287
|
+
}
|
package/dist/thread-events.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-events.d.ts","sourceRoot":"","sources":["../src/thread-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEjE,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,gBAAgB,GAChB,wBAAwB,GACxB,8BAA8B,GAC9B,qBAAqB,GACrB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnD,MAAM,MAAM,sBAAsB,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtE,MAAM,MAAM,wBAAwB,GAChC,SAAS,GACT,cAAc,GACd,WAAW,GACX,kBAAkB,GAClB,eAAe,CAAC;AAEpB,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO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AE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,cAAc,GACd,WAAW,GACX,sBAAsB,GACtB,eAAe,GACf,qBAAqB,GACrB,iBAAiB,GACjB,UAAU,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/time.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const epochMsBrand: unique symbol;
|
|
2
|
+
declare const durationMsBrand: unique symbol;
|
|
3
|
+
export type EpochMs = number & {
|
|
4
|
+
readonly [epochMsBrand]: "EpochMs";
|
|
5
|
+
};
|
|
6
|
+
export type DurationMs = number & {
|
|
7
|
+
readonly [durationMsBrand]: "DurationMs";
|
|
8
|
+
};
|
|
9
|
+
export declare const EPOCH_MILLISECONDS_FLOOR = 1000000000000;
|
|
10
|
+
export declare function nowMs(): EpochMs;
|
|
11
|
+
export declare function epochMs(value: unknown): EpochMs | null;
|
|
12
|
+
export declare function epochMsFromSeconds(value: number): EpochMs;
|
|
13
|
+
export declare function durationMs(value: number): DurationMs;
|
|
14
|
+
export declare function toIso(ms: EpochMs): string;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,YAAY,EAAE,OAAO,MAAM,CAAC;AAC1C,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,MAAM,CAAC;AAE7C,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AACtE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,eAAe,CAAC,EAAE,YAAY,CAAA;CAAE,CAAC;AAE/E,eAAO,MAAM,wBAAwB,gBAAoB,CAAC;AAc1D,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAYtD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAEzC"}
|
package/dist/time.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const EPOCH_MILLISECONDS_FLOOR = 1_000_000_000_000;
|
|
2
|
+
function isFinitePositive(value) {
|
|
3
|
+
return Number.isFinite(value) && value > 0;
|
|
4
|
+
}
|
|
5
|
+
function requireFinitePositive(value, label) {
|
|
6
|
+
if (!isFinitePositive(value)) {
|
|
7
|
+
throw new RangeError(`${label} must be a finite positive number`);
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
export function nowMs() {
|
|
12
|
+
return Date.now();
|
|
13
|
+
}
|
|
14
|
+
export function epochMs(value) {
|
|
15
|
+
const parsed = typeof value === "number"
|
|
16
|
+
? value
|
|
17
|
+
: typeof value === "string"
|
|
18
|
+
? Number(value)
|
|
19
|
+
: null;
|
|
20
|
+
if (parsed === null || !isFinitePositive(parsed)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return Math.trunc(parsed < EPOCH_MILLISECONDS_FLOOR ? parsed * 1000 : parsed);
|
|
24
|
+
}
|
|
25
|
+
export function epochMsFromSeconds(value) {
|
|
26
|
+
return Math.trunc(requireFinitePositive(value, "Epoch seconds") * 1000);
|
|
27
|
+
}
|
|
28
|
+
export function durationMs(value) {
|
|
29
|
+
return Math.trunc(requireFinitePositive(value, "Duration milliseconds"));
|
|
30
|
+
}
|
|
31
|
+
export function toIso(ms) {
|
|
32
|
+
return new Date(ms).toISOString();
|
|
33
|
+
}
|
package/dist/transports.d.ts
CHANGED
|
@@ -64,3 +64,4 @@ export interface CollaborationEventAppendCommand {
|
|
|
64
64
|
event: CollaborationEvent;
|
|
65
65
|
}
|
|
66
66
|
export type ControlCommand = NodeUpsertCommand | ActorUpsertCommand | AgentUpsertCommand | AgentEndpointUpsertCommand | ConversationUpsertCommand | BindingUpsertCommand | CollaborationUpsertCommand | CollaborationEventAppendCommand | PostMessageCommand | InvokeAgentCommand | EnsureAwakeCommand | SubscribeCommand;
|
|
67
|
+
//# sourceMappingURL=transports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../src/transports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACtF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAElF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,W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GACtB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,GAClB,0BAA0B,GAC1B,yBAAyB,GACzB,oBAAoB,GACpB,0BAA0B,GAC1B,+BAA+B,GAC/B,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openscout/protocol",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.83",
|
|
4
4
|
"description": "Typed protocol for the OpenScout local control plane",
|
|
5
|
+
"license": "Apache-2.0",
|
|
5
6
|
"type": "module",
|
|
7
|
+
"author": "Arach Tchoupani",
|
|
8
|
+
"homepage": "https://github.com/oscout/scout/tree/main/packages/protocol#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/oscout/scout.git",
|
|
12
|
+
"directory": "packages/protocol"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/oscout/scout/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"openscout",
|
|
19
|
+
"protocol",
|
|
20
|
+
"agents",
|
|
21
|
+
"broker",
|
|
22
|
+
"control-plane",
|
|
23
|
+
"a2a",
|
|
24
|
+
"typescript"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
6
27
|
"exports": {
|
|
7
28
|
".": {
|
|
8
|
-
"types": "./src/index.ts",
|
|
9
29
|
"bun": "./src/index.ts",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
10
32
|
"default": "./dist/index.js"
|
|
11
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
12
35
|
},
|
|
13
|
-
"types": "./
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
14
37
|
"files": [
|
|
15
|
-
"src",
|
|
16
38
|
"dist",
|
|
17
|
-
"
|
|
39
|
+
"src",
|
|
40
|
+
"!src/**/*.test.ts",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE"
|
|
18
43
|
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
},
|
|
19
47
|
"scripts": {
|
|
48
|
+
"prebuild": "bun ../../scripts/generate-runtime-catalog.ts",
|
|
20
49
|
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
50
|
+
"precheck": "bun ../../scripts/generate-runtime-catalog.ts",
|
|
21
51
|
"check": "tsc --noEmit -p tsconfig.json",
|
|
22
52
|
"test": "bun test src/*.test.ts",
|
|
23
53
|
"prepack": "npm run build && node ../../scripts/prepare-publish-manifest.mjs .",
|
|
54
|
+
"postpack": "node ../../scripts/restore-publish-manifest.mjs .",
|
|
24
55
|
"postpublish": "node ../../scripts/restore-publish-manifest.mjs ."
|
|
25
56
|
},
|
|
26
|
-
"publishConfig": {
|
|
27
|
-
"access": "public"
|
|
28
|
-
},
|
|
29
57
|
"devDependencies": {
|
|
30
58
|
"typescript": "^5"
|
|
31
59
|
}
|