@halonicjs/testing 0.1.1 → 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.
Files changed (122) hide show
  1. package/dist/adapters/http-kit/src/connector-host-class.d.ts +14 -0
  2. package/dist/adapters/http-kit/src/connector-host-class.js +34 -0
  3. package/dist/adapters/http-kit/src/index.d.ts +2 -0
  4. package/dist/adapters/http-kit/src/index.js +2 -0
  5. package/dist/adapters/http-kit/src/ollama-tags.d.ts +20 -0
  6. package/dist/adapters/http-kit/src/ollama-tags.js +38 -0
  7. package/dist/adapters/integration-kit/src/index.d.ts +2 -1
  8. package/dist/adapters/integration-kit/src/index.js +1 -0
  9. package/dist/adapters/integration-kit/src/loader.d.ts +2 -12
  10. package/dist/adapters/integration-kit/src/loader.js +3 -20
  11. package/dist/adapters/integration-kit/src/workspace-choices.d.ts +37 -0
  12. package/dist/adapters/integration-kit/src/workspace-choices.js +37 -0
  13. package/dist/core/events/src/connector-listing-failed.d.ts +18 -0
  14. package/dist/core/events/src/connector-listing-failed.js +1 -0
  15. package/dist/core/events/src/home-path.d.ts +4 -1
  16. package/dist/core/events/src/home-path.js +14 -3
  17. package/dist/core/events/src/index.d.ts +4 -2
  18. package/dist/core/events/src/index.js +2 -0
  19. package/dist/core/events/src/provider-notes.d.ts +16 -0
  20. package/dist/core/events/src/provider-notes.js +24 -0
  21. package/dist/core/events/src/run-basics.d.ts +103 -5
  22. package/dist/core/events/src/run-event.d.ts +72 -7
  23. package/dist/core/events/src/run-summary.d.ts +11 -1
  24. package/dist/core/events/src/sandbox-opened-read.d.ts +2 -1
  25. package/dist/core/events/src/sandbox-opened-read.js +27 -2
  26. package/dist/core/events/src/sandbox-opened.d.ts +37 -4
  27. package/dist/core/events/src/sandbox-opened.js +13 -3
  28. package/dist/core/events/src/summarize.js +3 -0
  29. package/dist/core/events/src/tool-failure-cause.d.ts +25 -0
  30. package/dist/core/events/src/tool-failure-cause.js +66 -0
  31. package/dist/core/format/src/index.d.ts +3 -2
  32. package/dist/core/format/src/index.js +3 -1
  33. package/dist/core/format/src/kinds/agent/harness-limits.d.ts +14 -0
  34. package/dist/core/format/src/kinds/agent/harness-limits.js +27 -0
  35. package/dist/core/format/src/kinds/agent/schema.d.ts +5 -0
  36. package/dist/core/format/src/kinds/agent/schema.js +3 -0
  37. package/dist/core/format/src/kinds/connector/kind.js +24 -3
  38. package/dist/core/format/src/kinds/connector/schema.d.ts +14 -0
  39. package/dist/core/format/src/kinds/connector/schema.js +18 -0
  40. package/dist/core/format/src/kinds/integration/schema.js +1 -1
  41. package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +2 -1
  42. package/dist/core/format/src/kinds/integration/sign-in-checks.js +33 -3
  43. package/dist/core/format/src/kinds/plugin/checks.d.ts +3 -2
  44. package/dist/core/format/src/kinds/plugin/checks.js +17 -5
  45. package/dist/core/format/src/kinds/plugin/schema.js +24 -4
  46. package/dist/core/format/src/kinds/provider/kind.js +40 -1
  47. package/dist/core/format/src/kinds/provider/types.d.ts +19 -0
  48. package/dist/core/format/src/kinds/provider/types.js +22 -0
  49. package/dist/core/format/src/kinds/routine/schema.d.ts +10 -5
  50. package/dist/core/format/src/kinds/routine/schema.js +21 -15
  51. package/dist/core/format/src/kinds/workspace/schema.js +5 -4
  52. package/dist/core/format/src/parse-file.js +3 -1
  53. package/dist/core/format/src/shared/fields.d.ts +9 -2
  54. package/dist/core/format/src/shared/fields.js +15 -6
  55. package/dist/core/format/src/shared/guard.d.ts +8 -0
  56. package/dist/core/format/src/shared/guard.js +50 -1
  57. package/dist/core/format/src/shared/missing-keys.d.ts +17 -0
  58. package/dist/core/format/src/shared/missing-keys.js +110 -0
  59. package/dist/core/ports/src/chat.d.ts +8 -0
  60. package/dist/core/ports/src/connector-start-failure.d.ts +31 -0
  61. package/dist/core/ports/src/connector-start-failure.js +32 -0
  62. package/dist/core/ports/src/connector-tool-error.d.ts +33 -0
  63. package/dist/core/ports/src/connector-tool-error.js +40 -0
  64. package/dist/core/ports/src/definition-store-left-out.d.ts +46 -0
  65. package/dist/core/ports/src/definition-store-left-out.js +47 -0
  66. package/dist/core/ports/src/definition-store.d.ts +13 -3
  67. package/dist/core/ports/src/definition-store.js +1 -1
  68. package/dist/core/ports/src/deploy-target.d.ts +358 -0
  69. package/dist/core/ports/src/deploy-target.js +2 -0
  70. package/dist/core/ports/src/harness-bridge-server.d.ts +55 -4
  71. package/dist/core/ports/src/harness.d.ts +33 -2
  72. package/dist/core/ports/src/host-too-old.d.ts +23 -0
  73. package/dist/core/ports/src/host-too-old.js +27 -0
  74. package/dist/core/ports/src/index.d.ts +16 -5
  75. package/dist/core/ports/src/index.js +15 -3
  76. package/dist/core/ports/src/llm-provider.d.ts +37 -6
  77. package/dist/core/ports/src/llm-provider.js +43 -3
  78. package/dist/core/ports/src/pairing-codes.d.ts +111 -0
  79. package/dist/core/ports/src/pairing-codes.js +336 -0
  80. package/dist/core/ports/src/pairing-qr-bytes.d.ts +32 -0
  81. package/dist/core/ports/src/pairing-qr-bytes.js +116 -0
  82. package/dist/core/ports/src/port-versions.d.ts +6 -2
  83. package/dist/core/ports/src/port-versions.js +8 -0
  84. package/dist/core/ports/src/remote-control.d.ts +159 -0
  85. package/dist/core/ports/src/remote-control.js +26 -0
  86. package/dist/core/ports/src/remote-gateway-protocol.d.ts +220 -0
  87. package/dist/core/ports/src/remote-gateway-protocol.js +62 -0
  88. package/dist/core/ports/src/remote-gateway-session.d.ts +194 -0
  89. package/dist/core/ports/src/remote-gateway-session.js +241 -0
  90. package/dist/core/ports/src/run-executor.d.ts +39 -3
  91. package/dist/core/ports/src/run-executor.js +1 -1
  92. package/dist/core/ports/src/sandbox.d.ts +19 -0
  93. package/dist/core/ports/src/sandbox.js +14 -0
  94. package/dist/core/ports/src/secrets.d.ts +32 -1
  95. package/dist/core/ports/src/secrets.js +19 -2
  96. package/dist/core/ports/src/tunnel-provider.d.ts +117 -0
  97. package/dist/core/ports/src/tunnel-provider.js +65 -0
  98. package/dist/core/ports/src/tunnel-resolver.d.ts +83 -0
  99. package/dist/core/ports/src/tunnel-resolver.js +36 -0
  100. package/dist/core/ports/src/vcs.d.ts +30 -0
  101. package/dist/core/schema-kit/src/builders.d.ts +5 -0
  102. package/dist/core/schema-kit/src/builders.js +5 -0
  103. package/dist/core/std/src/hidden-characters.d.ts +9 -0
  104. package/dist/core/std/src/hidden-characters.js +18 -0
  105. package/dist/core/std/src/index.d.ts +3 -1
  106. package/dist/core/std/src/index.js +3 -1
  107. package/dist/core/std/src/path-overlap.d.ts +22 -0
  108. package/dist/core/std/src/path-overlap.js +57 -0
  109. package/dist/core/std/src/public-suffixes.generated.d.ts +1 -1
  110. package/dist/core/std/src/public-suffixes.generated.js +0 -1
  111. package/dist/core/std/src/word-diff.d.ts +28 -0
  112. package/dist/core/std/src/word-diff.js +77 -0
  113. package/dist/core/yaml/src/edit-data.d.ts +7 -0
  114. package/dist/core/yaml/src/edit-data.js +62 -3
  115. package/dist/core/yaml/src/edit.d.ts +7 -0
  116. package/dist/core/yaml/src/edit.js +34 -3
  117. package/dist/core/yaml/src/splice-node.d.ts +6 -0
  118. package/dist/core/yaml/src/splice-node.js +10 -0
  119. package/dist/core/yaml/src/splice.js +20 -10
  120. package/dist/testing/integration/src/checks.d.ts +5 -3
  121. package/dist/testing/integration/src/checks.js +31 -3
  122. package/package.json +9 -2
@@ -1,5 +1,6 @@
1
1
  import type { AgentResume } from "./agent-resume.js";
2
- import type { ApprovalResolver, CantTryStep, ModelSkipReason, ProviderText, RunFailureReason, RunKind, RunParent, RunTrigger, RunVersion, StoredBlob, ToolNoun, ToolOutcome, ToolRefusalReason, ToolRisk, ToolUnaskedReason, ToolVerb, Usage } from "./run-basics.js";
2
+ import type { ConnectorListingFailedEvent } from "./connector-listing-failed.js";
3
+ import type { ApprovalResolver, CantTryStep, HarnessStartCause, LoggedInstructionPin, ModelSkipReason, ProviderText, RunFailureCause, RunFailureReason, RunKind, RunParent, RunTrigger, RunVersion, StoredBlob, ToolFailureCause, ToolNoun, ToolOutcome, ToolRefusalReason, ToolRisk, ToolUnaskedReason, ToolVerb, Usage } from "./run-basics.js";
3
4
  import type { LoggedSandboxBlock } from "./sandbox-blocked.js";
4
5
  import type { SandboxOpenedView } from "./sandbox-opened.js";
5
6
  /** The fields every event in a run log has, whatever its type. */
@@ -65,11 +66,22 @@ export type RunEventBody = {
65
66
  agent: string;
66
67
  prompt: string;
67
68
  parent?: string;
68
- } | {
69
+ }
70
+ /**
71
+ * `alias`: the model alias the call went to, such as `fast`; absent in
72
+ * older logs and when the model has none (requirement
73
+ * `engine.llm-request-alias`). `address`: the `host:port` of a provider on
74
+ * this computer, such as `localhost:11434`, never a URL, path or user
75
+ * name; absent for any other provider and in older logs (requirement
76
+ * `engine.llm-event-address`).
77
+ */
78
+ | {
69
79
  type: "llm.request";
70
80
  agent: string;
71
81
  provider: string;
72
82
  model: string;
83
+ alias?: string;
84
+ address?: string;
73
85
  messages: number;
74
86
  } | {
75
87
  type: "llm.response";
@@ -107,17 +119,32 @@ export type RunEventBody = {
107
119
  * `events.tool-call-as-text`). That call never runs. Absent otherwise.
108
120
  */
109
121
  toolCallAsText?: true;
122
+ /**
123
+ * The provider's plain sentences on how it changed the call, such as
124
+ * a setting the model doesn't take (requirement
125
+ * `events.provider-notes`). Kept on every call they came with; shown
126
+ * once per run (`providerNotes`). Absent otherwise.
127
+ */
128
+ notes?: string[];
110
129
  }
111
130
  /**
112
131
  * The call moved on to the next model. `providerText`: the provider's own
113
132
  * error text, for `--debug` and Copy details only (requirement
114
133
  * `events.provider-text`); absent in older logs and when it gave none.
134
+ * `provider`, `model`, `alias` and `address` name the model it moved to,
135
+ * as `llm.request` does, so a reader stops naming the one that failed
136
+ * (requirement `engine.llm-event-address`); absent in older logs, and
137
+ * `alias` and `address` as in `llm.request`.
115
138
  */
116
139
  | {
117
140
  type: "llm.fallback";
118
141
  agent: string;
119
142
  from: string;
120
143
  to: string;
144
+ provider?: string;
145
+ model?: string;
146
+ alias?: string;
147
+ address?: string;
121
148
  error: string;
122
149
  providerText?: ProviderText;
123
150
  }
@@ -134,6 +161,19 @@ export type RunEventBody = {
134
161
  model: string;
135
162
  reason: ModelSkipReason;
136
163
  next?: string;
164
+ }
165
+ /**
166
+ * A request of the agent's program to the harness bridge failed for a reason
167
+ * the bridge didn't name to the program, which was told the run log has the
168
+ * details (requirement `events.bridge-failed`). `kind`: the error kind of
169
+ * `@halonicjs/std`, such as `internal`. `message`: the error's own text,
170
+ * never holding the run token. It never counts towards a budget.
171
+ */
172
+ | {
173
+ type: "bridge.failed";
174
+ agent: string;
175
+ kind: string;
176
+ message: string;
137
177
  } | {
138
178
  type: "tool.called";
139
179
  agent: string;
@@ -257,7 +297,7 @@ export type RunEventBody = {
257
297
  agent: string;
258
298
  connector: string;
259
299
  timeoutMs: number;
260
- }
300
+ } | ConnectorListingFailedEvent
261
301
  /**
262
302
  * A step is about to make a connector call that can change things
263
303
  * (requirement `events.effect-requested`). Written before the call, so a
@@ -298,6 +338,8 @@ export type RunEventBody = {
298
338
  * `resultBlob`: set when the result was too large for the log; `result`
299
339
  * then holds only its start, and the whole result is in the blob store
300
340
  * (requirement `events.tool-result-blob`).
341
+ * `cause`: why the call failed, when the engine knows (requirement
342
+ * `events.tool-result-cause`); read it with `toolFailureCauseOf`.
301
343
  */
302
344
  | {
303
345
  type: "tool.result";
@@ -309,6 +351,7 @@ export type RunEventBody = {
309
351
  noun?: ToolNoun;
310
352
  verb?: ToolVerb;
311
353
  resultBlob?: StoredBlob;
354
+ cause?: ToolFailureCause;
312
355
  }
313
356
  /** A connector tool call that needs a person's OK; the run waits for "approve" or "reject". */
314
357
  | {
@@ -321,6 +364,8 @@ export type RunEventBody = {
321
364
  resume: AgentResume;
322
365
  /** The subagent whose call it is (requirement `events.agent-resume-inner`); absent for the state's own agent. */
323
366
  subagent?: string;
367
+ /** The connector the tool comes from (requirement `events.approval-requested-connector`); absent in older logs. `tool` stays the bare name. */
368
+ connector?: string;
324
369
  } | {
325
370
  type: "approval.resolved";
326
371
  state: string;
@@ -329,7 +374,7 @@ export type RunEventBody = {
329
374
  callId: string;
330
375
  approved: boolean;
331
376
  comment?: string;
332
- /** Who resolved it (requirement `events.approval-resolved-by`); absent in older logs. */
377
+ /** Who resolved it (requirements `events.approval-resolved-by` and `events.approval-resolved-remote`); absent in older logs. */
333
378
  by?: ApprovalResolver;
334
379
  }
335
380
  /**
@@ -339,6 +384,8 @@ export type RunEventBody = {
339
384
  * that answered.
340
385
  * `cantTry`: set instead of `reason` when the agent's step couldn't be
341
386
  * tried (requirement `events.run-cant-try`), as a parallel branch reports it.
387
+ * `pin` and `changed`: with the reason `instructions-not-trusted` only, as `run.failed` gives them
388
+ * (requirement `events.run-failed-instructions-not-trusted`); `agent` is the one that didn't start.
342
389
  */
343
390
  | {
344
391
  type: "agent.finished";
@@ -348,6 +395,8 @@ export type RunEventBody = {
348
395
  parent?: string;
349
396
  error?: string;
350
397
  reason?: RunFailureReason;
398
+ pin?: LoggedInstructionPin;
399
+ changed?: boolean;
351
400
  cantTry?: CantTryStep;
352
401
  } | {
353
402
  type: "artifact.created";
@@ -441,13 +490,24 @@ export type RunEventBody = {
441
490
  }
442
491
  /**
443
492
  * `reason`: why the run failed (requirement `events.run-failed-reason`); absent in older logs.
444
- * `host`: with `model-unreachable` only, the host and port that didn't answer, such as
493
+ * `host`: with `model-unreachable` and `model-timeout` only, the host and port that didn't answer, such as
445
494
  * `localhost:11434` (requirement `events.run-failed-model-unreachable`).
446
- * `sandboxReason`: with `sandbox-not-ready` only, why the sandbox can't start, as the `Sandbox`
447
- * port's reason code, such as `bubblewrap-missing` (requirement `events.run-failed-sandbox-not-ready`).
495
+ * `sandboxReason`: with `sandbox-not-ready`, and with `sandbox-start-failed` when the sandbox
496
+ * check no longer passed once the sandbox failed to open, why the sandbox can't start, as the
497
+ * `Sandbox` port's reason code, such as `bubblewrap-missing` (requirements
498
+ * `events.run-failed-sandbox-not-ready` and `events.run-failed-sandbox-start-failed`).
448
499
  * A reader that doesn't know the code reads it as `other`.
500
+ * `harnessCause`: with `harness-start-failed` only, why the program didn't start when the engine
501
+ * knows, `not-installed` or `signed-out` (requirement `events.run-failed-harness-cause`).
502
+ * `agent`: with `sandbox-not-ready`, the agent that didn't start (requirement `events.run-failed-sandbox-not-ready`).
503
+ * `agent`, `pin` and `changed`: with `instructions-not-trusted`, the agent that didn't start,
504
+ * the digests of the instructions the check saw (never their text) and whether a person had
505
+ * trusted instructions for it before (requirement `events.run-failed-instructions-not-trusted`);
506
+ * absent in older logs. A reader that doesn't know the reason still shows `error`.
449
507
  * `providerText`: the model provider's own error text, for `--debug` and Copy details only
450
508
  * (requirement `events.provider-text`); absent in older logs and when it gave none.
509
+ * `cause`: the typed cause, from the error the failing call threw, when that error has a
510
+ * kind (requirement `events.run-failed-cause`); absent in older logs. A screen reads it, never `error`.
451
511
  */
452
512
  | {
453
513
  type: "run.failed";
@@ -456,7 +516,12 @@ export type RunEventBody = {
456
516
  reason?: RunFailureReason;
457
517
  host?: string;
458
518
  sandboxReason?: string;
519
+ harnessCause?: HarnessStartCause;
520
+ agent?: string;
521
+ pin?: LoggedInstructionPin;
522
+ changed?: boolean;
459
523
  providerText?: ProviderText;
524
+ cause?: RunFailureCause;
460
525
  }
461
526
  /**
462
527
  * A Try it or Test run ended at a step it couldn't try, and nothing in it
@@ -1,4 +1,4 @@
1
- import type { CantTryStep, RunFailureReason, RunKind, RunStatus, RunTrigger, Usage } from "./run-basics.js";
1
+ import type { CantTryStep, RunFailureCause, RunFailureReason, RunKind, RunStatus, RunTrigger, Usage } from "./run-basics.js";
2
2
  /** A tool call a run is waiting on a person's OK for, from its `approval.requested` event. */
3
3
  export interface PendingApproval {
4
4
  /** The state's agent: the one that asked, or the one whose subagent asked. */
@@ -8,7 +8,10 @@ export interface PendingApproval {
8
8
  * `events.agent-resume-inner`); absent when `agent` asked itself.
9
9
  */
10
10
  subagent?: string;
11
+ /** The bare tool name, as the model was offered it. */
11
12
  tool: string;
13
+ /** The connector the tool comes from (requirement `events.approval-requested-connector`); absent for a built-in tool and in older logs. */
14
+ connector?: string;
12
15
  args: unknown;
13
16
  callId: string;
14
17
  /** ISO time the approval was asked for. */
@@ -56,6 +59,13 @@ export interface RunSummary {
56
59
  * failed, and for older logs whose `run.failed` gives no reason.
57
60
  */
58
61
  reason: RunFailureReason | null;
62
+ /**
63
+ * The typed cause of the failure, from its `run.failed` event (requirement
64
+ * `events.run-failed-cause`). Absent while the run hasn't failed, for older
65
+ * logs and when the failing error had no kind. Read it, not `error`, to
66
+ * tell one failure from another on a screen.
67
+ */
68
+ cause?: RunFailureCause;
59
69
  definitionsVersion: string;
60
70
  trigger: RunTrigger | null;
61
71
  /** The run that started this one (subflows). */
@@ -2,7 +2,8 @@ import { type SandboxOpenedView } from "./sandbox-opened.js";
2
2
  /**
3
3
  * Reads the `sandbox` of a stored `sandbox.opened` event (requirement
4
4
  * `events.sandbox-opened`). It never throws: a value that is damaged, from
5
- * another version or missing a field gives `null`, so a screen says it
5
+ * another version or missing a field gives `null`, and so does a damaged
6
+ * sign-in, though an event without one reads fine, so a screen says it
6
7
  * couldn't read what the step could do instead of showing part of it. It
7
8
  * copies only the view's fields, so an extra field in a damaged log never
8
9
  * reaches a screen either.
@@ -1,5 +1,9 @@
1
1
  import { deniedPathGroupCodes, } from "./sandbox-opened.js";
2
2
  const strengths = ["os", "vm", "remote"];
3
+ const subscriptionProviders = [
4
+ "anthropic",
5
+ "openai",
6
+ ];
3
7
  const groupCodes = deniedPathGroupCodes;
4
8
  /** A list of strings, or `null` when the value is anything else. */
5
9
  function stringsOf(value) {
@@ -18,10 +22,29 @@ function groupCodesOf(value) {
18
22
  return null;
19
23
  return codes;
20
24
  }
25
+ /**
26
+ * A stored sign-in with only its kind and provider; `undefined` when there is
27
+ * none, and `null` when it is damaged.
28
+ */
29
+ function signInOf(value) {
30
+ if (value === undefined)
31
+ return undefined;
32
+ if (typeof value !== "object" || value === null)
33
+ return null;
34
+ const { kind, provider } = value;
35
+ if (kind === "key" && typeof provider === "string" && provider !== "") {
36
+ return { kind, provider };
37
+ }
38
+ if (kind === "subscription" && subscriptionProviders.includes(provider)) {
39
+ return { kind, provider: provider };
40
+ }
41
+ return null;
42
+ }
21
43
  /**
22
44
  * Reads the `sandbox` of a stored `sandbox.opened` event (requirement
23
45
  * `events.sandbox-opened`). It never throws: a value that is damaged, from
24
- * another version or missing a field gives `null`, so a screen says it
46
+ * another version or missing a field gives `null`, and so does a damaged
47
+ * sign-in, though an event without one reads fine, so a screen says it
25
48
  * couldn't read what the step could do instead of showing part of it. It
26
49
  * copies only the view's fields, so an extra field in a damaged log never
27
50
  * reaches a screen either.
@@ -42,6 +65,7 @@ export function readSandboxOpened(value) {
42
65
  const deniedGroups = groupCodesOf(fields.deniedGroups);
43
66
  const deniedPaths = stringsOf(fields.deniedPaths);
44
67
  const allowedSites = stringsOf(fields.allowedSites);
68
+ const signIn = signInOf(fields.signIn);
45
69
  if (!strengths.includes(strength) || typeof workingFolder !== "string")
46
70
  return null;
47
71
  if (typeof timeLimitMs !== "number" || !Number.isFinite(timeLimitMs) || timeLimitMs < 0) {
@@ -49,7 +73,7 @@ export function readSandboxOpened(value) {
49
73
  }
50
74
  if (readOnlyPaths === null || deniedGroups === null)
51
75
  return null;
52
- if (deniedPaths === null || allowedSites === null)
76
+ if (deniedPaths === null || allowedSites === null || signIn === null)
53
77
  return null;
54
78
  return {
55
79
  strength: strength,
@@ -59,5 +83,6 @@ export function readSandboxOpened(value) {
59
83
  deniedPaths,
60
84
  allowedSites,
61
85
  timeLimitMs,
86
+ ...(signIn === undefined ? {} : { signIn }),
62
87
  };
63
88
  }
@@ -6,12 +6,37 @@
6
6
  export type SandboxStrength = "os" | "vm" | "remote";
7
7
  /**
8
8
  * The codes of the groups of paths a sandbox denies: the person's SSH keys,
9
- * their cloud sign-ins, browser data, password stores, Halonic's own data and
10
- * other agents' settings (such as `~/.claude`). One list, so the profile
9
+ * their cloud sign-ins, browser data, password stores, package registry tokens,
10
+ * shell histories, Halonic's own data and other agents' settings (such as `~/.claude`). One list, so the profile
11
11
  * builder, the run log and the screens name the same groups. Screens word
12
12
  * each code through the message catalogue.
13
13
  */
14
- export declare const deniedPathGroupCodes: readonly ["ssh-keys", "cloud-sign-ins", "browser-data", "password-stores", "halonic-data", "agent-settings"];
14
+ export declare const deniedPathGroupCodes: readonly ["ssh-keys", "cloud-sign-ins", "browser-data", "password-stores", "registry-tokens", "shell-history", "halonic-data", "agent-settings"];
15
+ /** The model providers a person can sign in to with their own subscription: Claude, and ChatGPT. */
16
+ export type SubscriptionProvider = "anthropic" | "openai";
17
+ /**
18
+ * How a sandboxed step's agent signs in to its model, for the run page's
19
+ * Your sign-in row. It names the kind and the provider only: never a key,
20
+ * the name of the secret that holds it, an address or a path.
21
+ */
22
+ export type SandboxSignIn =
23
+ /**
24
+ * With a key Halonic keeps: the agent never sees it, and Halonic adds it to
25
+ * requests on their way to `provider`, the id of the provider the key is
26
+ * for, such as `anthropic` or `zai`.
27
+ */
28
+ {
29
+ kind: "key";
30
+ provider: string;
31
+ }
32
+ /**
33
+ * With the person's own subscription, saved in the agent's own settings
34
+ * folder, which the agent can read while it runs.
35
+ */
36
+ | {
37
+ kind: "subscription";
38
+ provider: SubscriptionProvider;
39
+ };
15
40
  /** A group of denied paths: one of {@link deniedPathGroupCodes}. */
16
41
  export type DeniedPathGroupCode = (typeof deniedPathGroupCodes)[number];
17
42
  /**
@@ -39,6 +64,11 @@ export interface SandboxOpenedView {
39
64
  allowedSites: string[];
40
65
  /** How long the step may last, in milliseconds. */
41
66
  timeLimitMs: number;
67
+ /**
68
+ * How the agent signs in to its model. Absent when the host didn't say,
69
+ * and in events logged before it was recorded.
70
+ */
71
+ signIn?: SandboxSignIn;
42
72
  }
43
73
  /**
44
74
  * The parts of a sandbox profile that {@link sandboxOpenedView} reads. The
@@ -69,12 +99,15 @@ export interface SandboxOpenedOptions {
69
99
  home: string | null;
70
100
  /** The groups the profile's denied paths were built from. */
71
101
  deniedGroups: readonly DeniedPathGroup[];
102
+ /** How the agent signs in to its model, when the host knows. */
103
+ signIn?: SandboxSignIn;
72
104
  }
73
105
  /**
74
106
  * Makes the display copy of a sandbox profile that a `sandbox.opened` event
75
107
  * carries (requirement `events.sandbox-opened`). It copies a fixed list of
76
108
  * fields and nothing else, so the profile's `env`, its temp and settings
77
- * folders and any field added later never reach the run log. A group is named when it has paths and all of them
109
+ * folders and any field added later never reach the run log; of the sign-in
110
+ * it copies only the kind and the provider. A group is named when it has paths and all of them
78
111
  * are denied, so a group with no paths never claims something was blocked;
79
112
  * the denied paths outside the named groups are listed one by one. Paths in
80
113
  * the person's home folder start with `~`.
@@ -1,8 +1,8 @@
1
1
  import { shortenHome } from "./home-path.js";
2
2
  /**
3
3
  * The codes of the groups of paths a sandbox denies: the person's SSH keys,
4
- * their cloud sign-ins, browser data, password stores, Halonic's own data and
5
- * other agents' settings (such as `~/.claude`). One list, so the profile
4
+ * their cloud sign-ins, browser data, password stores, package registry tokens,
5
+ * shell histories, Halonic's own data and other agents' settings (such as `~/.claude`). One list, so the profile
6
6
  * builder, the run log and the screens name the same groups. Screens word
7
7
  * each code through the message catalogue.
8
8
  */
@@ -11,6 +11,8 @@ export const deniedPathGroupCodes = [
11
11
  "cloud-sign-ins",
12
12
  "browser-data",
13
13
  "password-stores",
14
+ "registry-tokens",
15
+ "shell-history",
14
16
  "halonic-data",
15
17
  "agent-settings",
16
18
  ];
@@ -18,7 +20,8 @@ export const deniedPathGroupCodes = [
18
20
  * Makes the display copy of a sandbox profile that a `sandbox.opened` event
19
21
  * carries (requirement `events.sandbox-opened`). It copies a fixed list of
20
22
  * fields and nothing else, so the profile's `env`, its temp and settings
21
- * folders and any field added later never reach the run log. A group is named when it has paths and all of them
23
+ * folders and any field added later never reach the run log; of the sign-in
24
+ * it copies only the kind and the provider. A group is named when it has paths and all of them
22
25
  * are denied, so a group with no paths never claims something was blocked;
23
26
  * the denied paths outside the named groups are listed one by one. Paths in
24
27
  * the person's home folder start with `~`.
@@ -48,5 +51,12 @@ export function sandboxOpenedView(profile, options) {
48
51
  deniedPaths: [...denied].filter((path) => !inNamedGroup.has(path)).map(shorten),
49
52
  allowedSites: [...profile.network.allowedSites],
50
53
  timeLimitMs: profile.timeLimitMs,
54
+ ...(options.signIn === undefined ? {} : { signIn: signInOf(options.signIn) }),
51
55
  };
52
56
  }
57
+ /** The sign-in's kind and provider, and nothing else it may carry. */
58
+ function signInOf(signIn) {
59
+ return signIn.kind === "key"
60
+ ? { kind: "key", provider: signIn.provider }
61
+ : { kind: "subscription", provider: signIn.provider };
62
+ }
@@ -126,6 +126,8 @@ function applyEvent(summary, event) {
126
126
  summary.endedAt = event.at;
127
127
  summary.error = event.error;
128
128
  summary.reason = event.reason ?? null;
129
+ if (event.cause !== undefined)
130
+ summary.cause = event.cause;
129
131
  summary.approvals = [];
130
132
  return;
131
133
  case "run.cant-try":
@@ -144,6 +146,7 @@ function pendingApproval(event) {
144
146
  agent: event.agent,
145
147
  ...(event.subagent === undefined ? {} : { subagent: event.subagent }),
146
148
  tool: event.tool,
149
+ ...(event.connector === undefined ? {} : { connector: event.connector }),
147
150
  args: event.args,
148
151
  callId: event.callId,
149
152
  at: event.at,
@@ -0,0 +1,25 @@
1
+ import type { ToolFailureCause } from "./run-basics.js";
2
+ import type { RunEventBody } from "./run-event.js";
3
+ /** A `tool.result` event, whose `cause` this reads. */
4
+ type ToolResultEvent = Extract<RunEventBody, {
5
+ type: "tool.result";
6
+ }>;
7
+ /** The longest `name` a `connector-not-started` cause carries; the engine cuts a longer one. */
8
+ export declare const maxCauseNameLength = 120;
9
+ /**
10
+ * Reads the `cause` of a stored `tool.result` event (requirement
11
+ * `events.tool-result-cause`). It never throws: a cause with a code it
12
+ * doesn't know, a field of the wrong type or a missing field reads as
13
+ * absent, so a screen falls back to its plain line instead of showing part
14
+ * of a cause. It copies only the cause's own fields, so an extra field in a
15
+ * log never reaches a screen.
16
+ *
17
+ * @param event - the `tool.result` event, as parsed from the log
18
+ * @returns the cause, or `undefined` when there is none it can read
19
+ *
20
+ * @example
21
+ * toolFailureCauseOf(result); // cause { code: "time-limit", seconds: 60 } => { code: "time-limit", seconds: 60 }
22
+ * toolFailureCauseOf(result); // cause { code: "melted" } => undefined
23
+ */
24
+ export declare function toolFailureCauseOf(event: ToolResultEvent): ToolFailureCause | undefined;
25
+ export {};
@@ -0,0 +1,66 @@
1
+ /** The longest `name` a `connector-not-started` cause carries; the engine cuts a longer one. */
2
+ export const maxCauseNameLength = 120;
3
+ const notMadeReasons = [
4
+ "not-connected",
5
+ "tool-gone",
6
+ "sending-off",
7
+ "bad-arguments",
8
+ ];
9
+ const startReasons = [
10
+ "program-missing",
11
+ "secret-not-set",
12
+ "other",
13
+ ];
14
+ /**
15
+ * Reads the `cause` of a stored `tool.result` event (requirement
16
+ * `events.tool-result-cause`). It never throws: a cause with a code it
17
+ * doesn't know, a field of the wrong type or a missing field reads as
18
+ * absent, so a screen falls back to its plain line instead of showing part
19
+ * of a cause. It copies only the cause's own fields, so an extra field in a
20
+ * log never reaches a screen.
21
+ *
22
+ * @param event - the `tool.result` event, as parsed from the log
23
+ * @returns the cause, or `undefined` when there is none it can read
24
+ *
25
+ * @example
26
+ * toolFailureCauseOf(result); // cause { code: "time-limit", seconds: 60 } => { code: "time-limit", seconds: 60 }
27
+ * toolFailureCauseOf(result); // cause { code: "melted" } => undefined
28
+ */
29
+ export function toolFailureCauseOf(event) {
30
+ // Typed, but parsed from a file: it may hold anything.
31
+ const cause = event.cause;
32
+ if (typeof cause !== "object" || cause === null)
33
+ return undefined;
34
+ const fields = cause;
35
+ switch (fields.code) {
36
+ case "time-limit":
37
+ return isSeconds(fields.seconds)
38
+ ? { code: "time-limit", seconds: fields.seconds }
39
+ : undefined;
40
+ case "engine-stopped":
41
+ return { code: "engine-stopped" };
42
+ case "not-made":
43
+ return notMadeReasons.includes(fields.why)
44
+ ? { code: "not-made", why: fields.why }
45
+ : undefined;
46
+ case "connector-not-started":
47
+ return connectorNotStarted(fields);
48
+ default:
49
+ return undefined;
50
+ }
51
+ }
52
+ /** A time limit in seconds: a finite number above zero. */
53
+ function isSeconds(value) {
54
+ return typeof value === "number" && Number.isFinite(value) && value > 0;
55
+ }
56
+ function connectorNotStarted(fields) {
57
+ if (!startReasons.includes(fields.why))
58
+ return undefined;
59
+ const why = fields.why;
60
+ const { name } = fields;
61
+ if (name === undefined)
62
+ return { code: "connector-not-started", why };
63
+ if (typeof name !== "string" || name === "" || name.length > maxCauseNameLength)
64
+ return undefined;
65
+ return { code: "connector-not-started", why, name };
66
+ }
@@ -7,7 +7,7 @@ export { type ConnectorStart, type FolderLookup, touchesWorkingFolder, type Work
7
7
  export type { Collection, CollectionField, CollectionView } from "./kinds/collection/schema.js";
8
8
  export { FIELD_TYPES } from "./kinds/collection/schema.js";
9
9
  export { connectorIsLocal } from "./kinds/connector/is-local.js";
10
- export { approveAll, type Connector, marksRead, needsApproval } from "./kinds/connector/schema.js";
10
+ export { approveAll, asksBeforeEachUse, type Connector, marksRead, needsApproval, } from "./kinds/connector/schema.js";
11
11
  export type { CloudflareSettings, Deployment, DeploymentLimits, Deployments, } from "./kinds/deployments/schema.js";
12
12
  export type { Hub, HubUses } from "./kinds/hub/schema.js";
13
13
  export { approvedSignIns, type ResolvedSignIn, } from "./kinds/integration/approved-sign-ins.js";
@@ -22,6 +22,7 @@ export { checkPlugin } from "./kinds/plugin/checks.js";
22
22
  export { ARGUMENT_NAME_PATTERN, DEFAULT_BACKEND_ENTRY, ENV_NAME_PATTERN, MAX_PLUGIN_ID_LENGTH, MAX_PLUGIN_SECRET_NAME_LENGTH, NPM_EXACT_VERSION_PATTERN, networkSiteProblem, Plugin, type PluginBackend, type PluginLocalTool, type PluginUi, PYPI_EXACT_VERSION_PATTERN, pluginPathProblem, } from "./kinds/plugin/schema.js";
23
23
  export { type PluginSettingField, type PluginSettingValue, settingValueProblem, } from "./kinds/plugin/setting-values.js";
24
24
  export type { Provider } from "./kinds/provider/schema.js";
25
+ export { isProviderType, openAiCompatibleTypes, type ProviderType, providerTypes, providerTypesInWords, } from "./kinds/provider/types.js";
25
26
  export type { Routine, RoutineTarget, RoutineTrigger } from "./kinds/routine/schema.js";
26
27
  export { WEBHOOK_REFUSED_HEADERS } from "./kinds/routine/webhook-headers.js";
27
28
  export type { Runtime } from "./kinds/runtime/schema.js";
@@ -34,6 +35,6 @@ export { type FileProblem, type ParsedFile, type ParseFileOptions, parseFile, }
34
35
  export { fileKinds, isKindName, type KindName, type KindValues, kindNames } from "./registry.js";
35
36
  export { isReservedPath, RESERVED_FOLDER } from "./reserved.js";
36
37
  export { SCHEMA_VERSION } from "./shared/fields.js";
37
- export type { Guard } from "./shared/guard.js";
38
+ export { type Guard, isGuard } from "./shared/guard.js";
38
39
  export { type NamedPath, type ProgramStart, pathsNamedBy } from "./shared/program-start.js";
39
40
  export { foldName } from "./shared/relative-path.js";
@@ -5,7 +5,7 @@ export { AGENT_HARNESSES, asciiAllowedSites, defaultWorkingFolder, isInWorkingFo
5
5
  export { touchesWorkingFolder, workingFolderRefusal, } from "./kinds/agent/working-folder-start.js";
6
6
  export { FIELD_TYPES } from "./kinds/collection/schema.js";
7
7
  export { connectorIsLocal } from "./kinds/connector/is-local.js";
8
- export { approveAll, marksRead, needsApproval } from "./kinds/connector/schema.js";
8
+ export { approveAll, asksBeforeEachUse, marksRead, needsApproval, } from "./kinds/connector/schema.js";
9
9
  export { approvedSignIns, } from "./kinds/integration/approved-sign-ins.js";
10
10
  export { checkIntegrationSheet } from "./kinds/integration/kind.js";
11
11
  export { parseIntegrationSheet } from "./kinds/integration/parse-sheet.js";
@@ -15,11 +15,13 @@ export { backendSheet, pluginFromIntegrationSheet } from "./kinds/plugin/backend
15
15
  export { checkPlugin } from "./kinds/plugin/checks.js";
16
16
  export { ARGUMENT_NAME_PATTERN, DEFAULT_BACKEND_ENTRY, ENV_NAME_PATTERN, MAX_PLUGIN_ID_LENGTH, MAX_PLUGIN_SECRET_NAME_LENGTH, NPM_EXACT_VERSION_PATTERN, networkSiteProblem, Plugin, PYPI_EXACT_VERSION_PATTERN, pluginPathProblem, } from "./kinds/plugin/schema.js";
17
17
  export { settingValueProblem, } from "./kinds/plugin/setting-values.js";
18
+ export { isProviderType, openAiCompatibleTypes, providerTypes, providerTypesInWords, } from "./kinds/provider/types.js";
18
19
  export { WEBHOOK_REFUSED_HEADERS } from "./kinds/routine/webhook-headers.js";
19
20
  export { skillScriptsRefusal, touchesSkillScripts, } from "./kinds/skill/scripts-folder.js";
20
21
  export { parseFile, } from "./parse-file.js";
21
22
  export { fileKinds, isKindName, kindNames } from "./registry.js";
22
23
  export { isReservedPath, RESERVED_FOLDER } from "./reserved.js";
23
24
  export { SCHEMA_VERSION } from "./shared/fields.js";
25
+ export { isGuard } from "./shared/guard.js";
24
26
  export { pathsNamedBy } from "./shared/program-start.js";
25
27
  export { foldName } from "./shared/relative-path.js";
@@ -0,0 +1,14 @@
1
+ /** The most model calls `harnessLimits.maxSteps` may allow. */
2
+ export declare const MAX_HARNESS_STEPS = 10000;
3
+ /** The most minutes `harnessLimits.maxMinutes` may allow: one day. */
4
+ export declare const MAX_HARNESS_MINUTES = 1440;
5
+ /**
6
+ * `harnessLimits`: what one step of the agent may use when it runs in a
7
+ * harness program (`claude-code`, `codex`). Each field is optional; a limit
8
+ * left out doesn't apply. Halonic's own loop ignores the block.
9
+ */
10
+ export declare const HarnessLimits: import("zod").ZodObject<{
11
+ maxSteps: import("zod").ZodOptional<import("zod").ZodNumber>;
12
+ maxMinutes: import("zod").ZodOptional<import("zod").ZodNumber>;
13
+ maxCost: import("zod").ZodOptional<import("zod").ZodNumber>;
14
+ }, import("zod/v4/core").$strict>;
@@ -0,0 +1,27 @@
1
+ // The limits on one step of a harness agent (requirement
2
+ // format.agent-harness-limits). A program such as Claude Code makes hundreds
3
+ // of model calls in a step, so the agent's `maxSteps`, sized for Halonic's
4
+ // own loop, can't bound it; these fields do, and only for a harness step.
5
+ import { s } from "../../../../schema-kit/src/index.js";
6
+ /** The most model calls `harnessLimits.maxSteps` may allow. */
7
+ export const MAX_HARNESS_STEPS = 10_000;
8
+ /** The most minutes `harnessLimits.maxMinutes` may allow: one day. */
9
+ export const MAX_HARNESS_MINUTES = 1440;
10
+ /**
11
+ * `harnessLimits`: what one step of the agent may use when it runs in a
12
+ * harness program (`claude-code`, `codex`). Each field is optional; a limit
13
+ * left out doesn't apply. Halonic's own loop ignores the block.
14
+ */
15
+ export const HarnessLimits = s
16
+ .object({
17
+ /** Most model calls the program makes in one step. */
18
+ maxSteps: s.number().int().min(1).max(MAX_HARNESS_STEPS).optional(),
19
+ /** Most minutes one step runs, not counting the time it waits for a person's answer. */
20
+ maxMinutes: s.number().int().min(1).max(MAX_HARNESS_MINUTES).optional(),
21
+ /**
22
+ * Most one step may spend, in the workspace budget's currency. Calls a
23
+ * subscription pays for count as 0, so only time and steps bound those.
24
+ */
25
+ maxCost: s.number().positive().optional(),
26
+ })
27
+ .strict();
@@ -136,6 +136,11 @@ export declare const Agent: import("zod").ZodObject<{
136
136
  }>>;
137
137
  workingFolder: import("zod").ZodOptional<import("zod").ZodString>;
138
138
  allowedSites: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
139
+ harnessLimits: import("zod").ZodOptional<import("zod").ZodObject<{
140
+ maxSteps: import("zod").ZodOptional<import("zod").ZodNumber>;
141
+ maxMinutes: import("zod").ZodOptional<import("zod").ZodNumber>;
142
+ maxCost: import("zod").ZodOptional<import("zod").ZodNumber>;
143
+ }, import("zod/v4/core").$strict>>;
139
144
  }, import("zod/v4/core").$strict>;
140
145
  /** An agent, with defaults filled in. */
141
146
  export type Agent = Infer<typeof Agent>;
@@ -1,5 +1,6 @@
1
1
  import { s } from "../../../../schema-kit/src/index.js";
2
2
  import { agentId, collectionId, id, ModelParams, version } from "../../shared/fields.js";
3
+ import { HarnessLimits } from "./harness-limits.js";
3
4
  import { AgentHarness, AllowedSite, MAX_ALLOWED_SITES, WorkingFolder } from "./sandbox-fields.js";
4
5
  /** The shape of an agent's reply: free text, one of a list of options, or JSON. */
5
6
  export const AgentOutput = s.discriminatedUnion("type", [
@@ -103,5 +104,7 @@ export const Agent = s
103
104
  workingFolder: WorkingFolder.optional(),
104
105
  /** Sites a harness agent may reach besides Halonic: host names or `*.` and a domain. */
105
106
  allowedSites: s.array(AllowedSite).max(MAX_ALLOWED_SITES).optional(),
107
+ /** The step, time and cost limits of one step in a harness program. */
108
+ harnessLimits: HarnessLimits.optional(),
106
109
  })
107
110
  .strict();