@skrr-ai/cli 0.1.88 → 0.1.90
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/dist/commands/machines/computer-adoption.d.ts +3 -2
- package/dist/commands/machines/computer-adoption.js +4 -3
- package/dist/commands/machines/dedicated/agent-browser.d.ts +25 -0
- package/dist/commands/machines/dedicated/agent-browser.js +65 -0
- package/dist/commands/machines/dedicated/exec.js +60 -14
- package/dist/commands/machines/dedicated/index.js +2 -0
- package/dist/commands/machines/dedicated/power/explain.d.ts +13 -0
- package/dist/commands/machines/dedicated/power/explain.js +36 -0
- package/dist/commands/machines/dedicated/power/index.d.ts +10 -0
- package/dist/commands/machines/dedicated/power/index.js +24 -0
- package/dist/commands/machines/dedicated/power/keep-awake.d.ts +20 -0
- package/dist/commands/machines/dedicated/power/keep-awake.js +69 -0
- package/dist/commands/machines/dedicated/power/set.d.ts +23 -0
- package/dist/commands/machines/dedicated/power/set.js +106 -0
- package/dist/commands/machines/dedicated/power/show.d.ts +13 -0
- package/dist/commands/machines/dedicated/power/show.js +36 -0
- package/dist/commands/machines/dedicated/show.js +17 -2
- package/dist/lib/commitments.d.ts +1 -1
- package/dist/lib/commitments.js +4 -2
- package/dist/lib/computer-adoption.d.ts +5 -0
- package/dist/lib/computer-adoption.js +6 -1
- package/dist/lib/computer-consent.d.ts +43 -1
- package/dist/lib/computer-consent.js +125 -4
- package/dist/lib/dedicated-keep-awake.d.ts +19 -0
- package/dist/lib/dedicated-keep-awake.js +64 -0
- package/dist/lib/dedicated-machines.d.ts +31 -0
- package/dist/lib/dedicated-machines.js +40 -0
- package/dist/lib/dedicated-power.d.ts +61 -0
- package/dist/lib/dedicated-power.js +243 -0
- package/dist/lib/exec-runtime-binary.d.ts +3 -1
- package/dist/lib/exec-runtime-binary.js +16 -2
- package/dist/lib/format.d.ts +13 -0
- package/dist/lib/format.js +51 -0
- package/dist/lib/keychain.js +3 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerWire.d.ts +135 -8
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/computerWire.js +166 -16
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dedicatedRuntimeBusyWire.d.ts +107 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dedicatedRuntimeBusyWire.js +151 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dedicatedRuntimeWakeWire.d.ts +115 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/dedicatedRuntimeWakeWire.js +117 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +8 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.d.ts +31 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/machineUuid.js +149 -9
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerWire.d.ts +135 -8
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/computerWire.js +161 -13
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dedicatedRuntimeBusyWire.d.ts +107 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dedicatedRuntimeBusyWire.js +147 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dedicatedRuntimeWakeWire.d.ts +115 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/dedicatedRuntimeWakeWire.js +113 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.d.ts +31 -7
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/machineUuid.js +144 -8
- package/dist/node_modules/@skrr-ai/auth-core/package.json +21 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +6730 -6366
- package/dist/node_modules/@skrr-ai/data-provider/package.json +1 -1
- package/oclif.manifest.json +6303 -5852
- package/package.json +2 -2
|
@@ -25,16 +25,18 @@
|
|
|
25
25
|
* dropped every command event for a release (OSK-13605).
|
|
26
26
|
*/
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
exports.
|
|
30
|
-
exports.COMPUTER_LEASE_STATE_POWER_PHASE = exports.COMPUTER_START_REFUSALS = exports.COMPUTER_PERSONAL_SIGN_IN_REASONS = exports.COMPUTER_PERSONAL_POWER_PHASES = exports.COMPUTER_POWER_PHASES = exports.COMPUTER_MACHINE_KINDS = void 0;
|
|
28
|
+
exports.COMPUTER_BROWSER_DIALOG_KINDS = exports.COMPUTER_INPUT_TEXT_MAX_LENGTH = exports.COMPUTER_BROWSER_INPUT_PLATFORMS = exports.COMPUTER_BROWSER_VIEWPORT_LIMITS = exports.COMPUTER_BROWSER_INPUT_TYPES = exports.COMPUTER_TERMINAL_CAVEATS = exports.COMPUTER_TERMINAL_HISTORY_CAUSES = exports.COMPUTER_TERMINAL_LIFETIMES = exports.COMPUTER_TERMINAL_INPUT_TYPES = exports.COMPUTER_TERMINAL_SIGNALS = exports.COMPUTER_DIAGNOSTICS_MAX_STREAMS = exports.COMPUTER_DIAGNOSTICS_INTERVAL_MS = exports.COMPUTER_DIAGNOSTIC_COUNTERS = exports.COMPUTER_FRAME_ACK_TIMEOUT_MS = exports.COMPUTER_FRAME_MAX_BYTES = exports.COMPUTER_BROWSER_VIEWPORT = exports.COMPUTER_SURFACE_END_REASONS = exports.COMPUTER_SURFACE_STATES = exports.COMPUTER_SURFACE_KINDS = exports.COMPUTER_CONTROL_ACTIVITY_CHANGES = exports.COMPUTER_CONTROL_CHANGE_REASONS = exports.COMPUTER_SURFACE_UNPIN_REASONS = exports.COMPUTER_SURFACE_PIN_ACTIONS = exports.COMPUTER_SHARE_MODES = exports.COMPUTER_SHARE_ACTIONS = exports.COMPUTER_CONTROL_ACTIONS = exports.COMPUTER_AGENT_WRITE_WAIT_MS = exports.COMPUTER_RECONNECT_GRACE_MS = exports.COMPUTER_RECLAIM_WARNING_MS = exports.COMPUTER_CONTROL_IDLE_MS = exports.COMPUTER_HANDBACK_NOTE_MAX_LENGTH = exports.COMPUTER_GRANT_TIERS = exports.COMPUTER_OPERATIONS = exports.COMPUTER_ACCESS_LEVELS = exports.COMPUTER_ACTOR_ENGINE_MAX_LENGTH = exports.COMPUTER_PLATFORM_ROUTE_SESSION_PREFIXES = exports.COMPUTER_ACTIVITY_ACTOR_KINDS = exports.COMPUTER_ACTOR_KINDS = exports.COMPUTER_REFUSAL_CODES = exports.COMPUTER_CAPABILITY_VALUES = exports.COMPUTER_CAPABILITIES = exports.COMPUTER_MANIFEST_REORDER_WAIT_MS = exports.COMPUTER_RESYNC_TIMEOUT_MS = exports.COMPUTER_API_ANSWERED_EVENT_KEYS = exports.COMPUTER_SERVER_EVENT_KEYS = exports.DAEMON_COMPUTER_REPORT_EVENT_KEYS = exports.DAEMON_COMPUTER_EVENT_NAMES = exports.COMPUTER_EVENT_NAMES = exports.DAEMON_COMPUTER_EVENTS = exports.COMPUTER_EVENTS = void 0;
|
|
29
|
+
exports.COMPUTER_DECLARED_SERVICES_MAX = exports.COMPUTER_DECLARED_SERVICE_PROTOCOLS = exports.COMPUTER_SERVICES_TOOL_ERROR_PREFIX = exports.COMPUTER_SERVICES_TOOL_NAME = exports.COMPUTER_DECLARED_SERVICE_ACTIONS = exports.COMPUTER_COMMAND_OUTPUT_STREAMS = exports.COMPUTER_COMMAND_START_REFUSALS = exports.COMPUTER_COMMAND_UNKNOWN_END_SIGNAL = exports.COMPUTER_COMMAND_NOT_STARTED_SIGNAL = exports.COMPUTER_COMMAND_OUTCOMES = exports.COMPUTER_LIFECYCLE_EVENTS = exports.COMPUTER_COMMAND_PHASES = exports.COMPUTER_ACTIVITY_WITHHELD_PLACEHOLDER = exports.COMPUTER_ACTIVITY_OUTPUT_MAX_LENGTH = exports.COMPUTER_ACTIVITY_SUMMARY_MAX_LENGTH = exports.COMPUTER_ACTIVITY_KINDS = exports.COMPUTER_FILE_CONTENTS_TAG_PATTERN = exports.COMPUTER_FILE_CONTENTS_TAG_MAX_ENTRIES = exports.COMPUTER_FILE_CHANGES = exports.COMPUTER_FILES_CHANGED_MAX_CHANGES = exports.COMPUTER_FILES_WATCH_DEGRADED_REASONS = exports.COMPUTER_FILE_WITHHELD_REASONS = exports.COMPUTER_FILE_TYPES = exports.COMPUTER_FILE_GIT_STATUS_BUDGET_MS = exports.COMPUTER_FILE_SEARCH_MAX_QUERY_LENGTH = exports.COMPUTER_FILE_SEARCH_MAX_BUDGET_MS = exports.COMPUTER_FILE_SEARCH_DEFAULT_BUDGET_MS = exports.COMPUTER_FILE_SEARCH_MAX_LIMIT = exports.COMPUTER_FILE_SEARCH_DEFAULT_LIMIT = exports.COMPUTER_FILE_GIT_MARKS = exports.COMPUTER_FILE_SEARCH_STATES = exports.COMPUTER_FILE_SEARCH_OPERATIONS = exports.COMPUTER_FILE_OPERATIONS = exports.COMPUTER_BROWSER_URL_MAX_LENGTH = exports.COMPUTER_BROWSER_TAB_ACTIONS = exports.COMPUTER_BROWSER_HISTORY_ACTIONS = exports.COMPUTER_BROWSER_COPY_MAX_LENGTH = exports.COMPUTER_TERMINAL_CWD_MAX_LENGTH = exports.COMPUTER_BROWSER_FILE_CHOOSER_PATH_MAX_LENGTH = exports.COMPUTER_BROWSER_FILE_CHOOSER_ACCEPT_MAX_LENGTH = exports.COMPUTER_BROWSER_FILE_CHOOSER_MAX_FILES = exports.COMPUTER_BROWSER_FILE_CHOOSER_OUTCOMES = exports.COMPUTER_BROWSER_FILE_CHOOSER_MODES = exports.COMPUTER_BROWSER_DOWNLOADS_MAX = exports.COMPUTER_BROWSER_DOWNLOAD_STATES = exports.COMPUTER_BROWSER_DIALOG_CREDENTIAL_MAX_LENGTH = exports.COMPUTER_BROWSER_DIALOG_PROMPT_MAX_LENGTH = exports.COMPUTER_BROWSER_DIALOG_MESSAGE_MAX_LENGTH = exports.COMPUTER_BROWSER_DIALOG_ANSWERERS = exports.COMPUTER_BROWSER_DIALOG_OUTCOMES = void 0;
|
|
30
|
+
exports.COMPUTER_LEASE_STATE_POWER_PHASE = exports.COMPUTER_START_REFUSALS = exports.COMPUTER_PERSONAL_SIGN_IN_REASONS = exports.COMPUTER_PERSONAL_POWER_PHASES = exports.COMPUTER_POWER_PHASES = exports.COMPUTER_MACHINE_KINDS = exports.COMPUTER_DECLARED_SERVICE_PROBLEMS = exports.COMPUTER_DECLARED_SERVICE_NAME_PATTERN = exports.COMPUTER_DECLARED_SERVICE_HOST = exports.COMPUTER_DECLARED_SERVICE_PATH_MAX_LENGTH = exports.COMPUTER_DECLARED_SERVICE_NAME_MAX_LENGTH = void 0;
|
|
31
31
|
exports.normalizeComputerRefusalCode = normalizeComputerRefusalCode;
|
|
32
|
+
exports.isComputerPlatformRouteSession = isComputerPlatformRouteSession;
|
|
32
33
|
exports.computerTierOperations = computerTierOperations;
|
|
33
34
|
exports.computerOperationAllowed = computerOperationAllowed;
|
|
34
35
|
exports.computerAccessOperations = computerAccessOperations;
|
|
35
36
|
exports.computerControlChangeIsHolderChange = computerControlChangeIsHolderChange;
|
|
36
37
|
exports.computerLeaseInputRefusal = computerLeaseInputRefusal;
|
|
37
38
|
exports.computerLeaseAcceptsInput = computerLeaseAcceptsInput;
|
|
39
|
+
exports.clampComputerBrowserViewport = clampComputerBrowserViewport;
|
|
38
40
|
exports.computerFileEntityTagsEqual = computerFileEntityTagsEqual;
|
|
39
41
|
exports.computerDeclaredServiceOperation = computerDeclaredServiceOperation;
|
|
40
42
|
exports.computerDeclaredServiceSpec = computerDeclaredServiceSpec;
|
|
@@ -55,6 +57,22 @@ exports.COMPUTER_EVENTS = {
|
|
|
55
57
|
attach: 'computer:attach',
|
|
56
58
|
/** client → API: leave. */
|
|
57
59
|
detach: 'computer:detach',
|
|
60
|
+
/**
|
|
61
|
+
* client → API: read the whole manifest again ON THE SAME ATTACHMENT, after
|
|
62
|
+
* a missed delta or a `stale_epoch` (OSK-13815). The ack carries what an
|
|
63
|
+
* attach's does — the attachment id (unchanged), the manifest and the
|
|
64
|
+
* operations — or a typed refusal; `not_found` means the attachment is gone
|
|
65
|
+
* and only then does the client attach afresh. Re-reading state must never
|
|
66
|
+
* change who the reader is: a control lease is bound to the attachment
|
|
67
|
+
* (`holderAttachmentId`), and a resync that detached and attached again
|
|
68
|
+
* orphaned the hold the person had just taken. Answered by the API, which
|
|
69
|
+
* renews the binding with the daemon exactly as its periodic re-check does
|
|
70
|
+
* (a repeated `daemon:computer:attach` with the same id), so it has no
|
|
71
|
+
* daemon mirror and needs no daemon capability. An API that predates it
|
|
72
|
+
* never answers; the client bounds the wait and falls back to attaching
|
|
73
|
+
* afresh.
|
|
74
|
+
*/
|
|
75
|
+
resync: 'computer:resync',
|
|
58
76
|
/** API → client: this attachment was detached, with the reason (revoked, stale generation, …). */
|
|
59
77
|
detached: 'computer:detached',
|
|
60
78
|
/** API → client: a whole manifest, or a revisioned delta. */
|
|
@@ -196,6 +214,24 @@ exports.COMPUTER_SERVER_EVENT_KEYS = [
|
|
|
196
214
|
'activity',
|
|
197
215
|
'filesChanged',
|
|
198
216
|
];
|
|
217
|
+
/**
|
|
218
|
+
* Client → API requests the API answers itself, with no `daemon:computer:*`
|
|
219
|
+
* mirror: every other client request is relayed to the daemon under the same
|
|
220
|
+
* key. `resync` renews the binding through the daemon's existing attach
|
|
221
|
+
* (OSK-13815).
|
|
222
|
+
*/
|
|
223
|
+
exports.COMPUTER_API_ANSWERED_EVENT_KEYS = [
|
|
224
|
+
'resync',
|
|
225
|
+
];
|
|
226
|
+
/** How long the client waits for a `computer:resync` answer before attaching afresh (an API that predates it never answers). */
|
|
227
|
+
exports.COMPUTER_RESYNC_TIMEOUT_MS = 12_000;
|
|
228
|
+
/**
|
|
229
|
+
* How long a client holds a manifest delta that arrived AHEAD of its
|
|
230
|
+
* predecessor before reading the hole as a loss (OSK-13815). Deltas fan out
|
|
231
|
+
* through a relay of several replicas; a reorder is milliseconds, a loss is
|
|
232
|
+
* forever, and only a loss needs the whole manifest again.
|
|
233
|
+
*/
|
|
234
|
+
exports.COMPUTER_MANIFEST_REORDER_WAIT_MS = 300;
|
|
199
235
|
// ---------------------------------------------------------------------------
|
|
200
236
|
// Capabilities (§7.1)
|
|
201
237
|
// ---------------------------------------------------------------------------
|
|
@@ -300,6 +336,42 @@ exports.COMPUTER_CAPABILITIES = {
|
|
|
300
336
|
* browser; nothing is proxied to it. Announced by the relay that serves it.
|
|
301
337
|
*/
|
|
302
338
|
declaredServices: 'computer_declared_services_v1',
|
|
339
|
+
/**
|
|
340
|
+
* The page follows the controlling window (§6.2 "a stable viewport", §7.1,
|
|
341
|
+
* OSK-13808): a browser `viewport` input, sent only by the attachment that
|
|
342
|
+
* holds the browser's lease at the current epoch, sizes the streamed page
|
|
343
|
+
* to that window's content box (`COMPUTER_BROWSER_VIEWPORT_LIMITS`). Only
|
|
344
|
+
* while a person holds control: handing back — or the hold lapsing, being
|
|
345
|
+
* revoked or moving to the agent any other way — restores the browser's own
|
|
346
|
+
* viewport before the agent can act, so an agent never inherits a person's
|
|
347
|
+
* size. Watchers keep seeing the page at whatever size it is, scaled to
|
|
348
|
+
* fit. Announced only where the browser driver can override and restore
|
|
349
|
+
* the page's metrics; without it the window scales the fixed page, as
|
|
350
|
+
* before, and never sends the input.
|
|
351
|
+
*/
|
|
352
|
+
browserViewport: 'computer_browser_viewport_v1',
|
|
353
|
+
/**
|
|
354
|
+
* A browser surface whose browser is still starting says so (OSK-13824): its
|
|
355
|
+
* descriptor carries `starting: { since }` from the moment its Chromium
|
|
356
|
+
* begins to launch until that launch ends (running, or failed), and the
|
|
357
|
+
* window shows "Starting the browser…" instead of subscribing into a
|
|
358
|
+
* refusal. A cold start on a fresh guest takes 25–30 s. A daemon announcing
|
|
359
|
+
* this states the ABSENCE of `starting` too: a browser surface without it
|
|
360
|
+
* is not starting. Without the announcement a client cannot tell, and falls
|
|
361
|
+
* back to reading a surface it saw open moments ago as starting.
|
|
362
|
+
*/
|
|
363
|
+
browserStarting: 'computer_browser_starting_v1',
|
|
364
|
+
/**
|
|
365
|
+
* An agent actor on the machine's activity and control leases (OSK-13827)
|
|
366
|
+
* names the REAL agent: `agentId` is the agent's own id for tool-call and
|
|
367
|
+
* browser sessions too (v1 daemons put the SESSION id there for tool calls,
|
|
368
|
+
* so no reader could ever name them), and may carry `engine`, the harness
|
|
369
|
+
* the session runs on, so one agent's sessions on different engines can be
|
|
370
|
+
* told apart. A daemon announcing this states what it sends; the server
|
|
371
|
+
* withholds `engine` from every other daemon's actors, and a reader treats
|
|
372
|
+
* an actor without it as it always did.
|
|
373
|
+
*/
|
|
374
|
+
activityActorV2: 'computer_activity_actor_v2',
|
|
303
375
|
};
|
|
304
376
|
exports.COMPUTER_CAPABILITY_VALUES = Object.values(exports.COMPUTER_CAPABILITIES);
|
|
305
377
|
// ---------------------------------------------------------------------------
|
|
@@ -341,6 +413,12 @@ exports.COMPUTER_REFUSAL_CODES = [
|
|
|
341
413
|
'machine_unavailable',
|
|
342
414
|
/** The machine's daemon is not answering. */
|
|
343
415
|
'daemon_unreachable',
|
|
416
|
+
/**
|
|
417
|
+
* The relay failed while answering — an exception, not a fact about the
|
|
418
|
+
* machine. Retryable; the API log carries the same `correlationId`
|
|
419
|
+
* (OSK-13823). Never `machine_unavailable`, which says the machine is down.
|
|
420
|
+
*/
|
|
421
|
+
'relay_error',
|
|
344
422
|
/** A bounded wait ran out (§7.2 R4). */
|
|
345
423
|
'timeout',
|
|
346
424
|
'invalid_request',
|
|
@@ -354,22 +432,16 @@ exports.COMPUTER_REFUSAL_CODES = [
|
|
|
354
432
|
'service_limit',
|
|
355
433
|
];
|
|
356
434
|
/**
|
|
357
|
-
*
|
|
358
|
-
*
|
|
435
|
+
* The code when it is a computer refusal, else `null`. There is one spelling
|
|
436
|
+
* per code: the browser's older spelling of `human_control` was accepted for
|
|
437
|
+
* one release and retired with the old browser events (§5.2, OSK-13509).
|
|
359
438
|
*/
|
|
360
|
-
exports.COMPUTER_LEGACY_REFUSAL_SPELLINGS = Object.freeze({
|
|
361
|
-
live_view_active: 'human_control',
|
|
362
|
-
});
|
|
363
|
-
/** The canonical code for a received spelling, or `null` when it is not a computer refusal. */
|
|
364
439
|
function normalizeComputerRefusalCode(code) {
|
|
365
440
|
if (typeof code !== 'string') {
|
|
366
441
|
return null;
|
|
367
442
|
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
return Object.prototype.hasOwnProperty.call(exports.COMPUTER_LEGACY_REFUSAL_SPELLINGS, code)
|
|
372
|
-
? exports.COMPUTER_LEGACY_REFUSAL_SPELLINGS[code]
|
|
443
|
+
return exports.COMPUTER_REFUSAL_CODES.includes(code)
|
|
444
|
+
? code
|
|
373
445
|
: null;
|
|
374
446
|
}
|
|
375
447
|
// ---------------------------------------------------------------------------
|
|
@@ -384,6 +456,27 @@ exports.COMPUTER_ACTOR_KINDS = ['agent', 'human'];
|
|
|
384
456
|
* API and a client saw a `seq` hole no fill could close.
|
|
385
457
|
*/
|
|
386
458
|
exports.COMPUTER_ACTIVITY_ACTOR_KINDS = [...exports.COMPUTER_ACTOR_KINDS, 'system'];
|
|
459
|
+
/**
|
|
460
|
+
* The session ids the PLATFORM's own routes run daemon tools under — the web
|
|
461
|
+
* Files surface (`computer-files:` on a personal machine, `dedicated-runtime:`
|
|
462
|
+
* on a Dedicated Runtime) and the owner's `skrr machines dedicated` commands.
|
|
463
|
+
* No agent and no model is behind such a session: the person who asked is
|
|
464
|
+
* known to the API (which audits it), not to the daemon. So an activity event
|
|
465
|
+
* produced under one names no agent (OSK-13790: a person's upload used to read
|
|
466
|
+
* "agent created …"). Built by `ComputerFileService.runPersonalMachineTool`
|
|
467
|
+
* and `DedicatedRuntimeMachineAccess.runDedicatedRuntimeTool`.
|
|
468
|
+
*/
|
|
469
|
+
exports.COMPUTER_PLATFORM_ROUTE_SESSION_PREFIXES = [
|
|
470
|
+
'dedicated-runtime:',
|
|
471
|
+
'computer-files:',
|
|
472
|
+
];
|
|
473
|
+
/** Whether a tool call's session is one of the platform's own routes, not an agent's. */
|
|
474
|
+
function isComputerPlatformRouteSession(sessionId) {
|
|
475
|
+
return (typeof sessionId === 'string' &&
|
|
476
|
+
exports.COMPUTER_PLATFORM_ROUTE_SESSION_PREFIXES.some((prefix) => sessionId.startsWith(prefix)));
|
|
477
|
+
}
|
|
478
|
+
/** The longest `engine` the wire carries; a longer one is not an engine name. */
|
|
479
|
+
exports.COMPUTER_ACTOR_ENGINE_MAX_LENGTH = 64;
|
|
387
480
|
/**
|
|
388
481
|
* How a person present on the machine reached it: as its owner, or through a
|
|
389
482
|
* grant at one of the two tiers. Agents carry no access level — an agent
|
|
@@ -552,7 +645,11 @@ exports.COMPUTER_SURFACE_END_REASONS = [
|
|
|
552
645
|
/** Someone signed the computer's browser out everywhere, which ends every browser window. */
|
|
553
646
|
'browser_reset',
|
|
554
647
|
];
|
|
555
|
-
/**
|
|
648
|
+
/**
|
|
649
|
+
* The browser's logical viewport whoever is looking (§6.2): what the agent
|
|
650
|
+
* always works at. A person holding control may size the page to their window
|
|
651
|
+
* (`computer_browser_viewport_v1`); handing back restores this.
|
|
652
|
+
*/
|
|
556
653
|
exports.COMPUTER_BROWSER_VIEWPORT = Object.freeze({ width: 1280, height: 800 });
|
|
557
654
|
/** One frame never exceeds this, so it fits the SSE transport every guest uses (§7.2 R7). */
|
|
558
655
|
exports.COMPUTER_FRAME_MAX_BYTES = 1024 * 1024;
|
|
@@ -626,7 +723,10 @@ exports.COMPUTER_TERMINAL_HISTORY_CAUSES = [
|
|
|
626
723
|
* verified (OSK-13535).
|
|
627
724
|
*/
|
|
628
725
|
exports.COMPUTER_TERMINAL_CAVEATS = ['windows_pty_unverified'];
|
|
629
|
-
/**
|
|
726
|
+
/**
|
|
727
|
+
* Input a browser surface takes. `tab` needs `computer_browser_tabs_v1`;
|
|
728
|
+
* `viewport` needs `computer_browser_viewport_v1`.
|
|
729
|
+
*/
|
|
630
730
|
exports.COMPUTER_BROWSER_INPUT_TYPES = [
|
|
631
731
|
'pointer',
|
|
632
732
|
'key',
|
|
@@ -634,7 +734,57 @@ exports.COMPUTER_BROWSER_INPUT_TYPES = [
|
|
|
634
734
|
'navigate',
|
|
635
735
|
'history',
|
|
636
736
|
'tab',
|
|
737
|
+
'viewport',
|
|
637
738
|
];
|
|
739
|
+
/**
|
|
740
|
+
* What a `viewport` input may ask of the page (OSK-13808), in CSS pixels: the
|
|
741
|
+
* controlling window's content box, bounded so no window can make the page
|
|
742
|
+
* absurd for the agent that gets it back, and aspect-clamped (`minAspect` and
|
|
743
|
+
* `maxAspect` are width ÷ height) so a sliver of a window cannot either.
|
|
744
|
+
* Device pixel ratio is not part of it: the page keeps the browser's own, so a
|
|
745
|
+
* high-density screen changes no layout and no picture size.
|
|
746
|
+
*/
|
|
747
|
+
exports.COMPUTER_BROWSER_VIEWPORT_LIMITS = Object.freeze({
|
|
748
|
+
minWidth: 320,
|
|
749
|
+
maxWidth: 2560,
|
|
750
|
+
minHeight: 240,
|
|
751
|
+
maxHeight: 1600,
|
|
752
|
+
minAspect: 0.4,
|
|
753
|
+
maxAspect: 3.2,
|
|
754
|
+
});
|
|
755
|
+
/**
|
|
756
|
+
* The size a `viewport` input asks for, made legal: whole CSS pixels inside
|
|
757
|
+
* `COMPUTER_BROWSER_VIEWPORT_LIMITS`, its aspect inside the clamp. Total and
|
|
758
|
+
* idempotent: the window sends what this returns and the daemon applies what
|
|
759
|
+
* this returns, so both ends agree on the page a size produces. Null for a size
|
|
760
|
+
* with no area (a hidden or collapsed window asks for nothing).
|
|
761
|
+
*/
|
|
762
|
+
function clampComputerBrowserViewport(size) {
|
|
763
|
+
const { width: rawWidth, height: rawHeight } = size ?? {};
|
|
764
|
+
if (!Number.isFinite(rawWidth) || !Number.isFinite(rawHeight))
|
|
765
|
+
return null;
|
|
766
|
+
if (!(rawWidth > 0) || !(rawHeight > 0))
|
|
767
|
+
return null;
|
|
768
|
+
const limits = exports.COMPUTER_BROWSER_VIEWPORT_LIMITS;
|
|
769
|
+
const bound = (value, low, high) => Math.max(low, Math.min(high, Math.round(value)));
|
|
770
|
+
let width = bound(rawWidth, limits.minWidth, limits.maxWidth);
|
|
771
|
+
let height = bound(rawHeight, limits.minHeight, limits.maxHeight);
|
|
772
|
+
if (width / height > limits.maxAspect) {
|
|
773
|
+
// Too wide: narrow it first; a height already at its floor cannot grow the other way.
|
|
774
|
+
width = Math.max(limits.minWidth, Math.floor(height * limits.maxAspect));
|
|
775
|
+
if (width / height > limits.maxAspect) {
|
|
776
|
+
height = Math.min(limits.maxHeight, Math.ceil(width / limits.maxAspect));
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
else if (width / height < limits.minAspect) {
|
|
780
|
+
// Too tall: shorten it first, then widen if the width is at its floor.
|
|
781
|
+
height = Math.max(limits.minHeight, Math.floor(width / limits.minAspect));
|
|
782
|
+
if (width / height < limits.minAspect) {
|
|
783
|
+
width = Math.min(limits.maxWidth, Math.ceil(height * limits.minAspect));
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return { width, height };
|
|
787
|
+
}
|
|
638
788
|
/**
|
|
639
789
|
* The client OS a browser `key` input comes from. A person's shortcuts are
|
|
640
790
|
* mapped onto the Linux page's by the daemon: on `mac`, Command is Control,
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Dedicated Runtime busy-report wire contract (power-control task K2,
|
|
3
|
+
* `dedicated-runtime-power-and-demand-wake-2026-10-07.md` §7.3 / §13.5).
|
|
4
|
+
*
|
|
5
|
+
* Declared ONCE, here. The daemon is published and cannot import the API, so
|
|
6
|
+
* the capability name, the payload shape and its bounds live in this package,
|
|
7
|
+
* which every end can import (`@skrr-ai/auth-core/dedicated-runtime-busy-wire`).
|
|
8
|
+
* `dedicatedRuntimeBusyWire.test.ts` fails on a second spelling of the
|
|
9
|
+
* capability anywhere else in the repo.
|
|
10
|
+
*
|
|
11
|
+
* WHAT THE REPORT SAYS
|
|
12
|
+
* ---------------------------------------------------------------------------
|
|
13
|
+
* "Does anything run in the tenant workload slice?" — read by the guest daemon
|
|
14
|
+
* from cgroup v2 `skrr-workload.slice`, recursively (the slice root is empty by
|
|
15
|
+
* contract; processes live in leaves), with the root-owned sshd listener left
|
|
16
|
+
* out. It is a LOCAL read summarised into counts; no per-process list ever
|
|
17
|
+
* crosses the wire.
|
|
18
|
+
*
|
|
19
|
+
* FAIL CLOSED. `busy` is `true | false | 'unknown'`. Any failure to read — a
|
|
20
|
+
* missing slice, an unreadable file, a tree too large to walk, a quiesce in
|
|
21
|
+
* progress, an sshd that is not where the image promises — is `'unknown'`, and
|
|
22
|
+
* a reader MUST treat `'unknown'` as busy. `false` is only ever the daemon
|
|
23
|
+
* having positively read an empty slice.
|
|
24
|
+
*
|
|
25
|
+
* THE POLICY KNOB (OPEN PRODUCT QUESTION — not decided here)
|
|
26
|
+
* ---------------------------------------------------------------------------
|
|
27
|
+
* An idle tmux server or a shell prompt keeps a leaf populated forever. The
|
|
28
|
+
* owner decision is that tmux/SSH shells ARE protected, but whether an IDLE
|
|
29
|
+
* shell should pin the machine is undecided. So the report carries both
|
|
30
|
+
* readings and the server chooses:
|
|
31
|
+
*
|
|
32
|
+
* - `busy` the STRICT reading (`policy: 'strict'`): every
|
|
33
|
+
* process in the slice counts. This is the
|
|
34
|
+
* default and the only one a server should act
|
|
35
|
+
* on until the product question is answered.
|
|
36
|
+
* - `busyIgnoringIdleShells` the same read with the `idleShell` bucket
|
|
37
|
+
* removed. Classification is by process name
|
|
38
|
+
* (a shell or tmux with nothing else running),
|
|
39
|
+
* a HEURISTIC: it cannot see a shell loop, so
|
|
40
|
+
* it must never be the default.
|
|
41
|
+
*
|
|
42
|
+
* The `breakdown` says which bucket made it busy, for the "why" text.
|
|
43
|
+
*/
|
|
44
|
+
export declare const DEDICATED_RUNTIME_BUSY_REPORT_CAPABILITY = "dedicated_runtime_busy_report_v1";
|
|
45
|
+
/** The heartbeat key the report rides under. Sent only by a daemon that announced the capability. */
|
|
46
|
+
export declare const DEDICATED_RUNTIME_BUSY_HEARTBEAT_KEY = "dedicatedRuntimeBusy";
|
|
47
|
+
export declare const DEDICATED_RUNTIME_BUSY_REPORT_VERSION = 1;
|
|
48
|
+
/**
|
|
49
|
+
* `strict`: every process in the slice (less the root sshd listener) counts.
|
|
50
|
+
* The only value v1 sends; the field exists so a later relaxation is a new
|
|
51
|
+
* value rather than a silent change of meaning.
|
|
52
|
+
*/
|
|
53
|
+
export declare const DEDICATED_RUNTIME_BUSY_POLICIES: readonly ["strict"];
|
|
54
|
+
export type DedicatedRuntimeBusyPolicy = (typeof DEDICATED_RUNTIME_BUSY_POLICIES)[number];
|
|
55
|
+
/**
|
|
56
|
+
* Why the daemon could not give a definite answer, or `ok`. Anything but `ok`
|
|
57
|
+
* pairs with `busy: 'unknown'`.
|
|
58
|
+
*/
|
|
59
|
+
export declare const DEDICATED_RUNTIME_BUSY_SLICE_HEALTH: readonly ["ok", "not_a_guest", "slice_missing", "slice_unreadable", "ssh_not_in_slice", "tree_too_large", "quiesced", "read_error"];
|
|
60
|
+
export type DedicatedRuntimeBusySliceHealth = (typeof DEDICATED_RUNTIME_BUSY_SLICE_HEALTH)[number];
|
|
61
|
+
export declare const DEDICATED_RUNTIME_BUSY_LIMITS: {
|
|
62
|
+
/** Service leaf names carried for the "busy because of service X" text. */
|
|
63
|
+
readonly maxServiceNames: 8;
|
|
64
|
+
readonly maxServiceNameLength: 48;
|
|
65
|
+
/** Cgroup leaves the daemon will visit; more is `tree_too_large` -> unknown. */
|
|
66
|
+
readonly maxLeaves: 64;
|
|
67
|
+
readonly maxDepth: 4;
|
|
68
|
+
/** Processes the daemon classifies per read; the rest count as workload. */
|
|
69
|
+
readonly maxClassifiedPids: 256;
|
|
70
|
+
/** Hard ceiling on the serialized report. */
|
|
71
|
+
readonly maxSerializedBytes: 1024;
|
|
72
|
+
};
|
|
73
|
+
export interface DedicatedRuntimeBusyBreakdown {
|
|
74
|
+
/** Processes in non-service, non-ssh leaves (the `default` leaf, the slice root) that are not idle-shell class. */
|
|
75
|
+
workload: number;
|
|
76
|
+
/** Processes in `skrr-svc-*.scope` leaves: a declared service running, always-on by design. */
|
|
77
|
+
service: number;
|
|
78
|
+
/** SSH connection plumbing in `ssh.service` that is not the root listener (non-root sshd, the session helper) and other non-shell processes there. */
|
|
79
|
+
ssh: number;
|
|
80
|
+
/** Shell or tmux processes in `default` / `ssh.service` (heuristic by name; see header). */
|
|
81
|
+
idleShell: number;
|
|
82
|
+
/** Root-owned sshd processes left out of every count above. */
|
|
83
|
+
excludedSshd: number;
|
|
84
|
+
/** True when more processes existed than were classified; the rest are in `workload`. */
|
|
85
|
+
truncated: boolean;
|
|
86
|
+
/** Up to `maxServiceNames` service leaf names that have processes. */
|
|
87
|
+
services: string[];
|
|
88
|
+
}
|
|
89
|
+
export interface DedicatedRuntimeBusyReport {
|
|
90
|
+
version: typeof DEDICATED_RUNTIME_BUSY_REPORT_VERSION;
|
|
91
|
+
policy: DedicatedRuntimeBusyPolicy;
|
|
92
|
+
/** Strict reading. `'unknown'` MUST be treated as busy. */
|
|
93
|
+
busy: boolean | 'unknown';
|
|
94
|
+
/** Same read with the `idleShell` bucket removed; a heuristic, not the default. */
|
|
95
|
+
busyIgnoringIdleShells: boolean | 'unknown';
|
|
96
|
+
breakdown: DedicatedRuntimeBusyBreakdown;
|
|
97
|
+
/** ISO time the daemon read the slice. */
|
|
98
|
+
readAt: string;
|
|
99
|
+
sliceHealth: DedicatedRuntimeBusySliceHealth;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The reader's view of a daemon's heartbeat section. Anything malformed, from
|
|
103
|
+
* a daemon that did not announce the capability, or oversized is `null`, and
|
|
104
|
+
* the caller must then treat the machine as busy. Never trusts a field it did
|
|
105
|
+
* not validate; a value is clamped, not coerced to "idle".
|
|
106
|
+
*/
|
|
107
|
+
export declare function parseDedicatedRuntimeBusyReport(raw: unknown): DedicatedRuntimeBusyReport | null;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The Dedicated Runtime busy-report wire contract (power-control task K2,
|
|
4
|
+
* `dedicated-runtime-power-and-demand-wake-2026-10-07.md` §7.3 / §13.5).
|
|
5
|
+
*
|
|
6
|
+
* Declared ONCE, here. The daemon is published and cannot import the API, so
|
|
7
|
+
* the capability name, the payload shape and its bounds live in this package,
|
|
8
|
+
* which every end can import (`@skrr-ai/auth-core/dedicated-runtime-busy-wire`).
|
|
9
|
+
* `dedicatedRuntimeBusyWire.test.ts` fails on a second spelling of the
|
|
10
|
+
* capability anywhere else in the repo.
|
|
11
|
+
*
|
|
12
|
+
* WHAT THE REPORT SAYS
|
|
13
|
+
* ---------------------------------------------------------------------------
|
|
14
|
+
* "Does anything run in the tenant workload slice?" — read by the guest daemon
|
|
15
|
+
* from cgroup v2 `skrr-workload.slice`, recursively (the slice root is empty by
|
|
16
|
+
* contract; processes live in leaves), with the root-owned sshd listener left
|
|
17
|
+
* out. It is a LOCAL read summarised into counts; no per-process list ever
|
|
18
|
+
* crosses the wire.
|
|
19
|
+
*
|
|
20
|
+
* FAIL CLOSED. `busy` is `true | false | 'unknown'`. Any failure to read — a
|
|
21
|
+
* missing slice, an unreadable file, a tree too large to walk, a quiesce in
|
|
22
|
+
* progress, an sshd that is not where the image promises — is `'unknown'`, and
|
|
23
|
+
* a reader MUST treat `'unknown'` as busy. `false` is only ever the daemon
|
|
24
|
+
* having positively read an empty slice.
|
|
25
|
+
*
|
|
26
|
+
* THE POLICY KNOB (OPEN PRODUCT QUESTION — not decided here)
|
|
27
|
+
* ---------------------------------------------------------------------------
|
|
28
|
+
* An idle tmux server or a shell prompt keeps a leaf populated forever. The
|
|
29
|
+
* owner decision is that tmux/SSH shells ARE protected, but whether an IDLE
|
|
30
|
+
* shell should pin the machine is undecided. So the report carries both
|
|
31
|
+
* readings and the server chooses:
|
|
32
|
+
*
|
|
33
|
+
* - `busy` the STRICT reading (`policy: 'strict'`): every
|
|
34
|
+
* process in the slice counts. This is the
|
|
35
|
+
* default and the only one a server should act
|
|
36
|
+
* on until the product question is answered.
|
|
37
|
+
* - `busyIgnoringIdleShells` the same read with the `idleShell` bucket
|
|
38
|
+
* removed. Classification is by process name
|
|
39
|
+
* (a shell or tmux with nothing else running),
|
|
40
|
+
* a HEURISTIC: it cannot see a shell loop, so
|
|
41
|
+
* it must never be the default.
|
|
42
|
+
*
|
|
43
|
+
* The `breakdown` says which bucket made it busy, for the "why" text.
|
|
44
|
+
*/
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.DEDICATED_RUNTIME_BUSY_LIMITS = exports.DEDICATED_RUNTIME_BUSY_SLICE_HEALTH = exports.DEDICATED_RUNTIME_BUSY_POLICIES = exports.DEDICATED_RUNTIME_BUSY_REPORT_VERSION = exports.DEDICATED_RUNTIME_BUSY_HEARTBEAT_KEY = exports.DEDICATED_RUNTIME_BUSY_REPORT_CAPABILITY = void 0;
|
|
47
|
+
exports.parseDedicatedRuntimeBusyReport = parseDedicatedRuntimeBusyReport;
|
|
48
|
+
exports.DEDICATED_RUNTIME_BUSY_REPORT_CAPABILITY = 'dedicated_runtime_busy_report_v1';
|
|
49
|
+
/** The heartbeat key the report rides under. Sent only by a daemon that announced the capability. */
|
|
50
|
+
exports.DEDICATED_RUNTIME_BUSY_HEARTBEAT_KEY = 'dedicatedRuntimeBusy';
|
|
51
|
+
exports.DEDICATED_RUNTIME_BUSY_REPORT_VERSION = 1;
|
|
52
|
+
/**
|
|
53
|
+
* `strict`: every process in the slice (less the root sshd listener) counts.
|
|
54
|
+
* The only value v1 sends; the field exists so a later relaxation is a new
|
|
55
|
+
* value rather than a silent change of meaning.
|
|
56
|
+
*/
|
|
57
|
+
exports.DEDICATED_RUNTIME_BUSY_POLICIES = ['strict'];
|
|
58
|
+
/**
|
|
59
|
+
* Why the daemon could not give a definite answer, or `ok`. Anything but `ok`
|
|
60
|
+
* pairs with `busy: 'unknown'`.
|
|
61
|
+
*/
|
|
62
|
+
exports.DEDICATED_RUNTIME_BUSY_SLICE_HEALTH = [
|
|
63
|
+
'ok',
|
|
64
|
+
'not_a_guest',
|
|
65
|
+
'slice_missing',
|
|
66
|
+
'slice_unreadable',
|
|
67
|
+
'ssh_not_in_slice',
|
|
68
|
+
'tree_too_large',
|
|
69
|
+
'quiesced',
|
|
70
|
+
'read_error',
|
|
71
|
+
];
|
|
72
|
+
exports.DEDICATED_RUNTIME_BUSY_LIMITS = {
|
|
73
|
+
/** Service leaf names carried for the "busy because of service X" text. */
|
|
74
|
+
maxServiceNames: 8,
|
|
75
|
+
maxServiceNameLength: 48,
|
|
76
|
+
/** Cgroup leaves the daemon will visit; more is `tree_too_large` -> unknown. */
|
|
77
|
+
maxLeaves: 64,
|
|
78
|
+
maxDepth: 4,
|
|
79
|
+
/** Processes the daemon classifies per read; the rest count as workload. */
|
|
80
|
+
maxClassifiedPids: 256,
|
|
81
|
+
/** Hard ceiling on the serialized report. */
|
|
82
|
+
maxSerializedBytes: 1024,
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The reader's view of a daemon's heartbeat section. Anything malformed, from
|
|
86
|
+
* a daemon that did not announce the capability, or oversized is `null`, and
|
|
87
|
+
* the caller must then treat the machine as busy. Never trusts a field it did
|
|
88
|
+
* not validate; a value is clamped, not coerced to "idle".
|
|
89
|
+
*/
|
|
90
|
+
function parseDedicatedRuntimeBusyReport(raw) {
|
|
91
|
+
if (!raw || typeof raw !== 'object')
|
|
92
|
+
return null;
|
|
93
|
+
const r = raw;
|
|
94
|
+
if (r.version !== exports.DEDICATED_RUNTIME_BUSY_REPORT_VERSION)
|
|
95
|
+
return null;
|
|
96
|
+
if (!exports.DEDICATED_RUNTIME_BUSY_POLICIES.includes(r.policy))
|
|
97
|
+
return null;
|
|
98
|
+
const tri = (v) => v === true || v === false || v === 'unknown' ? v : undefined;
|
|
99
|
+
const busy = tri(r.busy);
|
|
100
|
+
const ignoring = tri(r.busyIgnoringIdleShells);
|
|
101
|
+
if (busy === undefined || ignoring === undefined)
|
|
102
|
+
return null;
|
|
103
|
+
if (!exports.DEDICATED_RUNTIME_BUSY_SLICE_HEALTH.includes(r.sliceHealth)) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const readAtMs = typeof r.readAt === 'string' ? Date.parse(r.readAt) : NaN;
|
|
107
|
+
if (!Number.isFinite(readAtMs))
|
|
108
|
+
return null;
|
|
109
|
+
const b = r.breakdown;
|
|
110
|
+
if (!b || typeof b !== 'object')
|
|
111
|
+
return null;
|
|
112
|
+
const count = (v) => typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? v : null;
|
|
113
|
+
const workload = count(b.workload);
|
|
114
|
+
const service = count(b.service);
|
|
115
|
+
const ssh = count(b.ssh);
|
|
116
|
+
const idleShell = count(b.idleShell);
|
|
117
|
+
const excludedSshd = count(b.excludedSshd);
|
|
118
|
+
if (workload === null ||
|
|
119
|
+
service === null ||
|
|
120
|
+
ssh === null ||
|
|
121
|
+
idleShell === null ||
|
|
122
|
+
excludedSshd === null ||
|
|
123
|
+
typeof b.truncated !== 'boolean' ||
|
|
124
|
+
!Array.isArray(b.services)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const services = b.services
|
|
128
|
+
.filter((s) => typeof s === 'string')
|
|
129
|
+
.slice(0, exports.DEDICATED_RUNTIME_BUSY_LIMITS.maxServiceNames)
|
|
130
|
+
.map((s) => s.slice(0, exports.DEDICATED_RUNTIME_BUSY_LIMITS.maxServiceNameLength));
|
|
131
|
+
const report = {
|
|
132
|
+
version: exports.DEDICATED_RUNTIME_BUSY_REPORT_VERSION,
|
|
133
|
+
policy: r.policy,
|
|
134
|
+
busy,
|
|
135
|
+
busyIgnoringIdleShells: ignoring,
|
|
136
|
+
breakdown: {
|
|
137
|
+
workload,
|
|
138
|
+
service,
|
|
139
|
+
ssh,
|
|
140
|
+
idleShell,
|
|
141
|
+
excludedSshd,
|
|
142
|
+
truncated: b.truncated,
|
|
143
|
+
services,
|
|
144
|
+
},
|
|
145
|
+
readAt: new Date(readAtMs).toISOString(),
|
|
146
|
+
sliceHealth: r.sliceHealth,
|
|
147
|
+
};
|
|
148
|
+
if (JSON.stringify(report).length > exports.DEDICATED_RUNTIME_BUSY_LIMITS.maxSerializedBytes)
|
|
149
|
+
return null;
|
|
150
|
+
return report;
|
|
151
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Dedicated Runtime wake-progress wire contract (power-control task W5,
|
|
3
|
+
* `dedicated-runtime-power-and-demand-wake-2026-10-07.md` §5.3, §7.2, §9).
|
|
4
|
+
*
|
|
5
|
+
* Declared ONCE, here, for the same reason `computerWire.ts` is: the browser,
|
|
6
|
+
* the React Native app and the CLI import it, and none of them may spell the
|
|
7
|
+
* event, the capability or a code a second time. `dedicatedRuntimeWakeWire.test.ts`
|
|
8
|
+
* fails on a second spelling in the API.
|
|
9
|
+
*
|
|
10
|
+
* WHAT IT IS
|
|
11
|
+
* ---------------------------------------------------------------------------
|
|
12
|
+
* A person opens a terminal, an SSH channel, a service call or the Computer on a
|
|
13
|
+
* STOPPED Dedicated Runtime. That is wake progress, not an error: the relay asks
|
|
14
|
+
* `requestWake` (source `person`) to start the machine, then tells THAT request,
|
|
15
|
+
* in stages, how far the start has got, until the machine is assignable and the
|
|
16
|
+
* original request is served, or a bound runs out and it says why and what to do.
|
|
17
|
+
*
|
|
18
|
+
* THE CLIENT ANNOUNCES IT
|
|
19
|
+
* ---------------------------------------------------------------------------
|
|
20
|
+
* A client that has not announced `dedicated_wake_progress_v1` in the open
|
|
21
|
+
* request's `capabilities` array is NEVER sent `dedicated:wake:progress` and is
|
|
22
|
+
* never made to wait: it gets an immediate typed refusal instead. (A client
|
|
23
|
+
* socket has no registration step to announce on, so the announcement rides each
|
|
24
|
+
* request — stateless, nothing held in the relay.)
|
|
25
|
+
*
|
|
26
|
+
* THE VOCABULARY
|
|
27
|
+
* ---------------------------------------------------------------------------
|
|
28
|
+
* `phase` uses the cold-start measurement's phase names
|
|
29
|
+
* (`scripts/dedicated-runtime/measure-cold-start.js` `COLD_START_PHASES`), so
|
|
30
|
+
* what the person sees and what F4 measures are the same words. A spec holds the
|
|
31
|
+
* two lists equal.
|
|
32
|
+
*
|
|
33
|
+
* NOT A SPINNER WITHOUT A BOUND
|
|
34
|
+
* ---------------------------------------------------------------------------
|
|
35
|
+
* `boundMs` is carried on every event so a surface can show elapsed-of-bound.
|
|
36
|
+
* The bound sits ABOVE a slow-but-working start (design §9): running out says
|
|
37
|
+
* "this is taking longer than expected" and the machine is left starting; it is
|
|
38
|
+
* never an accusation that the machine is dead.
|
|
39
|
+
*/
|
|
40
|
+
/** API -> client, on the same socket as the request it belongs to. */
|
|
41
|
+
export declare const DEDICATED_WAKE_EVENTS: {
|
|
42
|
+
readonly progress: "dedicated:wake:progress";
|
|
43
|
+
};
|
|
44
|
+
/** Announced in the open request's `capabilities` array. */
|
|
45
|
+
export declare const DEDICATED_WAKE_CAPABILITIES: {
|
|
46
|
+
readonly progress: "dedicated_wake_progress_v1";
|
|
47
|
+
};
|
|
48
|
+
export type DedicatedWakeCapability = (typeof DEDICATED_WAKE_CAPABILITIES)[keyof typeof DEDICATED_WAKE_CAPABILITIES];
|
|
49
|
+
/** Same names, same order as `WAKE_PHASES` in api/server/services/DedicatedRuntime/wakePhases.js (pinned by a test). */
|
|
50
|
+
export declare const DEDICATED_WAKE_PHASES: readonly ["start_requested", "provider_start_accepted", "instance_running", "daemon_connected", "first_heartbeat", "assignable"];
|
|
51
|
+
export type DedicatedWakePhase = (typeof DEDICATED_WAKE_PHASES)[number];
|
|
52
|
+
/**
|
|
53
|
+
* - `waking` a start is in flight; `phase` says how far.
|
|
54
|
+
* - `ready` assignable; the original request is about to be served.
|
|
55
|
+
* - `deferred` the machine is stopping; nothing was started. Retry after `retryAfterSeconds`.
|
|
56
|
+
* - `refused` the start was refused, with `code`, `reason`, `detail`, `fix`.
|
|
57
|
+
* - `timed_out` the bound ran out while it was still starting. Not a failure of the machine.
|
|
58
|
+
*/
|
|
59
|
+
export declare const DEDICATED_WAKE_STATES: readonly ["waking", "ready", "deferred", "refused", "timed_out"];
|
|
60
|
+
export type DedicatedWakeState = (typeof DEDICATED_WAKE_STATES)[number];
|
|
61
|
+
/** The surfaces a wake can be asked from. */
|
|
62
|
+
export declare const DEDICATED_WAKE_SURFACES: readonly ["terminal", "ssh", "services", "templates", "computer", "http"];
|
|
63
|
+
export type DedicatedWakeSurface = (typeof DEDICATED_WAKE_SURFACES)[number];
|
|
64
|
+
/**
|
|
65
|
+
* Typed refusals. Each is a different fact with a different next step; none of
|
|
66
|
+
* them is the generic "Dedicated Runtime dispatch was refused".
|
|
67
|
+
*/
|
|
68
|
+
export declare const DEDICATED_WAKE_CODES: {
|
|
69
|
+
/** Stopped, and this request did not (or could not) wake it. */
|
|
70
|
+
readonly stopped: "DEDICATED_RUNTIME_STOPPED";
|
|
71
|
+
/** A stop is finishing; retry when it has. */
|
|
72
|
+
readonly stopping: "DEDICATED_RUNTIME_STOPPING";
|
|
73
|
+
/** A start is in flight (ours or someone's). */
|
|
74
|
+
readonly starting: "DEDICATED_RUNTIME_STARTING";
|
|
75
|
+
/** The bound ran out while it was still starting. */
|
|
76
|
+
readonly timeout: "DEDICATED_RUNTIME_WAKE_TIMEOUT";
|
|
77
|
+
/** The start was refused: the plan no longer includes the machine. */
|
|
78
|
+
readonly entitlement: "DEDICATED_RUNTIME_WAKE_REFUSED_ENTITLEMENT";
|
|
79
|
+
/** The start was refused: the spend cap was reached. */
|
|
80
|
+
readonly spendCap: "DEDICATED_RUNTIME_WAKE_REFUSED_SPEND_CAP";
|
|
81
|
+
/** Any other refusal; `reason` names it. */
|
|
82
|
+
readonly refused: "DEDICATED_RUNTIME_WAKE_REFUSED";
|
|
83
|
+
/** The start was requested and the machine fell back to stopped or failed. */
|
|
84
|
+
readonly failed: "DEDICATED_RUNTIME_WAKE_FAILED";
|
|
85
|
+
};
|
|
86
|
+
export type DedicatedWakeCode = (typeof DEDICATED_WAKE_CODES)[keyof typeof DEDICATED_WAKE_CODES];
|
|
87
|
+
/**
|
|
88
|
+
* How long a surface waits for a start before saying it is taking longer than
|
|
89
|
+
* expected. Above the slow-but-working case: a cold start on a fresh guest
|
|
90
|
+
* takes 25-30 s for the browser alone, and the AMI boot is longer. It is a
|
|
91
|
+
* bound on what we show, never a verdict on the machine.
|
|
92
|
+
*/
|
|
93
|
+
export declare const DEDICATED_WAKE_BOUND_MS = 180000;
|
|
94
|
+
/** How often the relay re-reads the lease while waiting. */
|
|
95
|
+
export declare const DEDICATED_WAKE_POLL_MS = 2000;
|
|
96
|
+
export interface DedicatedWakeProgress {
|
|
97
|
+
leaseId: string;
|
|
98
|
+
surface: DedicatedWakeSurface;
|
|
99
|
+
/** The id of the request this belongs to (`requestId`, `channelId`, ...). */
|
|
100
|
+
ref?: string;
|
|
101
|
+
state: DedicatedWakeState;
|
|
102
|
+
/** Present while `waking`, and on `timed_out` (where the machine had got to). */
|
|
103
|
+
phase?: DedicatedWakePhase;
|
|
104
|
+
elapsedMs: number;
|
|
105
|
+
boundMs: number;
|
|
106
|
+
/** Power reason (e.g. `wake_refused_spend_cap`) or a lifecycle reason. */
|
|
107
|
+
reason?: string;
|
|
108
|
+
/** One of `DEDICATED_WAKE_CODES` on `refused`, `deferred` and `timed_out`. */
|
|
109
|
+
code?: DedicatedWakeCode;
|
|
110
|
+
detail?: string;
|
|
111
|
+
/** What the person can do next. */
|
|
112
|
+
fix?: string | null;
|
|
113
|
+
retryAfterSeconds?: number;
|
|
114
|
+
}
|
|
115
|
+
export declare function clientAnnouncesWakeProgress(capabilities: unknown): boolean;
|