@halonicjs/testing 0.1.0 → 0.1.2
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/NOTICE +4 -0
- package/README.md +1 -1
- package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
- package/dist/adapters/http-kit/src/address-checking.js +1 -0
- package/dist/adapters/http-kit/src/connector-host-class.d.ts +14 -0
- package/dist/adapters/http-kit/src/connector-host-class.js +34 -0
- package/dist/adapters/http-kit/src/index.d.ts +3 -0
- package/dist/adapters/http-kit/src/index.js +2 -0
- package/dist/adapters/http-kit/src/ollama-tags.d.ts +20 -0
- package/dist/adapters/http-kit/src/ollama-tags.js +38 -0
- package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
- package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +2 -1
- package/dist/adapters/integration-kit/src/declaration.js +4 -3
- package/dist/adapters/integration-kit/src/host.d.ts +7 -1
- package/dist/adapters/integration-kit/src/host.js +1 -0
- package/dist/adapters/integration-kit/src/index.d.ts +5 -2
- package/dist/adapters/integration-kit/src/index.js +2 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +4 -2
- package/dist/adapters/integration-kit/src/leak-attempt.js +5 -2
- package/dist/adapters/integration-kit/src/limited-http.d.ts +7 -1
- package/dist/adapters/integration-kit/src/limited-http.js +53 -10
- package/dist/adapters/integration-kit/src/loader.d.ts +28 -11
- package/dist/adapters/integration-kit/src/loader.js +36 -21
- package/dist/adapters/integration-kit/src/own-request.d.ts +2 -2
- package/dist/adapters/integration-kit/src/own-request.js +1 -1
- package/dist/adapters/integration-kit/src/plugin-load.d.ts +3 -3
- package/dist/adapters/integration-kit/src/plugin-load.js +5 -5
- package/dist/adapters/integration-kit/src/policy.d.ts +28 -0
- package/dist/adapters/integration-kit/src/response-body.d.ts +6 -2
- package/dist/adapters/integration-kit/src/secret-filter.d.ts +3 -3
- package/dist/adapters/integration-kit/src/secret-filter.js +19 -4
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +3 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +8 -2
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +35 -25
- package/dist/adapters/integration-kit/src/secret-placement.js +65 -95
- package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
- package/dist/adapters/integration-kit/src/workspace-choices.d.ts +37 -0
- package/dist/adapters/integration-kit/src/workspace-choices.js +37 -0
- package/dist/core/events/src/blocked-sites.d.ts +57 -0
- package/dist/core/events/src/blocked-sites.js +89 -0
- package/dist/core/events/src/connector-listing-failed.d.ts +18 -0
- package/dist/core/events/src/connector-listing-failed.js +1 -0
- package/dist/core/events/src/home-path.d.ts +4 -1
- package/dist/core/events/src/home-path.js +14 -3
- package/dist/core/events/src/index.d.ts +8 -2
- package/dist/core/events/src/index.js +5 -0
- package/dist/core/events/src/provider-notes.d.ts +16 -0
- package/dist/core/events/src/provider-notes.js +24 -0
- package/dist/core/events/src/run-basics.d.ts +131 -10
- package/dist/core/events/src/run-event.d.ts +120 -11
- package/dist/core/events/src/run-reads.d.ts +25 -0
- package/dist/core/events/src/run-reads.js +44 -0
- package/dist/core/events/src/run-sends.d.ts +47 -0
- package/dist/core/events/src/run-sends.js +68 -0
- package/dist/core/events/src/run-summary.d.ts +11 -1
- package/dist/core/events/src/sandbox-opened-read.d.ts +2 -1
- package/dist/core/events/src/sandbox-opened-read.js +27 -2
- package/dist/core/events/src/sandbox-opened.d.ts +37 -4
- package/dist/core/events/src/sandbox-opened.js +13 -3
- package/dist/core/events/src/summarize.js +8 -1
- package/dist/core/events/src/timeline-entry.js +1 -0
- package/dist/core/events/src/tool-failure-cause.d.ts +25 -0
- package/dist/core/events/src/tool-failure-cause.js +66 -0
- package/dist/core/format/src/index.d.ts +9 -6
- package/dist/core/format/src/index.js +7 -3
- package/dist/core/format/src/integration/index.d.ts +3 -2
- package/dist/core/format/src/integration/index.js +2 -1
- package/dist/core/format/src/kinds/agent/harness-limits.d.ts +14 -0
- package/dist/core/format/src/kinds/agent/harness-limits.js +27 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +15 -5
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +29 -10
- package/dist/core/format/src/kinds/agent/schema.d.ts +5 -0
- package/dist/core/format/src/kinds/agent/schema.js +5 -2
- package/dist/core/format/src/kinds/connector/is-local.js +1 -1
- package/dist/core/format/src/kinds/connector/kind.js +122 -2
- package/dist/core/format/src/kinds/connector/schema.d.ts +38 -0
- package/dist/core/format/src/kinds/connector/schema.js +71 -2
- package/dist/core/format/src/kinds/deployments/kind.js +25 -1
- package/dist/core/format/src/kinds/deployments/schema.d.ts +40 -0
- package/dist/core/format/src/kinds/deployments/schema.js +52 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
- package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
- package/dist/core/format/src/kinds/integration/host-key.js +8 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +4 -2
- package/dist/core/format/src/kinds/integration/kind.js +49 -12
- package/dist/core/format/src/kinds/integration/policy.d.ts +47 -2
- package/dist/core/format/src/kinds/integration/policy.js +61 -2
- package/dist/core/format/src/kinds/integration/schema.d.ts +180 -3
- package/dist/core/format/src/kinds/integration/schema.js +133 -7
- package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +14 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.js +150 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
- package/dist/core/format/src/kinds/plugin/checks.d.ts +3 -2
- package/dist/core/format/src/kinds/plugin/checks.js +24 -6
- package/dist/core/format/src/kinds/plugin/schema.d.ts +130 -0
- package/dist/core/format/src/kinds/plugin/schema.js +26 -6
- package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +1 -1
- package/dist/core/format/src/kinds/plugin/ui-checks.js +1 -10
- package/dist/core/format/src/kinds/provider/kind.js +40 -1
- package/dist/core/format/src/kinds/provider/types.d.ts +19 -0
- package/dist/core/format/src/kinds/provider/types.js +22 -0
- package/dist/core/format/src/kinds/routine/kind.js +38 -1
- package/dist/core/format/src/kinds/routine/schema.d.ts +20 -5
- package/dist/core/format/src/kinds/routine/schema.js +42 -14
- package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
- package/dist/core/format/src/kinds/workflow/schema.js +1 -1
- package/dist/core/format/src/kinds/workspace/kind.js +1 -1
- package/dist/core/format/src/kinds/workspace/schema.d.ts +2 -2
- package/dist/core/format/src/kinds/workspace/schema.js +6 -5
- package/dist/core/format/src/parse-file.js +3 -1
- package/dist/core/format/src/shared/fields.d.ts +12 -8
- package/dist/core/format/src/shared/fields.js +48 -19
- package/dist/core/format/src/shared/guard.d.ts +8 -0
- package/dist/core/format/src/shared/guard.js +50 -1
- package/dist/core/format/src/shared/missing-keys.d.ts +17 -0
- package/dist/core/format/src/shared/missing-keys.js +110 -0
- package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
- package/dist/core/ports/src/agent-runs-not-available.js +25 -0
- package/dist/core/ports/src/blob-store.d.ts +12 -0
- package/dist/core/ports/src/blob-store.js +22 -0
- package/dist/core/ports/src/chat.d.ts +8 -0
- package/dist/core/ports/src/connector-client.d.ts +48 -4
- package/dist/core/ports/src/connector-client.js +17 -0
- package/dist/core/ports/src/connector-start-failure.d.ts +31 -0
- package/dist/core/ports/src/connector-start-failure.js +32 -0
- package/dist/core/ports/src/connector-tool-error.d.ts +33 -0
- package/dist/core/ports/src/connector-tool-error.js +40 -0
- package/dist/core/ports/src/definition-store-left-out.d.ts +46 -0
- package/dist/core/ports/src/definition-store-left-out.js +47 -0
- package/dist/core/ports/src/definition-store.d.ts +36 -5
- package/dist/core/ports/src/definition-store.js +1 -1
- package/dist/core/ports/src/deploy-target.d.ts +358 -0
- package/dist/core/ports/src/deploy-target.js +2 -0
- package/dist/core/ports/src/harness-bridge-server.d.ts +67 -7
- package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
- package/dist/core/ports/src/harness-sign-in-command.js +31 -0
- package/dist/core/ports/src/harness.d.ts +79 -15
- package/dist/core/ports/src/harness.js +1 -1
- package/dist/core/ports/src/host-settings-store.d.ts +116 -0
- package/dist/core/ports/src/host-settings-store.js +106 -0
- package/dist/core/ports/src/host-too-old.d.ts +23 -0
- package/dist/core/ports/src/host-too-old.js +27 -0
- package/dist/core/ports/src/index.d.ts +32 -13
- package/dist/core/ports/src/index.js +28 -8
- package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
- package/dist/core/ports/src/instruction-trust-store.js +43 -0
- package/dist/core/ports/src/integration.d.ts +71 -7
- package/dist/core/ports/src/integration.js +22 -4
- package/dist/core/ports/src/llm-provider.d.ts +39 -6
- package/dist/core/ports/src/llm-provider.js +46 -3
- package/dist/core/ports/src/pairing-codes.d.ts +111 -0
- package/dist/core/ports/src/pairing-codes.js +336 -0
- package/dist/core/ports/src/pairing-qr-bytes.d.ts +32 -0
- package/dist/core/ports/src/pairing-qr-bytes.js +116 -0
- package/dist/core/ports/src/password-hasher.d.ts +36 -20
- package/dist/core/ports/src/port-versions.d.ts +13 -6
- package/dist/core/ports/src/port-versions.js +14 -0
- package/dist/core/ports/src/program-probe.d.ts +25 -2
- package/dist/core/ports/src/program-probe.js +1 -1
- package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
- package/dist/core/ports/src/provider-default-base-url.js +18 -0
- package/dist/core/ports/src/record-store.d.ts +17 -0
- package/dist/core/ports/src/record-store.js +70 -0
- package/dist/core/ports/src/remote-control.d.ts +159 -0
- package/dist/core/ports/src/remote-control.js +26 -0
- package/dist/core/ports/src/remote-gateway-protocol.d.ts +220 -0
- package/dist/core/ports/src/remote-gateway-protocol.js +62 -0
- package/dist/core/ports/src/remote-gateway-session.d.ts +194 -0
- package/dist/core/ports/src/remote-gateway-session.js +241 -0
- package/dist/core/ports/src/run-executor.d.ts +44 -7
- package/dist/core/ports/src/run-executor.js +1 -1
- package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
- package/dist/core/ports/src/run-target-not-found.js +41 -0
- package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
- package/dist/core/ports/src/sandbox-setting-store.js +33 -0
- package/dist/core/ports/src/sandbox.d.ts +149 -13
- package/dist/core/ports/src/sandbox.js +52 -2
- package/dist/core/ports/src/secrets.d.ts +105 -1
- package/dist/core/ports/src/secrets.js +75 -2
- package/dist/core/ports/src/tool-approval-store.d.ts +50 -8
- package/dist/core/ports/src/tool-approval-store.js +59 -0
- package/dist/core/ports/src/tunnel-provider.d.ts +117 -0
- package/dist/core/ports/src/tunnel-provider.js +65 -0
- package/dist/core/ports/src/tunnel-resolver.d.ts +83 -0
- package/dist/core/ports/src/tunnel-resolver.js +36 -0
- package/dist/core/ports/src/vcs-status.d.ts +8 -0
- package/dist/core/ports/src/vcs-status.js +90 -0
- package/dist/core/ports/src/vcs.d.ts +30 -0
- package/dist/core/schema-kit/src/builders.d.ts +5 -0
- package/dist/core/schema-kit/src/builders.js +5 -0
- package/dist/core/std/src/amount.d.ts +13 -0
- package/dist/core/std/src/amount.js +22 -0
- package/dist/core/std/src/hidden-characters.d.ts +28 -0
- package/dist/core/std/src/hidden-characters.js +72 -0
- package/dist/core/std/src/index.d.ts +7 -0
- package/dist/core/std/src/index.js +7 -0
- package/dist/core/std/src/path-overlap.d.ts +22 -0
- package/dist/core/std/src/path-overlap.js +57 -0
- package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
- package/dist/core/std/src/public-suffixes.generated.js +10428 -0
- package/dist/core/std/src/registrable-domain.d.ts +10 -0
- package/dist/core/std/src/registrable-domain.js +62 -0
- package/dist/core/std/src/secret-variable-name.d.ts +12 -0
- package/dist/core/std/src/secret-variable-name.js +34 -0
- package/dist/core/std/src/site-name.d.ts +35 -0
- package/dist/core/std/src/site-name.js +111 -0
- package/dist/core/std/src/url-host.d.ts +35 -0
- package/dist/core/std/src/url-host.js +170 -0
- package/dist/core/std/src/word-diff.d.ts +28 -0
- package/dist/core/std/src/word-diff.js +77 -0
- package/dist/core/yaml/src/edit-data.d.ts +7 -0
- package/dist/core/yaml/src/edit-data.js +62 -3
- package/dist/core/yaml/src/edit.d.ts +7 -0
- package/dist/core/yaml/src/edit.js +34 -3
- package/dist/core/yaml/src/splice-node.d.ts +6 -0
- package/dist/core/yaml/src/splice-node.js +10 -0
- package/dist/core/yaml/src/splice.js +20 -10
- package/dist/testing/integration/src/checks.d.ts +5 -3
- package/dist/testing/integration/src/checks.js +31 -3
- package/dist/testing/integration/src/load.js +3 -1
- package/package.json +9 -2
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The end-to-end session around the remote gateway protocol: the Noise
|
|
3
|
+
* handshakes, the binary frames they travel in, the two cleartext refusals,
|
|
4
|
+
* and the limits and times both sides keep (requirement
|
|
5
|
+
* `ports.remote-gateway-session`, ADR "Pairing and the end-to-end session").
|
|
6
|
+
* No crypto is done here: a Noise library does it behind an adapter.
|
|
7
|
+
*/
|
|
8
|
+
/** The Noise handshake that pairs a new phone, on the QR and the typed route alike. */
|
|
9
|
+
export declare const gatewayPairingPattern = "Noise_XXpsk3_25519_ChaChaPoly_SHA256";
|
|
10
|
+
/** The Noise handshake a paired phone reconnects with, to the host key it pinned. */
|
|
11
|
+
export declare const gatewayReconnectPattern = "Noise_IK_25519_ChaChaPoly_SHA256";
|
|
12
|
+
/**
|
|
13
|
+
* The Noise prologue of both handshakes. It names the protocol version, so a
|
|
14
|
+
* peer of another version fails the handshake instead of negotiating.
|
|
15
|
+
*/
|
|
16
|
+
export declare const gatewayNoisePrologue = "halonic-gateway/2";
|
|
17
|
+
/**
|
|
18
|
+
* The first byte of every binary WebSocket frame, which says what follows.
|
|
19
|
+
*
|
|
20
|
+
* - `pair1` to `pair3` carry the three messages of the pairing handshake,
|
|
21
|
+
* `resume1` and `resume2` the two of the reconnect handshake.
|
|
22
|
+
* - `message` carries one Noise transport message holding one gateway message.
|
|
23
|
+
* - `rekey` carries an empty transport message, the sender's last under its
|
|
24
|
+
* old key: it rekeys its sending direction after it, and the reader rekeys
|
|
25
|
+
* its receiving direction after reading it.
|
|
26
|
+
* - `handshake-failed` and `pair-refused` are the only cleartext frames. They
|
|
27
|
+
* are informative: anyone on the path could fake one, and neither may make
|
|
28
|
+
* the phone clear anything.
|
|
29
|
+
*
|
|
30
|
+
* Any other first byte, a frame of a kind the other side doesn't send, a
|
|
31
|
+
* handshake frame out of order or a text frame closes the connection.
|
|
32
|
+
*/
|
|
33
|
+
export declare const gatewayFrameKinds: {
|
|
34
|
+
readonly pair1: 1;
|
|
35
|
+
readonly pair2: 2;
|
|
36
|
+
readonly pair3: 3;
|
|
37
|
+
readonly resume1: 17;
|
|
38
|
+
readonly resume2: 18;
|
|
39
|
+
readonly message: 32;
|
|
40
|
+
readonly rekey: 33;
|
|
41
|
+
readonly "handshake-failed": 48;
|
|
42
|
+
readonly "pair-refused": 49;
|
|
43
|
+
};
|
|
44
|
+
/** One of the names in {@link gatewayFrameKinds}. */
|
|
45
|
+
export type GatewayFrameKind = keyof typeof gatewayFrameKinds;
|
|
46
|
+
/** The largest Noise message, handshake or transport, by the Noise spec. */
|
|
47
|
+
export declare const noiseMaxMessageBytes = 65535;
|
|
48
|
+
/** The largest binary frame: a kind byte and one Noise message. */
|
|
49
|
+
export declare const gatewayMaxFrameBytes: number;
|
|
50
|
+
/**
|
|
51
|
+
* The largest handshake message, without its kind byte. The longest, pairing
|
|
52
|
+
* message 3, is 32 + 16 bytes of key and tag and a payload with a name of at
|
|
53
|
+
* most {@link gatewayMaxNameBytes} and a nonce, so a larger one is an attack.
|
|
54
|
+
*/
|
|
55
|
+
export declare const gatewayMaxHandshakeBytes = 1024;
|
|
56
|
+
/** The longest name in a handshake payload, the host's or the phone's, in bytes of UTF-8. */
|
|
57
|
+
export declare const gatewayMaxNameBytes = 64;
|
|
58
|
+
/**
|
|
59
|
+
* The payload of pairing message 1, from the phone, in cleartext: its
|
|
60
|
+
* commitment to message 3, the SHA-256 of {@link pairCommitInput}, in base64url
|
|
61
|
+
* without padding (43 characters). JSON, UTF-8. The host recomputes it once
|
|
62
|
+
* message 3 decrypts, and a mismatch is a wrong try, so an attacker who knows
|
|
63
|
+
* the code can't search for a message 3 that makes the check codes match.
|
|
64
|
+
*/
|
|
65
|
+
export interface PairCommitPayload {
|
|
66
|
+
readonly commit: string;
|
|
67
|
+
}
|
|
68
|
+
/** What the phone's commitment starts with, in ASCII: it names the use and its version. */
|
|
69
|
+
export declare const pairCommitLabel = "halonic pair commit v1";
|
|
70
|
+
/** The length of the fresh nonce in pairing message 3's payload, in bytes. */
|
|
71
|
+
export declare const pairCommitNonceBytes = 16;
|
|
72
|
+
/**
|
|
73
|
+
* The bytes the phone's commitment hashes: {@link pairCommitLabel} in ASCII,
|
|
74
|
+
* the phone's static public key, and the exact bytes of its message 3 payload.
|
|
75
|
+
* Throws a `RangeError` for a key that isn't 32 bytes. The hash itself is the
|
|
76
|
+
* adapter's, like every other primitive.
|
|
77
|
+
*/
|
|
78
|
+
export declare function pairCommitInput(phoneStaticKey: Uint8Array, payload3: Uint8Array): Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* The payload of pairing message 2, from the host, encrypted: the name the
|
|
81
|
+
* phone shows for it, as {@link gatewayHostName} gives it. JSON, UTF-8.
|
|
82
|
+
*/
|
|
83
|
+
export interface PairHostPayload {
|
|
84
|
+
readonly hostName: string;
|
|
85
|
+
}
|
|
86
|
+
/** The name a host sends when nothing of its own name is left to show. */
|
|
87
|
+
export declare const gatewayFallbackHostName = "Computer";
|
|
88
|
+
/**
|
|
89
|
+
* The host's own name as it sends it in pairing message 2, so the phone can
|
|
90
|
+
* read it: without the code points the phone refuses, without spaces at either
|
|
91
|
+
* end, and cut at a whole code point to {@link gatewayMaxNameBytes} bytes of
|
|
92
|
+
* UTF-8. A lone surrogate becomes U+FFFD, since JSON can't carry it as UTF-8.
|
|
93
|
+
* When nothing is left, it is {@link gatewayFallbackHostName}.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* gatewayHostName(`Desk${String.fromCodePoint(0x202e)}kseD`); // "DeskkseD"
|
|
97
|
+
* gatewayHostName("\n"); // "Computer"
|
|
98
|
+
*/
|
|
99
|
+
export declare function gatewayHostName(name: string): string;
|
|
100
|
+
/** The name a host shows and keeps for a phone when nothing of the phone's own name is left. */
|
|
101
|
+
export declare const gatewayFallbackPhoneName = "Phone";
|
|
102
|
+
/**
|
|
103
|
+
* A name one side sent, as the other may show it: cleaned by the rules of
|
|
104
|
+
* {@link gatewayHostName}, or `fallback` when nothing is left. The host
|
|
105
|
+
* cleans a phone's name from pairing message 3 this way, with
|
|
106
|
+
* {@link gatewayFallbackPhoneName}, before it shows it next to the check code.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* gatewayReadableName(`Pixel${String.fromCodePoint(0x202e)} 8`, gatewayFallbackPhoneName); // "Pixel 8"
|
|
110
|
+
*/
|
|
111
|
+
export declare function gatewayReadableName(name: string, fallback: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* The payload of pairing message 3, from the phone, encrypted: the name and
|
|
114
|
+
* platform the host shows with the check code and keeps for the phone, and a
|
|
115
|
+
* fresh nonce of {@link pairCommitNonceBytes} bytes in base64url without
|
|
116
|
+
* padding (22 characters). The nonce makes message 3 unpredictable to anyone
|
|
117
|
+
* who sees the commitment, and keeps the commitment from linking a phone across
|
|
118
|
+
* pairings. JSON, UTF-8. The reconnect handshake's payloads are empty.
|
|
119
|
+
*/
|
|
120
|
+
export interface PairPhonePayload {
|
|
121
|
+
readonly name: string;
|
|
122
|
+
readonly platform: "android" | "ios";
|
|
123
|
+
readonly nonce: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The session's times and counts. A handshake not finished
|
|
127
|
+
* `handshakeTimeoutMs` after its first frame is closed. A sender sends a
|
|
128
|
+
* `rekey` frame at the latest `rekeyAfterMs` after its last one, or as its
|
|
129
|
+
* `rekeyAfterMessages`-th transport message since, whichever comes first; a
|
|
130
|
+
* reader closes the connection when one more message arrives without it. The
|
|
131
|
+
* host ends a session `sessionMaxMs` after its handshake, and the phone
|
|
132
|
+
* reconnects with IK.
|
|
133
|
+
*/
|
|
134
|
+
export declare const gatewaySessionLimits: {
|
|
135
|
+
readonly handshakeTimeoutMs: 10000;
|
|
136
|
+
readonly rekeyAfterMs: number;
|
|
137
|
+
readonly rekeyAfterMessages: 10000;
|
|
138
|
+
readonly sessionMaxMs: number;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The host's pairing rules, kept in memory only (build plan decision 6). A
|
|
142
|
+
* code lives `codeLifetimeMs` and pairs at most one phone: the first pairing
|
|
143
|
+
* message 3 that decrypts with it uses it up. The host then waits
|
|
144
|
+
* `allowWaitMs` for Allow. A message 3 that doesn't decrypt, or whose
|
|
145
|
+
* commitment doesn't match, is a wrong try and doesn't use the code up. So is
|
|
146
|
+
* a pairing handshake the host answered with message 2 that closes, drops or
|
|
147
|
+
* times out before a message 3 that decrypts and matches, so a leaked code
|
|
148
|
+
* can't be tried against the host's check code for free.
|
|
149
|
+
* `wrongTriesPerCode` wrong tries end the code, and the host takes at most
|
|
150
|
+
* `failedTriesPerMinute` failed tries across all codes before it refuses
|
|
151
|
+
* pairing message 1 until the minute is over.
|
|
152
|
+
*/
|
|
153
|
+
export declare const pairingRules: {
|
|
154
|
+
readonly codeLifetimeMs: number;
|
|
155
|
+
readonly allowWaitMs: number;
|
|
156
|
+
readonly wrongTriesPerCode: 5;
|
|
157
|
+
readonly failedTriesPerMinute: 10;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Why the host refused a pairing before the phone's message 3 decrypted, in
|
|
161
|
+
* the order of the byte that encodes each.
|
|
162
|
+
*
|
|
163
|
+
* - `wrong-code`: message 3 didn't decrypt; `triesLeft` is 1 to 4.
|
|
164
|
+
* - `code-ended`: the code ran out, had its last wrong try, or its dialog was
|
|
165
|
+
* closed, or no pairing is open.
|
|
166
|
+
* - `code-used`: another phone's message 3 already used the code.
|
|
167
|
+
* - `rate-limited`: the host has had too many failed tries this minute.
|
|
168
|
+
*/
|
|
169
|
+
export declare const pairRefusedReasons: readonly ["wrong-code", "code-ended", "code-used", "rate-limited"];
|
|
170
|
+
/** One of {@link pairRefusedReasons}. */
|
|
171
|
+
export type PairRefusedReason = (typeof pairRefusedReasons)[number];
|
|
172
|
+
/**
|
|
173
|
+
* A cleartext frame. `triesLeft` is 0 for every reason but `wrong-code`.
|
|
174
|
+
* After either one the host closes the connection.
|
|
175
|
+
*/
|
|
176
|
+
export type GatewayCleartextFrame = {
|
|
177
|
+
readonly kind: "handshake-failed";
|
|
178
|
+
} | {
|
|
179
|
+
readonly kind: "pair-refused";
|
|
180
|
+
readonly reason: PairRefusedReason;
|
|
181
|
+
readonly triesLeft: number;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Writes a cleartext frame: one kind byte, and for `pair-refused` the index of
|
|
185
|
+
* its reason in {@link pairRefusedReasons} and `triesLeft`. Throws a
|
|
186
|
+
* `RangeError` for a `triesLeft` the rules don't allow.
|
|
187
|
+
*/
|
|
188
|
+
export declare function encodeCleartextFrame(frame: GatewayCleartextFrame): Uint8Array;
|
|
189
|
+
/**
|
|
190
|
+
* Reads a cleartext frame, exactly as {@link encodeCleartextFrame} writes it.
|
|
191
|
+
* Anything else, including a reason or a `triesLeft` it would refuse to
|
|
192
|
+
* write, is `undefined`: the phone treats it as bytes it can't read.
|
|
193
|
+
*/
|
|
194
|
+
export declare function decodeCleartextFrame(bytes: Uint8Array): GatewayCleartextFrame | undefined;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The end-to-end session around the remote gateway protocol: the Noise
|
|
3
|
+
* handshakes, the binary frames they travel in, the two cleartext refusals,
|
|
4
|
+
* and the limits and times both sides keep (requirement
|
|
5
|
+
* `ports.remote-gateway-session`, ADR "Pairing and the end-to-end session").
|
|
6
|
+
* No crypto is done here: a Noise library does it behind an adapter.
|
|
7
|
+
*/
|
|
8
|
+
/** The Noise handshake that pairs a new phone, on the QR and the typed route alike. */
|
|
9
|
+
export const gatewayPairingPattern = "Noise_XXpsk3_25519_ChaChaPoly_SHA256";
|
|
10
|
+
/** The Noise handshake a paired phone reconnects with, to the host key it pinned. */
|
|
11
|
+
export const gatewayReconnectPattern = "Noise_IK_25519_ChaChaPoly_SHA256";
|
|
12
|
+
/**
|
|
13
|
+
* The Noise prologue of both handshakes. It names the protocol version, so a
|
|
14
|
+
* peer of another version fails the handshake instead of negotiating.
|
|
15
|
+
*/
|
|
16
|
+
export const gatewayNoisePrologue = "halonic-gateway/2";
|
|
17
|
+
/**
|
|
18
|
+
* The first byte of every binary WebSocket frame, which says what follows.
|
|
19
|
+
*
|
|
20
|
+
* - `pair1` to `pair3` carry the three messages of the pairing handshake,
|
|
21
|
+
* `resume1` and `resume2` the two of the reconnect handshake.
|
|
22
|
+
* - `message` carries one Noise transport message holding one gateway message.
|
|
23
|
+
* - `rekey` carries an empty transport message, the sender's last under its
|
|
24
|
+
* old key: it rekeys its sending direction after it, and the reader rekeys
|
|
25
|
+
* its receiving direction after reading it.
|
|
26
|
+
* - `handshake-failed` and `pair-refused` are the only cleartext frames. They
|
|
27
|
+
* are informative: anyone on the path could fake one, and neither may make
|
|
28
|
+
* the phone clear anything.
|
|
29
|
+
*
|
|
30
|
+
* Any other first byte, a frame of a kind the other side doesn't send, a
|
|
31
|
+
* handshake frame out of order or a text frame closes the connection.
|
|
32
|
+
*/
|
|
33
|
+
export const gatewayFrameKinds = {
|
|
34
|
+
pair1: 0x01,
|
|
35
|
+
pair2: 0x02,
|
|
36
|
+
pair3: 0x03,
|
|
37
|
+
resume1: 0x11,
|
|
38
|
+
resume2: 0x12,
|
|
39
|
+
message: 0x20,
|
|
40
|
+
rekey: 0x21,
|
|
41
|
+
"handshake-failed": 0x30,
|
|
42
|
+
"pair-refused": 0x31,
|
|
43
|
+
};
|
|
44
|
+
/** The largest Noise message, handshake or transport, by the Noise spec. */
|
|
45
|
+
export const noiseMaxMessageBytes = 65_535;
|
|
46
|
+
/** The largest binary frame: a kind byte and one Noise message. */
|
|
47
|
+
export const gatewayMaxFrameBytes = 1 + noiseMaxMessageBytes;
|
|
48
|
+
/**
|
|
49
|
+
* The largest handshake message, without its kind byte. The longest, pairing
|
|
50
|
+
* message 3, is 32 + 16 bytes of key and tag and a payload with a name of at
|
|
51
|
+
* most {@link gatewayMaxNameBytes} and a nonce, so a larger one is an attack.
|
|
52
|
+
*/
|
|
53
|
+
export const gatewayMaxHandshakeBytes = 1_024;
|
|
54
|
+
/** The longest name in a handshake payload, the host's or the phone's, in bytes of UTF-8. */
|
|
55
|
+
export const gatewayMaxNameBytes = 64;
|
|
56
|
+
/** What the phone's commitment starts with, in ASCII: it names the use and its version. */
|
|
57
|
+
export const pairCommitLabel = "halonic pair commit v1";
|
|
58
|
+
/** The length of the fresh nonce in pairing message 3's payload, in bytes. */
|
|
59
|
+
export const pairCommitNonceBytes = 16;
|
|
60
|
+
/**
|
|
61
|
+
* The bytes the phone's commitment hashes: {@link pairCommitLabel} in ASCII,
|
|
62
|
+
* the phone's static public key, and the exact bytes of its message 3 payload.
|
|
63
|
+
* Throws a `RangeError` for a key that isn't 32 bytes. The hash itself is the
|
|
64
|
+
* adapter's, like every other primitive.
|
|
65
|
+
*/
|
|
66
|
+
export function pairCommitInput(phoneStaticKey, payload3) {
|
|
67
|
+
if (phoneStaticKey.length !== 32) {
|
|
68
|
+
throw new RangeError("a phone's static key is 32 bytes");
|
|
69
|
+
}
|
|
70
|
+
const label = Uint8Array.from(pairCommitLabel, (c) => c.charCodeAt(0));
|
|
71
|
+
const input = new Uint8Array(label.length + 32 + payload3.length);
|
|
72
|
+
input.set(label, 0);
|
|
73
|
+
input.set(phoneStaticKey, label.length);
|
|
74
|
+
input.set(payload3, label.length + 32);
|
|
75
|
+
return input;
|
|
76
|
+
}
|
|
77
|
+
/** The name a host sends when nothing of its own name is left to show. */
|
|
78
|
+
export const gatewayFallbackHostName = "Computer";
|
|
79
|
+
/**
|
|
80
|
+
* The code points the phone refuses in a host name, as unreadable (requirement
|
|
81
|
+
* `ports.remote-gateway-host-name`): control characters, the line and
|
|
82
|
+
* paragraph separators, the bidi marks, embeddings, overrides and isolates,
|
|
83
|
+
* the zero width space, the word joiner and invisible operators, and the byte
|
|
84
|
+
* order mark. The zero width non-joiner and joiner (U+200C, U+200D) stay:
|
|
85
|
+
* Persian, the Indic scripts and emoji need them. Written as numbers, so the
|
|
86
|
+
* source holds no invisible character itself.
|
|
87
|
+
*/
|
|
88
|
+
const notPlainRanges = [
|
|
89
|
+
[0x0000, 0x001f],
|
|
90
|
+
[0x007f, 0x009f],
|
|
91
|
+
[0x061c, 0x061c],
|
|
92
|
+
[0x200b, 0x200b],
|
|
93
|
+
[0x200e, 0x200f],
|
|
94
|
+
[0x2028, 0x202e],
|
|
95
|
+
[0x2060, 0x2064],
|
|
96
|
+
[0x2066, 0x2069],
|
|
97
|
+
[0xfeff, 0xfeff],
|
|
98
|
+
];
|
|
99
|
+
/**
|
|
100
|
+
* The host's own name as it sends it in pairing message 2, so the phone can
|
|
101
|
+
* read it: without the code points the phone refuses, without spaces at either
|
|
102
|
+
* end, and cut at a whole code point to {@link gatewayMaxNameBytes} bytes of
|
|
103
|
+
* UTF-8. A lone surrogate becomes U+FFFD, since JSON can't carry it as UTF-8.
|
|
104
|
+
* When nothing is left, it is {@link gatewayFallbackHostName}.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* gatewayHostName(`Desk${String.fromCodePoint(0x202e)}kseD`); // "DeskkseD"
|
|
108
|
+
* gatewayHostName("\n"); // "Computer"
|
|
109
|
+
*/
|
|
110
|
+
export function gatewayHostName(name) {
|
|
111
|
+
return gatewayReadableName(name, gatewayFallbackHostName);
|
|
112
|
+
}
|
|
113
|
+
/** The name a host shows and keeps for a phone when nothing of the phone's own name is left. */
|
|
114
|
+
export const gatewayFallbackPhoneName = "Phone";
|
|
115
|
+
/**
|
|
116
|
+
* A name one side sent, as the other may show it: cleaned by the rules of
|
|
117
|
+
* {@link gatewayHostName}, or `fallback` when nothing is left. The host
|
|
118
|
+
* cleans a phone's name from pairing message 3 this way, with
|
|
119
|
+
* {@link gatewayFallbackPhoneName}, before it shows it next to the check code.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* gatewayReadableName(`Pixel${String.fromCodePoint(0x202e)} 8`, gatewayFallbackPhoneName); // "Pixel 8"
|
|
123
|
+
*/
|
|
124
|
+
export function gatewayReadableName(name, fallback) {
|
|
125
|
+
let plain = "";
|
|
126
|
+
for (const character of name.toWellFormed()) {
|
|
127
|
+
const point = character.codePointAt(0) ?? 0;
|
|
128
|
+
if (!notPlainRanges.some(([first, last]) => point >= first && point <= last)) {
|
|
129
|
+
plain += character;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
let kept = "";
|
|
133
|
+
let bytes = 0;
|
|
134
|
+
for (const character of plain.trim()) {
|
|
135
|
+
bytes += utf8Length(character.codePointAt(0) ?? 0);
|
|
136
|
+
if (bytes > gatewayMaxNameBytes)
|
|
137
|
+
break;
|
|
138
|
+
kept += character;
|
|
139
|
+
}
|
|
140
|
+
return kept.trimEnd() || fallback;
|
|
141
|
+
}
|
|
142
|
+
/** How many bytes of UTF-8 a code point takes. */
|
|
143
|
+
function utf8Length(point) {
|
|
144
|
+
if (point < 0x80)
|
|
145
|
+
return 1;
|
|
146
|
+
if (point < 0x800)
|
|
147
|
+
return 2;
|
|
148
|
+
if (point < 0x10000)
|
|
149
|
+
return 3;
|
|
150
|
+
return 4;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The session's times and counts. A handshake not finished
|
|
154
|
+
* `handshakeTimeoutMs` after its first frame is closed. A sender sends a
|
|
155
|
+
* `rekey` frame at the latest `rekeyAfterMs` after its last one, or as its
|
|
156
|
+
* `rekeyAfterMessages`-th transport message since, whichever comes first; a
|
|
157
|
+
* reader closes the connection when one more message arrives without it. The
|
|
158
|
+
* host ends a session `sessionMaxMs` after its handshake, and the phone
|
|
159
|
+
* reconnects with IK.
|
|
160
|
+
*/
|
|
161
|
+
export const gatewaySessionLimits = {
|
|
162
|
+
handshakeTimeoutMs: 10_000,
|
|
163
|
+
rekeyAfterMs: 30 * 60_000,
|
|
164
|
+
rekeyAfterMessages: 10_000,
|
|
165
|
+
sessionMaxMs: 24 * 60 * 60_000,
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* The host's pairing rules, kept in memory only (build plan decision 6). A
|
|
169
|
+
* code lives `codeLifetimeMs` and pairs at most one phone: the first pairing
|
|
170
|
+
* message 3 that decrypts with it uses it up. The host then waits
|
|
171
|
+
* `allowWaitMs` for Allow. A message 3 that doesn't decrypt, or whose
|
|
172
|
+
* commitment doesn't match, is a wrong try and doesn't use the code up. So is
|
|
173
|
+
* a pairing handshake the host answered with message 2 that closes, drops or
|
|
174
|
+
* times out before a message 3 that decrypts and matches, so a leaked code
|
|
175
|
+
* can't be tried against the host's check code for free.
|
|
176
|
+
* `wrongTriesPerCode` wrong tries end the code, and the host takes at most
|
|
177
|
+
* `failedTriesPerMinute` failed tries across all codes before it refuses
|
|
178
|
+
* pairing message 1 until the minute is over.
|
|
179
|
+
*/
|
|
180
|
+
export const pairingRules = {
|
|
181
|
+
codeLifetimeMs: 5 * 60_000,
|
|
182
|
+
allowWaitMs: 2 * 60_000,
|
|
183
|
+
wrongTriesPerCode: 5,
|
|
184
|
+
failedTriesPerMinute: 10,
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Why the host refused a pairing before the phone's message 3 decrypted, in
|
|
188
|
+
* the order of the byte that encodes each.
|
|
189
|
+
*
|
|
190
|
+
* - `wrong-code`: message 3 didn't decrypt; `triesLeft` is 1 to 4.
|
|
191
|
+
* - `code-ended`: the code ran out, had its last wrong try, or its dialog was
|
|
192
|
+
* closed, or no pairing is open.
|
|
193
|
+
* - `code-used`: another phone's message 3 already used the code.
|
|
194
|
+
* - `rate-limited`: the host has had too many failed tries this minute.
|
|
195
|
+
*/
|
|
196
|
+
export const pairRefusedReasons = [
|
|
197
|
+
"wrong-code",
|
|
198
|
+
"code-ended",
|
|
199
|
+
"code-used",
|
|
200
|
+
"rate-limited",
|
|
201
|
+
];
|
|
202
|
+
/**
|
|
203
|
+
* Writes a cleartext frame: one kind byte, and for `pair-refused` the index of
|
|
204
|
+
* its reason in {@link pairRefusedReasons} and `triesLeft`. Throws a
|
|
205
|
+
* `RangeError` for a `triesLeft` the rules don't allow.
|
|
206
|
+
*/
|
|
207
|
+
export function encodeCleartextFrame(frame) {
|
|
208
|
+
if (frame.kind === "handshake-failed") {
|
|
209
|
+
return Uint8Array.of(gatewayFrameKinds["handshake-failed"]);
|
|
210
|
+
}
|
|
211
|
+
const most = frame.reason === "wrong-code" ? pairingRules.wrongTriesPerCode - 1 : 0;
|
|
212
|
+
const least = frame.reason === "wrong-code" ? 1 : 0;
|
|
213
|
+
if (!Number.isInteger(frame.triesLeft) || frame.triesLeft < least || frame.triesLeft > most) {
|
|
214
|
+
throw new RangeError(`triesLeft for ${frame.reason} must be ${least} to ${most}`);
|
|
215
|
+
}
|
|
216
|
+
return Uint8Array.of(gatewayFrameKinds["pair-refused"], pairRefusedReasons.indexOf(frame.reason), frame.triesLeft);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Reads a cleartext frame, exactly as {@link encodeCleartextFrame} writes it.
|
|
220
|
+
* Anything else, including a reason or a `triesLeft` it would refuse to
|
|
221
|
+
* write, is `undefined`: the phone treats it as bytes it can't read.
|
|
222
|
+
*/
|
|
223
|
+
export function decodeCleartextFrame(bytes) {
|
|
224
|
+
const [kind, reasonByte, triesLeft] = bytes;
|
|
225
|
+
if (kind === gatewayFrameKinds["handshake-failed"] && bytes.length === 1) {
|
|
226
|
+
return { kind: "handshake-failed" };
|
|
227
|
+
}
|
|
228
|
+
if (kind !== gatewayFrameKinds["pair-refused"] || bytes.length !== 3)
|
|
229
|
+
return undefined;
|
|
230
|
+
const reason = pairRefusedReasons[reasonByte];
|
|
231
|
+
if (reason === undefined || triesLeft === undefined)
|
|
232
|
+
return undefined;
|
|
233
|
+
const frame = { kind: "pair-refused", reason, triesLeft };
|
|
234
|
+
try {
|
|
235
|
+
encodeCleartextFrame(frame);
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
return undefined;
|
|
239
|
+
}
|
|
240
|
+
return frame;
|
|
241
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CantTryStep, ModelSkipReason, RunEvent, RunKind, RunSummary, RunTrigger, RunVersion } from "../../events/src/index.js";
|
|
1
|
+
import type { ApprovalResolver, CantTryStep, ModelSkipReason, RunEvent, RunKind, RunSummary, RunTrigger, RunVersion } from "../../events/src/index.js";
|
|
2
2
|
import type { ChatMessage, ChatParams, ChatResponse, ToolDefinition } from "./chat.js";
|
|
3
3
|
/** Version of the {@link RunExecutor} port. A breaking change bumps it and comes with an ADR. */
|
|
4
|
-
export declare const runExecutorVersion =
|
|
4
|
+
export declare const runExecutorVersion = 2;
|
|
5
5
|
/**
|
|
6
6
|
* Start a workflow run. Subflows are not started through this port: the
|
|
7
7
|
* engine starts them inside the executor, which also tells the parent when a
|
|
@@ -32,8 +32,8 @@ export interface StartRunRequest {
|
|
|
32
32
|
* Which version of the workspace the run reads, as the caller loaded it:
|
|
33
33
|
* the live version, with its commit and date, or the saved files. It goes
|
|
34
34
|
* on `run.started`, and the run's child runs record it too. Not recorded
|
|
35
|
-
* when absent. The executor
|
|
36
|
-
*
|
|
35
|
+
* when absent. The local executor passes it to `definitionsOf`, so the
|
|
36
|
+
* host gives the run that version's files; it doesn't check them against it.
|
|
37
37
|
*/
|
|
38
38
|
version?: RunVersion;
|
|
39
39
|
/**
|
|
@@ -73,6 +73,24 @@ export interface SendOptions {
|
|
|
73
73
|
* next one by accident. Absent: no check.
|
|
74
74
|
*/
|
|
75
75
|
readonly callId?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The wait step the event is meant for, as the run's summary names it: its
|
|
78
|
+
* state and the time it started waiting (`lastWaitingAt`). When it is given
|
|
79
|
+
* and the run now waits at another step, or has waited again since, `send`
|
|
80
|
+
* is refused before anything is recorded: a person who answered a wait
|
|
81
|
+
* card that has since moved on must not answer the next wait step by
|
|
82
|
+
* accident. Absent: no check.
|
|
83
|
+
*/
|
|
84
|
+
readonly wait?: {
|
|
85
|
+
readonly state: string;
|
|
86
|
+
readonly since: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Where a person's answer to an approval came from, so the run log can say
|
|
90
|
+
* so: `person` at the screen, `remote-device` from a phone. The host sets
|
|
91
|
+
* it from who is signed in, never from what a phone sends. Absent: `person`.
|
|
92
|
+
*/
|
|
93
|
+
readonly by?: Extract<ApprovalResolver, "person" | "remote-device">;
|
|
76
94
|
}
|
|
77
95
|
/** An agent's model settings for a chat turn that aren't saved in a file yet. */
|
|
78
96
|
export interface ChatAgentSettings {
|
|
@@ -128,6 +146,18 @@ export interface ChatTurnRefusal {
|
|
|
128
146
|
/** Why, as plain text. Text a server wrote is cut and escaped before it gets here. */
|
|
129
147
|
reason: string;
|
|
130
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A listed tool a chat turn left out because nobody approved it yet, as data
|
|
151
|
+
* a status view can read (requirement `ports.chat-turn-waiting`). Waiting
|
|
152
|
+
* isn't a refusal: the tool broke no rule, and it is offered once a person
|
|
153
|
+
* approves it. It never goes to the model.
|
|
154
|
+
*/
|
|
155
|
+
export interface ChatTurnWaiting {
|
|
156
|
+
/** The id of the connector that lists the tool. */
|
|
157
|
+
source: string;
|
|
158
|
+
/** The name the server lists the tool under, cut to 64 characters and escaped. */
|
|
159
|
+
name: string;
|
|
160
|
+
}
|
|
131
161
|
/**
|
|
132
162
|
* A model alias a chat turn skipped before calling it. It is what an
|
|
133
163
|
* `llm.skipped` run log event says, for a turn that has no run log.
|
|
@@ -160,6 +190,11 @@ export interface ChatTurnResponse extends ChatResponse {
|
|
|
160
190
|
turn?: ChatMessage[];
|
|
161
191
|
/** What the turn refused, in the order it happened. Absent or empty when it refused nothing. */
|
|
162
192
|
refusals?: ChatTurnRefusal[];
|
|
193
|
+
/**
|
|
194
|
+
* The listed tools left out because they wait for a person's approval.
|
|
195
|
+
* Absent or empty when none did.
|
|
196
|
+
*/
|
|
197
|
+
waiting?: ChatTurnWaiting[];
|
|
163
198
|
/** The model aliases skipped before any call, in order. Absent or empty when none was. */
|
|
164
199
|
skipped?: ChatTurnSkip[];
|
|
165
200
|
}
|
|
@@ -217,21 +252,23 @@ export interface RunExecutor {
|
|
|
217
252
|
/**
|
|
218
253
|
* Starts a workflow run, or returns the existing one for a repeated `runId`.
|
|
219
254
|
*
|
|
220
|
-
* @throws when the hub or workflow doesn't exist
|
|
255
|
+
* @throws RunTargetNotFound when the hub or workflow doesn't exist
|
|
256
|
+
* @throws when the input is refused
|
|
221
257
|
*/
|
|
222
258
|
start(request: StartRunRequest): Promise<RunSummary>;
|
|
223
259
|
/**
|
|
224
260
|
* Starts a run of one agent; its workflow id is "agent:<agentId>". A
|
|
225
261
|
* repeated `runId` returns the existing run.
|
|
226
262
|
*
|
|
227
|
-
* @throws when the hub or agent doesn't exist
|
|
263
|
+
* @throws RunTargetNotFound when the hub or agent doesn't exist
|
|
228
264
|
*/
|
|
229
265
|
startAgent(request: StartAgentRequest): Promise<RunSummary>;
|
|
230
266
|
/**
|
|
231
267
|
* Delivers an event to a waiting run, such as "approve".
|
|
232
268
|
*
|
|
233
269
|
* @throws when the run doesn't exist, doesn't accept the event now, or
|
|
234
|
-
* doesn't wait on the call that `options.callId`
|
|
270
|
+
* doesn't wait on the call that `options.callId` or the step that
|
|
271
|
+
* `options.wait` names
|
|
235
272
|
*/
|
|
236
273
|
send(runId: string, event: string, payload?: unknown, options?: SendOptions): Promise<RunSummary>;
|
|
237
274
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Version of the {@link RunExecutor} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
-
export const runExecutorVersion =
|
|
2
|
+
export const runExecutorVersion = 2;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** What a run was asked to start does not exist: a hub, a workflow in a hub, or an agent in a hub. */
|
|
2
|
+
export type RunTargetKind = "hub" | "workflow" | "agent";
|
|
3
|
+
/**
|
|
4
|
+
* What {@link RunExecutor.start} and `startAgent` throw when the hub, the
|
|
5
|
+
* workflow or the agent the request names doesn't exist (requirement
|
|
6
|
+
* `ports.run-target-not-found`). A caller that answers a person, such as the
|
|
7
|
+
* host's run routes, can then tell a wrong name from a real failure.
|
|
8
|
+
*
|
|
9
|
+
* It is a `RangeError`, as the lookups threw before. Check for it with
|
|
10
|
+
* {@link isRunTargetNotFound}, not `instanceof`: an executor may be built
|
|
11
|
+
* against its own copy of this package.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* throw new RunTargetNotFound("workflow", "tidy", 'The hub "billing" has no workflow "tidy".');
|
|
15
|
+
*/
|
|
16
|
+
export declare class RunTargetNotFound extends RangeError {
|
|
17
|
+
readonly name = "RunTargetNotFound";
|
|
18
|
+
/** Which kind of thing is missing. */
|
|
19
|
+
readonly kind: RunTargetKind;
|
|
20
|
+
/** The id the request named. */
|
|
21
|
+
readonly id: string;
|
|
22
|
+
/**
|
|
23
|
+
* @param kind - which kind of thing is missing
|
|
24
|
+
* @param id - the id the request named
|
|
25
|
+
* @param message - safe to log; the host doesn't send it to a client
|
|
26
|
+
*/
|
|
27
|
+
constructor(kind: RunTargetKind, id: string, message: string);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether `value` is a {@link RunTargetNotFound}: an `Error` named
|
|
31
|
+
* "RunTargetNotFound" with a known `kind` and an `id`. It works across
|
|
32
|
+
* copies of this package, where `instanceof` doesn't.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isRunTargetNotFound(value: unknown): value is RunTargetNotFound;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What {@link RunExecutor.start} and `startAgent` throw when the hub, the
|
|
3
|
+
* workflow or the agent the request names doesn't exist (requirement
|
|
4
|
+
* `ports.run-target-not-found`). A caller that answers a person, such as the
|
|
5
|
+
* host's run routes, can then tell a wrong name from a real failure.
|
|
6
|
+
*
|
|
7
|
+
* It is a `RangeError`, as the lookups threw before. Check for it with
|
|
8
|
+
* {@link isRunTargetNotFound}, not `instanceof`: an executor may be built
|
|
9
|
+
* against its own copy of this package.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* throw new RunTargetNotFound("workflow", "tidy", 'The hub "billing" has no workflow "tidy".');
|
|
13
|
+
*/
|
|
14
|
+
export class RunTargetNotFound extends RangeError {
|
|
15
|
+
name = "RunTargetNotFound";
|
|
16
|
+
/** Which kind of thing is missing. */
|
|
17
|
+
kind;
|
|
18
|
+
/** The id the request named. */
|
|
19
|
+
id;
|
|
20
|
+
/**
|
|
21
|
+
* @param kind - which kind of thing is missing
|
|
22
|
+
* @param id - the id the request named
|
|
23
|
+
* @param message - safe to log; the host doesn't send it to a client
|
|
24
|
+
*/
|
|
25
|
+
constructor(kind, id, message) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.kind = kind;
|
|
28
|
+
this.id = id;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Whether `value` is a {@link RunTargetNotFound}: an `Error` named
|
|
33
|
+
* "RunTargetNotFound" with a known `kind` and an `id`. It works across
|
|
34
|
+
* copies of this package, where `instanceof` doesn't.
|
|
35
|
+
*/
|
|
36
|
+
export function isRunTargetNotFound(value) {
|
|
37
|
+
if (!(value instanceof Error) || value.name !== "RunTargetNotFound")
|
|
38
|
+
return false;
|
|
39
|
+
const { kind, id } = value;
|
|
40
|
+
return (kind === "hub" || kind === "workflow" || kind === "agent") && typeof id === "string";
|
|
41
|
+
}
|