@inflexa-ai/harness 0.48.0 → 0.48.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 (115) hide show
  1. package/dist/contracts/chat-events.d.ts +40 -0
  2. package/dist/contracts/chat-frame.js +11 -0
  3. package/dist/contracts/index.d.ts +1 -1
  4. package/dist/contracts/message.d.ts +7 -1
  5. package/dist/contracts/schemas/chat-events.d.ts +319 -0
  6. package/dist/contracts/schemas/chat-events.js +29 -0
  7. package/dist/execution/run-synthesis.js +1 -0
  8. package/dist/index.d.ts +5 -3
  9. package/dist/index.js +2 -1
  10. package/dist/input-sanitization.d.ts +30 -2
  11. package/dist/input-sanitization.js +187 -2
  12. package/dist/loop/run-loop.js +50 -5
  13. package/dist/loop/tool-adapter.d.ts +8 -0
  14. package/dist/loop/tool-adapter.js +75 -4
  15. package/dist/loop/tool-detail.d.ts +5 -1
  16. package/dist/loop/tool-detail.js +7 -3
  17. package/dist/loop/tool-value.d.ts +57 -0
  18. package/dist/loop/tool-value.js +249 -0
  19. package/dist/loop/types.d.ts +9 -2
  20. package/dist/memory/conversation-display-storage.js +4 -1
  21. package/dist/memory/count-tokens.js +29 -2
  22. package/dist/runtime/dbos.d.ts +6 -0
  23. package/dist/runtime/dbos.js +14 -2
  24. package/dist/sandbox/sandbox-step-translate.d.ts +5 -9
  25. package/dist/sandbox/sandbox-step-translate.js +5 -9
  26. package/dist/state/artifacts.d.ts +4 -1
  27. package/dist/state/artifacts.js +4 -1
  28. package/dist/state/index.d.ts +2 -2
  29. package/dist/state/index.js +1 -1
  30. package/dist/state/plans.d.ts +27 -0
  31. package/dist/state/plans.js +57 -3
  32. package/dist/tasks/data-profile-activity.d.ts +3 -7
  33. package/dist/tasks/data-profile-activity.js +1 -1
  34. package/dist/tasks/data-profile.js +3 -6
  35. package/dist/tools/ad-hoc-router.js +1 -0
  36. package/dist/tools/bio/alphafold-prediction.js +1 -0
  37. package/dist/tools/bio/chembl.js +1 -0
  38. package/dist/tools/bio/comptox.js +1 -0
  39. package/dist/tools/bio/drug-gene-interactions.js +1 -0
  40. package/dist/tools/bio/gene-disease-evidence.js +1 -0
  41. package/dist/tools/bio/gene-preclinical-profile.js +1 -0
  42. package/dist/tools/bio/lookup-annotation.js +1 -0
  43. package/dist/tools/bio/opentargets.js +1 -0
  44. package/dist/tools/bio/pubchem.js +1 -0
  45. package/dist/tools/bio/pubmed.js +1 -0
  46. package/dist/tools/bio/search-clinical-trials.js +1 -0
  47. package/dist/tools/bio/search-faers.js +1 -0
  48. package/dist/tools/bio/search-gene.js +1 -0
  49. package/dist/tools/bio/search-geo-datasets.js +1 -0
  50. package/dist/tools/bio/search-interactions.js +1 -0
  51. package/dist/tools/bio/search-patents.js +1 -0
  52. package/dist/tools/bio/search-protein.js +1 -0
  53. package/dist/tools/bio/search-regulatory-approvals.js +1 -0
  54. package/dist/tools/bio/target-safety.js +1 -0
  55. package/dist/tools/capability-data.js +5 -0
  56. package/dist/tools/define-tool.d.ts +18 -0
  57. package/dist/tools/define-tool.js +2 -0
  58. package/dist/tools/display/show-user.js +1 -0
  59. package/dist/tools/execute-analysis.js +4 -0
  60. package/dist/tools/knowledge/check.d.ts +47 -1
  61. package/dist/tools/knowledge/check.js +10 -1
  62. package/dist/tools/knowledge/client.d.ts +1 -1
  63. package/dist/tools/knowledge/recommend.js +4 -3
  64. package/dist/tools/knowledge/situation.d.ts +39 -1
  65. package/dist/tools/knowledge/situation.js +80 -8
  66. package/dist/tools/knowledge/skeleton.d.ts +7 -0
  67. package/dist/tools/knowledge/skeleton.js +88 -2
  68. package/dist/tools/knowledge/template.js +1 -0
  69. package/dist/tools/memory/update-working-memory.js +5 -0
  70. package/dist/tools/read-tool-output.js +4 -0
  71. package/dist/tools/report-authoring/authoring-tools.js +8 -0
  72. package/dist/tools/report-session/examine-page.js +5 -0
  73. package/dist/tools/report-session/list-artifacts.js +5 -0
  74. package/dist/tools/report-session/preview-report.js +1 -0
  75. package/dist/tools/report-session/record-version.js +1 -0
  76. package/dist/tools/report-session/script-tools.js +2 -0
  77. package/dist/tools/research/context7-docs.js +2 -0
  78. package/dist/tools/research/generate-analogy-report.js +3 -0
  79. package/dist/tools/research/generate-plan.js +6 -0
  80. package/dist/tools/research/inspect-data-profile.js +5 -0
  81. package/dist/tools/research/inspect-run.js +5 -0
  82. package/dist/tools/research/resolve-citation.js +1 -0
  83. package/dist/tools/research/search-arxiv.js +1 -0
  84. package/dist/tools/research/search-github-repos.js +1 -0
  85. package/dist/tools/research/search-semantic-scholar.js +1 -0
  86. package/dist/tools/research/web-fetch.js +1 -0
  87. package/dist/tools/research/web-search.js +1 -0
  88. package/dist/tools/sandbox/lease-tools.js +2 -0
  89. package/dist/tools/sandbox/link-packages.js +1 -0
  90. package/dist/tools/sandbox/list-available-packages.js +5 -0
  91. package/dist/tools/sandbox/list-available-refs.js +5 -0
  92. package/dist/tools/sandbox/report-blocker.js +1 -0
  93. package/dist/tools/sandbox/skills.js +2 -0
  94. package/dist/tools/sandbox/submit-file-metadata.js +1 -0
  95. package/dist/tools/script/file-tools.js +6 -0
  96. package/dist/tools/script/run-script.js +20 -1
  97. package/dist/tools/start-report-session.js +1 -0
  98. package/dist/tools/tool-view.d.ts +63 -0
  99. package/dist/tools/tool-view.js +68 -0
  100. package/dist/tools/workspace/edit-file.js +5 -0
  101. package/dist/tools/workspace/execute-command.js +5 -2
  102. package/dist/tools/workspace/file-stat.js +5 -0
  103. package/dist/tools/workspace/grep.js +4 -0
  104. package/dist/tools/workspace/list-files.js +5 -0
  105. package/dist/tools/workspace/read-file.js +4 -0
  106. package/dist/tools/workspace/scan-inputs.js +5 -0
  107. package/dist/tools/workspace/show-file.js +1 -0
  108. package/dist/tools/workspace/show-plan.js +1 -0
  109. package/dist/tools/workspace/workspace-search.js +5 -0
  110. package/dist/tools/workspace/write-file.js +7 -2
  111. package/dist/workflows/execute-analysis.js +2 -1
  112. package/dist/workflows/sandbox-step.js +3 -7
  113. package/package.json +1 -1
  114. package/dist/tools/detail-resolver.d.ts +0 -40
  115. package/dist/tools/detail-resolver.js +0 -44
@@ -67,6 +67,38 @@ export type ToolCallOutcome = ToolOutcome | "incomplete";
67
67
  * when the detail could not be produced.
68
68
  */
69
69
  export type ToolCallDetail = string;
70
+ /**
71
+ * One shown text of a tool call value. The harness removes the control characters and each listed secret form from
72
+ * the text, and it cuts a text over its cap. `cut` is true when the cap cut the text.
73
+ *
74
+ * - `text`: plain text.
75
+ * - `json`: the JSON text of a value. A host can parse it only when `cut` is false, because a cut text is not valid JSON.
76
+ * - `code`: source code in `language`.
77
+ */
78
+ export type ToolCallLeaf = {
79
+ kind: "text";
80
+ text: string;
81
+ cut: boolean;
82
+ } | {
83
+ kind: "json";
84
+ text: string;
85
+ cut: boolean;
86
+ } | {
87
+ kind: "code";
88
+ language: string;
89
+ text: string;
90
+ cut: boolean;
91
+ };
92
+ /**
93
+ * The shown value of a tool call: its input, its result, or its error. A host selects a renderer from `kind`.
94
+ * `fields` holds an ordered list of at most 4 named leaves, and a leaf never holds a `fields` value.
95
+ */
96
+ export type ToolCallValue = ToolCallLeaf | {
97
+ kind: "fields";
98
+ fields: Array<{
99
+ name: string;
100
+ } & ToolCallLeaf>;
101
+ };
70
102
  /**
71
103
  * A sub-agent loop started a request to its model. Only a sub-agent gives this frame, thus a consumer that
72
104
  * keeps the root frames only (`isRootFrame`) never sees it. A host reads it as "the sub-agent thinks".
@@ -84,6 +116,8 @@ export type ToolStartedEvent = {
84
116
  name: string;
85
117
  /** See {@link ToolCallDetail}. Absent — never empty — when none was produced. */
86
118
  detail?: ToolCallDetail;
119
+ /** See {@link ToolCallValue}. The input of the call. */
120
+ input?: ToolCallValue;
87
121
  source: EventSource;
88
122
  };
89
123
  /** A tool call has resolved. */
@@ -109,6 +143,12 @@ export type ToolFinishedEvent = {
109
143
  * it dispatches anything. Thus the fallback is correct only for one call.
110
144
  */
111
145
  durationMs?: number;
146
+ /** See {@link ToolCallValue}. The input again, because a replay of a tool step does not give its `tool-started`. */
147
+ input?: ToolCallValue;
148
+ /** The value of a call with the outcome `ok`. */
149
+ result?: ToolCallValue;
150
+ /** The error text of a call with the outcome `error`. */
151
+ error?: ToolCallValue;
112
152
  source: EventSource;
113
153
  };
114
154
  /**
@@ -50,6 +50,7 @@ export function toChatFrame(event, fallbackSource) {
50
50
  toolUseId: event.toolUseId,
51
51
  name: event.name,
52
52
  detail: event.detail,
53
+ input: event.input,
53
54
  source: toSource(event.source),
54
55
  };
55
56
  case "tool-finished":
@@ -60,6 +61,9 @@ export function toChatFrame(event, fallbackSource) {
60
61
  outcome: event.outcome,
61
62
  detail: event.detail,
62
63
  durationMs: event.durationMs,
64
+ input: event.input,
65
+ result: event.result,
66
+ error: event.error,
63
67
  source: toSource(event.source),
64
68
  };
65
69
  case "text-delta":
@@ -161,6 +165,7 @@ function applyPartFrame(parts, frame) {
161
165
  toolCallId: frame.toolUseId,
162
166
  toolName: frame.name,
163
167
  detail: frame.detail,
168
+ input: frame.input,
164
169
  },
165
170
  ];
166
171
  case "tool-finished": {
@@ -174,6 +179,12 @@ function applyPartFrame(parts, frame) {
174
179
  finished.detail = frame.detail;
175
180
  if (frame.durationMs !== undefined)
176
181
  finished.durationMs = frame.durationMs;
182
+ if (frame.input !== undefined)
183
+ finished.input = frame.input;
184
+ if (frame.result !== undefined)
185
+ finished.result = frame.result;
186
+ if (frame.error !== undefined)
187
+ finished.error = frame.error;
177
188
  const started = parts.some((p) => p.type === "tool-call" && p.toolCallId === frame.toolUseId);
178
189
  if (!started) {
179
190
  // The stored transcript keeps a call whose start never arrived, thus a live view keeps it too.
@@ -3,7 +3,7 @@ export type { OrganSystem } from "./organ-system.js";
3
3
  export { SEVERITIES, SeveritySchema } from "./severity.js";
4
4
  export type { Severity } from "./severity.js";
5
5
  export type { PlanStep, PresentationContent, PresentationPart, PlanPart, RunCardPart, PlanApprovalPart, FileReferenceEntry, FileReferencePart, AskPart, RunStartedPart, StepStatus, DagStepState, PlanGraphStep, DagStatePart, StepPhase, StepActivityPart, ActivityEntryPart, SubAgentActivityEntry, SubAgentActivityPart, FileTreeEntry, StepFileTreePart, StepOutputFile, StepOutputPart, StepSummaryPart, StepUsagePart, StepBlockedPart, FindingReference, SynthesizedFinding, BiologicalTheme, RunSynthesisPart, SynthesisPhase, SynthesisProgressPart, RunCompletedFinding, RunCompletedPart, RunFailedPart, ChildSessionStartedPart, ReportRenderedPart, CompactionPart, PauseCause, WorkKind, PausePart, ModelRetryPart, ChatPart, KnownChatPart, } from "./chat-parts.js";
6
- export type { EventSource, TextDeltaEvent, IterationEvent, ToolStartedEvent, ToolFinishedEvent, FinishEvent, ChatErrorEvent, MessageStartEvent, ChatEvent, ChatFrame, ChatPartFrame, } from "./chat-events.js";
6
+ export type { EventSource, TextDeltaEvent, IterationEvent, ToolStartedEvent, ToolFinishedEvent, ToolCallLeaf, ToolCallValue, FinishEvent, ChatErrorEvent, MessageStartEvent, ChatEvent, ChatFrame, ChatPartFrame, } from "./chat-events.js";
7
7
  export type { TokenUsageRollup } from "./usage.js";
8
8
  export { DATA_PROFILE_RUN_LITERAL } from "./data-profile.js";
9
9
  export type { DataProfileAxis, DataProfileChecked, DataProfileCompanionCompleteness, DataProfileCoverage, DataProfileDimension, DataProfileFile, DataProfileGroup, DataProfileGroupSlot, DataProfileInputSignature, DataProfileKind, DataProfileLifecycleStatus, DataProfileMemberAnnotation, DataProfileObservation, DataProfileOrganism, DataProfilePartition, DataProfileProbeReport, DataProfileQualityAssessment, DataProfileQuarantine, DataProfileRecipeStep, DataProfileResult, DataProfileSubjectSource, } from "./data-profile.js";
@@ -6,7 +6,7 @@
6
6
  * discriminant is `type`, so `switch (part.type) { case "data-child-session-started": ... }`
7
7
  * narrows the union member without any `as` cast.
8
8
  */
9
- import type { ToolCallDetail, ToolCallOutcome } from "./chat-events.js";
9
+ import type { ToolCallDetail, ToolCallOutcome, ToolCallValue } from "./chat-events.js";
10
10
  import type { ChatPart } from "./chat-parts.js";
11
11
  import type { TokenUsageRollup } from "./usage.js";
12
12
  /** A plain assistant/user text run. */
@@ -40,6 +40,12 @@ export type ToolCallPart = {
40
40
  detail?: ToolCallDetail;
41
41
  /** The time in milliseconds around the dispatch of the call, from `tool-finished`. Absent when no measurement was taken. */
42
42
  durationMs?: number;
43
+ /** See {@link ToolCallValue}. Absent when the tool declares no input view, and in a row stored without one. */
44
+ input?: ToolCallValue;
45
+ /** The shown result of a call with the outcome `ok`. Absent when the tool declares no result view, for each other outcome, and in a row stored without one. */
46
+ result?: ToolCallValue;
47
+ /** The shown error of a call with the outcome `error`. Absent when the tool declares no error view, for each other outcome, and in a row stored without one. */
48
+ error?: ToolCallValue;
43
49
  };
44
50
  /** The discriminated union of every part the chat path can carry. */
45
51
  export type MessagePart = TextPart | ToolCallPart | ChatPart;
@@ -37,11 +37,99 @@ export declare const ToolCallOutcomeSchema: z.ZodEnum<{
37
37
  incomplete: "incomplete";
38
38
  ok: "ok";
39
39
  }>;
40
+ /** The most named leaves that a `fields` value holds. */
41
+ export declare const TOOL_CALL_FIELDS_MAX = 4;
42
+ /** A field name has 1 to 40 characters of letters, digits, `_`, and `-`. */
43
+ export declare const ToolCallFieldNameSchema: z.ZodString;
44
+ /** A language has 1 to 20 characters of lowercase letters, digits, `+`, `#`, `.`, and `-`. */
45
+ export declare const ToolCallLanguageSchema: z.ZodString;
46
+ /** Mirrors `ToolCallLeaf`. */
47
+ export declare const ToolCallLeafSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ kind: z.ZodLiteral<"text">;
49
+ text: z.ZodString;
50
+ cut: z.ZodBoolean;
51
+ }, z.core.$strip>, z.ZodObject<{
52
+ kind: z.ZodLiteral<"json">;
53
+ text: z.ZodString;
54
+ cut: z.ZodBoolean;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ kind: z.ZodLiteral<"code">;
57
+ language: z.ZodString;
58
+ text: z.ZodString;
59
+ cut: z.ZodBoolean;
60
+ }, z.core.$strip>], "kind">;
61
+ /** Mirrors `ToolCallValue`. A `fields` value holds 1 to 4 leaves and no `fields` value. */
62
+ export declare const ToolCallValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
63
+ kind: z.ZodLiteral<"text">;
64
+ text: z.ZodString;
65
+ cut: z.ZodBoolean;
66
+ }, z.core.$strip>, z.ZodObject<{
67
+ kind: z.ZodLiteral<"json">;
68
+ text: z.ZodString;
69
+ cut: z.ZodBoolean;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ kind: z.ZodLiteral<"code">;
72
+ language: z.ZodString;
73
+ text: z.ZodString;
74
+ cut: z.ZodBoolean;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ kind: z.ZodLiteral<"fields">;
77
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
78
+ kind: z.ZodLiteral<"text">;
79
+ text: z.ZodString;
80
+ cut: z.ZodBoolean;
81
+ name: z.ZodString;
82
+ }, z.core.$strip>, z.ZodObject<{
83
+ kind: z.ZodLiteral<"json">;
84
+ text: z.ZodString;
85
+ cut: z.ZodBoolean;
86
+ name: z.ZodString;
87
+ }, z.core.$strip>, z.ZodObject<{
88
+ kind: z.ZodLiteral<"code">;
89
+ language: z.ZodString;
90
+ text: z.ZodString;
91
+ cut: z.ZodBoolean;
92
+ name: z.ZodString;
93
+ }, z.core.$strip>], "kind">>;
94
+ }, z.core.$strip>], "kind">;
40
95
  export declare const ToolStartedEventSchema: z.ZodObject<{
41
96
  type: z.ZodLiteral<"tool-started">;
42
97
  toolUseId: z.ZodString;
43
98
  name: z.ZodString;
44
99
  detail: z.ZodOptional<z.ZodString>;
100
+ input: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
101
+ kind: z.ZodLiteral<"text">;
102
+ text: z.ZodString;
103
+ cut: z.ZodBoolean;
104
+ }, z.core.$strip>, z.ZodObject<{
105
+ kind: z.ZodLiteral<"json">;
106
+ text: z.ZodString;
107
+ cut: z.ZodBoolean;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ kind: z.ZodLiteral<"code">;
110
+ language: z.ZodString;
111
+ text: z.ZodString;
112
+ cut: z.ZodBoolean;
113
+ }, z.core.$strip>, z.ZodObject<{
114
+ kind: z.ZodLiteral<"fields">;
115
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
116
+ kind: z.ZodLiteral<"text">;
117
+ text: z.ZodString;
118
+ cut: z.ZodBoolean;
119
+ name: z.ZodString;
120
+ }, z.core.$strip>, z.ZodObject<{
121
+ kind: z.ZodLiteral<"json">;
122
+ text: z.ZodString;
123
+ cut: z.ZodBoolean;
124
+ name: z.ZodString;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ kind: z.ZodLiteral<"code">;
127
+ language: z.ZodString;
128
+ text: z.ZodString;
129
+ cut: z.ZodBoolean;
130
+ name: z.ZodString;
131
+ }, z.core.$strip>], "kind">>;
132
+ }, z.core.$strip>], "kind">>;
45
133
  source: z.ZodObject<{
46
134
  agentId: z.ZodString;
47
135
  callPath: z.ZodArray<z.ZodString>;
@@ -59,6 +147,105 @@ export declare const ToolFinishedEventSchema: z.ZodObject<{
59
147
  }>;
60
148
  detail: z.ZodOptional<z.ZodString>;
61
149
  durationMs: z.ZodOptional<z.ZodNumber>;
150
+ input: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
151
+ kind: z.ZodLiteral<"text">;
152
+ text: z.ZodString;
153
+ cut: z.ZodBoolean;
154
+ }, z.core.$strip>, z.ZodObject<{
155
+ kind: z.ZodLiteral<"json">;
156
+ text: z.ZodString;
157
+ cut: z.ZodBoolean;
158
+ }, z.core.$strip>, z.ZodObject<{
159
+ kind: z.ZodLiteral<"code">;
160
+ language: z.ZodString;
161
+ text: z.ZodString;
162
+ cut: z.ZodBoolean;
163
+ }, z.core.$strip>, z.ZodObject<{
164
+ kind: z.ZodLiteral<"fields">;
165
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
166
+ kind: z.ZodLiteral<"text">;
167
+ text: z.ZodString;
168
+ cut: z.ZodBoolean;
169
+ name: z.ZodString;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ kind: z.ZodLiteral<"json">;
172
+ text: z.ZodString;
173
+ cut: z.ZodBoolean;
174
+ name: z.ZodString;
175
+ }, z.core.$strip>, z.ZodObject<{
176
+ kind: z.ZodLiteral<"code">;
177
+ language: z.ZodString;
178
+ text: z.ZodString;
179
+ cut: z.ZodBoolean;
180
+ name: z.ZodString;
181
+ }, z.core.$strip>], "kind">>;
182
+ }, z.core.$strip>], "kind">>;
183
+ result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
184
+ kind: z.ZodLiteral<"text">;
185
+ text: z.ZodString;
186
+ cut: z.ZodBoolean;
187
+ }, z.core.$strip>, z.ZodObject<{
188
+ kind: z.ZodLiteral<"json">;
189
+ text: z.ZodString;
190
+ cut: z.ZodBoolean;
191
+ }, z.core.$strip>, z.ZodObject<{
192
+ kind: z.ZodLiteral<"code">;
193
+ language: z.ZodString;
194
+ text: z.ZodString;
195
+ cut: z.ZodBoolean;
196
+ }, z.core.$strip>, z.ZodObject<{
197
+ kind: z.ZodLiteral<"fields">;
198
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
199
+ kind: z.ZodLiteral<"text">;
200
+ text: z.ZodString;
201
+ cut: z.ZodBoolean;
202
+ name: z.ZodString;
203
+ }, z.core.$strip>, z.ZodObject<{
204
+ kind: z.ZodLiteral<"json">;
205
+ text: z.ZodString;
206
+ cut: z.ZodBoolean;
207
+ name: z.ZodString;
208
+ }, z.core.$strip>, z.ZodObject<{
209
+ kind: z.ZodLiteral<"code">;
210
+ language: z.ZodString;
211
+ text: z.ZodString;
212
+ cut: z.ZodBoolean;
213
+ name: z.ZodString;
214
+ }, z.core.$strip>], "kind">>;
215
+ }, z.core.$strip>], "kind">>;
216
+ error: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
217
+ kind: z.ZodLiteral<"text">;
218
+ text: z.ZodString;
219
+ cut: z.ZodBoolean;
220
+ }, z.core.$strip>, z.ZodObject<{
221
+ kind: z.ZodLiteral<"json">;
222
+ text: z.ZodString;
223
+ cut: z.ZodBoolean;
224
+ }, z.core.$strip>, z.ZodObject<{
225
+ kind: z.ZodLiteral<"code">;
226
+ language: z.ZodString;
227
+ text: z.ZodString;
228
+ cut: z.ZodBoolean;
229
+ }, z.core.$strip>, z.ZodObject<{
230
+ kind: z.ZodLiteral<"fields">;
231
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
232
+ kind: z.ZodLiteral<"text">;
233
+ text: z.ZodString;
234
+ cut: z.ZodBoolean;
235
+ name: z.ZodString;
236
+ }, z.core.$strip>, z.ZodObject<{
237
+ kind: z.ZodLiteral<"json">;
238
+ text: z.ZodString;
239
+ cut: z.ZodBoolean;
240
+ name: z.ZodString;
241
+ }, z.core.$strip>, z.ZodObject<{
242
+ kind: z.ZodLiteral<"code">;
243
+ language: z.ZodString;
244
+ text: z.ZodString;
245
+ cut: z.ZodBoolean;
246
+ name: z.ZodString;
247
+ }, z.core.$strip>], "kind">>;
248
+ }, z.core.$strip>], "kind">>;
62
249
  source: z.ZodObject<{
63
250
  agentId: z.ZodString;
64
251
  callPath: z.ZodArray<z.ZodString>;
@@ -137,6 +324,39 @@ export declare const ChatEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
137
324
  toolUseId: z.ZodString;
138
325
  name: z.ZodString;
139
326
  detail: z.ZodOptional<z.ZodString>;
327
+ input: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
328
+ kind: z.ZodLiteral<"text">;
329
+ text: z.ZodString;
330
+ cut: z.ZodBoolean;
331
+ }, z.core.$strip>, z.ZodObject<{
332
+ kind: z.ZodLiteral<"json">;
333
+ text: z.ZodString;
334
+ cut: z.ZodBoolean;
335
+ }, z.core.$strip>, z.ZodObject<{
336
+ kind: z.ZodLiteral<"code">;
337
+ language: z.ZodString;
338
+ text: z.ZodString;
339
+ cut: z.ZodBoolean;
340
+ }, z.core.$strip>, z.ZodObject<{
341
+ kind: z.ZodLiteral<"fields">;
342
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
343
+ kind: z.ZodLiteral<"text">;
344
+ text: z.ZodString;
345
+ cut: z.ZodBoolean;
346
+ name: z.ZodString;
347
+ }, z.core.$strip>, z.ZodObject<{
348
+ kind: z.ZodLiteral<"json">;
349
+ text: z.ZodString;
350
+ cut: z.ZodBoolean;
351
+ name: z.ZodString;
352
+ }, z.core.$strip>, z.ZodObject<{
353
+ kind: z.ZodLiteral<"code">;
354
+ language: z.ZodString;
355
+ text: z.ZodString;
356
+ cut: z.ZodBoolean;
357
+ name: z.ZodString;
358
+ }, z.core.$strip>], "kind">>;
359
+ }, z.core.$strip>], "kind">>;
140
360
  source: z.ZodObject<{
141
361
  agentId: z.ZodString;
142
362
  callPath: z.ZodArray<z.ZodString>;
@@ -153,6 +373,105 @@ export declare const ChatEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
153
373
  }>;
154
374
  detail: z.ZodOptional<z.ZodString>;
155
375
  durationMs: z.ZodOptional<z.ZodNumber>;
376
+ input: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
377
+ kind: z.ZodLiteral<"text">;
378
+ text: z.ZodString;
379
+ cut: z.ZodBoolean;
380
+ }, z.core.$strip>, z.ZodObject<{
381
+ kind: z.ZodLiteral<"json">;
382
+ text: z.ZodString;
383
+ cut: z.ZodBoolean;
384
+ }, z.core.$strip>, z.ZodObject<{
385
+ kind: z.ZodLiteral<"code">;
386
+ language: z.ZodString;
387
+ text: z.ZodString;
388
+ cut: z.ZodBoolean;
389
+ }, z.core.$strip>, z.ZodObject<{
390
+ kind: z.ZodLiteral<"fields">;
391
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
392
+ kind: z.ZodLiteral<"text">;
393
+ text: z.ZodString;
394
+ cut: z.ZodBoolean;
395
+ name: z.ZodString;
396
+ }, z.core.$strip>, z.ZodObject<{
397
+ kind: z.ZodLiteral<"json">;
398
+ text: z.ZodString;
399
+ cut: z.ZodBoolean;
400
+ name: z.ZodString;
401
+ }, z.core.$strip>, z.ZodObject<{
402
+ kind: z.ZodLiteral<"code">;
403
+ language: z.ZodString;
404
+ text: z.ZodString;
405
+ cut: z.ZodBoolean;
406
+ name: z.ZodString;
407
+ }, z.core.$strip>], "kind">>;
408
+ }, z.core.$strip>], "kind">>;
409
+ result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
410
+ kind: z.ZodLiteral<"text">;
411
+ text: z.ZodString;
412
+ cut: z.ZodBoolean;
413
+ }, z.core.$strip>, z.ZodObject<{
414
+ kind: z.ZodLiteral<"json">;
415
+ text: z.ZodString;
416
+ cut: z.ZodBoolean;
417
+ }, z.core.$strip>, z.ZodObject<{
418
+ kind: z.ZodLiteral<"code">;
419
+ language: z.ZodString;
420
+ text: z.ZodString;
421
+ cut: z.ZodBoolean;
422
+ }, z.core.$strip>, z.ZodObject<{
423
+ kind: z.ZodLiteral<"fields">;
424
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
425
+ kind: z.ZodLiteral<"text">;
426
+ text: z.ZodString;
427
+ cut: z.ZodBoolean;
428
+ name: z.ZodString;
429
+ }, z.core.$strip>, z.ZodObject<{
430
+ kind: z.ZodLiteral<"json">;
431
+ text: z.ZodString;
432
+ cut: z.ZodBoolean;
433
+ name: z.ZodString;
434
+ }, z.core.$strip>, z.ZodObject<{
435
+ kind: z.ZodLiteral<"code">;
436
+ language: z.ZodString;
437
+ text: z.ZodString;
438
+ cut: z.ZodBoolean;
439
+ name: z.ZodString;
440
+ }, z.core.$strip>], "kind">>;
441
+ }, z.core.$strip>], "kind">>;
442
+ error: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
443
+ kind: z.ZodLiteral<"text">;
444
+ text: z.ZodString;
445
+ cut: z.ZodBoolean;
446
+ }, z.core.$strip>, z.ZodObject<{
447
+ kind: z.ZodLiteral<"json">;
448
+ text: z.ZodString;
449
+ cut: z.ZodBoolean;
450
+ }, z.core.$strip>, z.ZodObject<{
451
+ kind: z.ZodLiteral<"code">;
452
+ language: z.ZodString;
453
+ text: z.ZodString;
454
+ cut: z.ZodBoolean;
455
+ }, z.core.$strip>, z.ZodObject<{
456
+ kind: z.ZodLiteral<"fields">;
457
+ fields: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
458
+ kind: z.ZodLiteral<"text">;
459
+ text: z.ZodString;
460
+ cut: z.ZodBoolean;
461
+ name: z.ZodString;
462
+ }, z.core.$strip>, z.ZodObject<{
463
+ kind: z.ZodLiteral<"json">;
464
+ text: z.ZodString;
465
+ cut: z.ZodBoolean;
466
+ name: z.ZodString;
467
+ }, z.core.$strip>, z.ZodObject<{
468
+ kind: z.ZodLiteral<"code">;
469
+ language: z.ZodString;
470
+ text: z.ZodString;
471
+ cut: z.ZodBoolean;
472
+ name: z.ZodString;
473
+ }, z.core.$strip>], "kind">>;
474
+ }, z.core.$strip>], "kind">>;
156
475
  source: z.ZodObject<{
157
476
  agentId: z.ZodString;
158
477
  callPath: z.ZodArray<z.ZodString>;
@@ -21,11 +21,37 @@ export const IterationEventSchema = z.object({
21
21
  export const ToolOutcomeSchema = z.enum(["ok", "error", "denied"]);
22
22
  /** Mirrors `ToolCallOutcome` — the live three plus the record-only `incomplete`. */
23
23
  export const ToolCallOutcomeSchema = z.enum(["ok", "error", "denied", "incomplete"]);
24
+ /** The most named leaves that a `fields` value holds. */
25
+ export const TOOL_CALL_FIELDS_MAX = 4;
26
+ /** A field name has 1 to 40 characters of letters, digits, `_`, and `-`. */
27
+ // oxlint-disable-next-line eslint-js/no-restricted-syntax -- a bounded character class has no zod builtin.
28
+ export const ToolCallFieldNameSchema = z.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
29
+ /** A language has 1 to 20 characters of lowercase letters, digits, `+`, `#`, `.`, and `-`. */
30
+ // oxlint-disable-next-line eslint-js/no-restricted-syntax -- a bounded character class has no zod builtin.
31
+ export const ToolCallLanguageSchema = z.string().regex(/^[a-z0-9+#.-]{1,20}$/);
32
+ const TextLeafShape = { kind: z.literal("text"), text: z.string(), cut: z.boolean() };
33
+ const JsonLeafShape = { kind: z.literal("json"), text: z.string(), cut: z.boolean() };
34
+ const CodeLeafShape = { kind: z.literal("code"), language: ToolCallLanguageSchema, text: z.string(), cut: z.boolean() };
35
+ /** Mirrors `ToolCallLeaf`. */
36
+ export const ToolCallLeafSchema = z.discriminatedUnion("kind", [z.object(TextLeafShape), z.object(JsonLeafShape), z.object(CodeLeafShape)]);
37
+ const ToolCallFieldSchema = z.discriminatedUnion("kind", [
38
+ z.object({ name: ToolCallFieldNameSchema, ...TextLeafShape }),
39
+ z.object({ name: ToolCallFieldNameSchema, ...JsonLeafShape }),
40
+ z.object({ name: ToolCallFieldNameSchema, ...CodeLeafShape }),
41
+ ]);
42
+ /** Mirrors `ToolCallValue`. A `fields` value holds 1 to 4 leaves and no `fields` value. */
43
+ export const ToolCallValueSchema = z.discriminatedUnion("kind", [
44
+ z.object(TextLeafShape),
45
+ z.object(JsonLeafShape),
46
+ z.object(CodeLeafShape),
47
+ z.object({ kind: z.literal("fields"), fields: z.array(ToolCallFieldSchema).min(1).max(TOOL_CALL_FIELDS_MAX) }),
48
+ ]);
24
49
  export const ToolStartedEventSchema = z.object({
25
50
  type: z.literal("tool-started"),
26
51
  toolUseId: z.string(),
27
52
  name: z.string(),
28
53
  detail: z.string().optional(),
54
+ input: ToolCallValueSchema.optional(),
29
55
  source: EventSourceSchema,
30
56
  });
31
57
  export const ToolFinishedEventSchema = z.object({
@@ -36,6 +62,9 @@ export const ToolFinishedEventSchema = z.object({
36
62
  detail: z.string().optional(),
37
63
  /** Optional and absent when unmeasured — never a zero in place of a figure. */
38
64
  durationMs: z.number().optional(),
65
+ input: ToolCallValueSchema.optional(),
66
+ result: ToolCallValueSchema.optional(),
67
+ error: ToolCallValueSchema.optional(),
39
68
  source: EventSourceSchema,
40
69
  });
41
70
  export const FinishEventSchema = z.object({
@@ -237,6 +237,7 @@ function buildSubmitTool(ctx) {
237
237
  "path and call again, or switch to report_blocker if the synthesis " +
238
238
  "cannot be made valid. The last accepted submission is the synthesis.",
239
239
  inputSchema: z.object({ synthesis: SynthesisDraftSchema }),
240
+ view: "none",
240
241
  describeCall: "none",
241
242
  execute: (input) => {
242
243
  const issues = semanticCheck(input.synthesis, ctx);
package/dist/index.d.ts CHANGED
@@ -55,6 +55,8 @@ export { defineTool, isToolError } from "./tools/define-tool.js";
55
55
  export { createHttpKnowledgeClient, createKnowledgeRecommendTool, createKnowledgeCheckTool, createKnowledgeTools, knowledgeToolDefinitionHash, } from "./tools/knowledge/index.js";
56
56
  export type { KnowledgeClient, KnowledgeSituation, HttpKnowledgeClientConfig } from "./tools/knowledge/index.js";
57
57
  export type { Tool, ToolDefinition, ToolContext, ToolError } from "./tools/define-tool.js";
58
+ export { viewText, viewJson, viewCode, viewFields } from "./tools/tool-view.js";
59
+ export type { ToolCallView, ViewText, ViewJson, ViewCode, ViewFields, ViewLeaf, ViewValue } from "./tools/tool-view.js";
58
60
  export { normalizeDetail, DETAIL_MAX_LENGTH } from "./loop/tool-detail.js";
59
61
  export { createCitationResolver } from "./citations/resolve.js";
60
62
  export type { CitationResolverConfig, CitationResolverDependencies, CitationResolverSourceConfig } from "./citations/resolve.js";
@@ -99,7 +101,7 @@ export type { ConversationDisplayRecorder, ConversationDisplayRecorderOptions }
99
101
  export { envelopeDisplayMessages, parseStoredDisplayEnvelope } from "./memory/conversation-display-storage.js";
100
102
  export type { ConversationDisplayMetadata, ConversationUIData, ConversationUIMessage, StoredDisplayEnvelope } from "./memory/conversation-display-storage.js";
101
103
  export { storedMessagesToChat } from "./memory/conversation-display-replay.js";
102
- export type { ChatEvent, ChatFrame, ChatPartFrame, TextDeltaEvent, IterationEvent, ToolStartedEvent, ToolFinishedEvent, ToolOutcome, ToolCallOutcome, ToolCallDetail, FinishEvent, ChatErrorEvent, MessageStartEvent, } from "./contracts/chat-events.js";
104
+ export type { ChatEvent, ChatFrame, ChatPartFrame, TextDeltaEvent, IterationEvent, ToolStartedEvent, ToolFinishedEvent, ToolOutcome, ToolCallOutcome, ToolCallDetail, ToolCallLeaf, ToolCallValue, FinishEvent, ChatErrorEvent, MessageStartEvent, } from "./contracts/chat-events.js";
103
105
  export { toChatFrame, applyChatFrame, checkChatPart, isKnownPartFrame } from "./contracts/chat-frame.js";
104
106
  export { createSubAgentActivityTracker, SUBAGENT_ACTIVITY_MAX_ENTRIES } from "./contracts/subagent-activity.js";
105
107
  export type { SubAgentActivityTracker } from "./contracts/subagent-activity.js";
@@ -190,8 +192,8 @@ export { planGraphOf } from "./workflows/plan/graph.js";
190
192
  export { planPartOf } from "./memory/card-builders.js";
191
193
  export { validatePlan } from "./schemas/validate-plan.js";
192
194
  export type { ValidationResult } from "./schemas/validate-plan.js";
193
- export { upsertPlan, loadPlan, loadPlanRecord } from "./state/plans.js";
194
- export type { UpsertPlanInput, PlanRecord } from "./state/plans.js";
195
+ export { upsertPlan, loadPlan, loadPlanRecord, queryPlanPage } from "./state/plans.js";
196
+ export type { UpsertPlanInput, PlanRecord, PlanPage, PlanPageEntry } from "./state/plans.js";
195
197
  export { insertRun, reserveRunById, queryActiveRun, queryActiveRunsByAnalysis, updateRunStatus, markRunCanceledIfActive, queryRun, queryRunsByAnalysis, countRunsByAnalysis, queryRunIdsByPlan, RunDedupCollisionError, RunIdentityCollisionError, } from "./state/runs.js";
196
198
  export type { InsertRunInput, RunReservation } from "./state/runs.js";
197
199
  export { queryStepsByRun, countStepsByRuns } from "./state/step-executions.js";
package/dist/index.js CHANGED
@@ -73,6 +73,7 @@ export { defineTool, isToolError } from "./tools/define-tool.js";
73
73
  // (or none), and it can hand `knowledge_recommend` to the conversation agent
74
74
  // through `hostTools`.
75
75
  export { createHttpKnowledgeClient, createKnowledgeRecommendTool, createKnowledgeCheckTool, createKnowledgeTools, knowledgeToolDefinitionHash, } from "./tools/knowledge/index.js";
76
+ export { viewText, viewJson, viewCode, viewFields } from "./tools/tool-view.js";
76
77
  // Tool-call-detail authoring aids for an embedder that contributes a host tool.
77
78
  // A `describeCall` hook that pre-empts truncation — a count in place of a
78
79
  // mid-value cut that would name a file that does not exist — must gate on the
@@ -293,7 +294,7 @@ export { validatePlan } from "./schemas/validate-plan.js";
293
294
  // Plan + run + step ledgers around a trigger. `upsertPlan` takes a
294
295
  // caller-derived id and inserts-if-absent (the deterministic-id intake path);
295
296
  // the run-state calls mirror the chat trigger's reserve → dedup → status flow.
296
- export { upsertPlan, loadPlan, loadPlanRecord } from "./state/plans.js";
297
+ export { upsertPlan, loadPlan, loadPlanRecord, queryPlanPage } from "./state/plans.js";
297
298
  export { insertRun, reserveRunById, queryActiveRun, queryActiveRunsByAnalysis, updateRunStatus, markRunCanceledIfActive, queryRun, queryRunsByAnalysis, countRunsByAnalysis, queryRunIdsByPlan, RunDedupCollisionError, RunIdentityCollisionError, } from "./state/runs.js";
298
299
  // The step ledger reads of a run, and the step counts of each run of a list in one statement.
299
300
  export { queryStepsByRun, countStepsByRuns } from "./state/step-executions.js";
@@ -3,8 +3,14 @@
3
3
  * What runs is exactly what is declared here.
4
4
  *
5
5
  * `normalizeUnicode` and `redactSecrets` are applied once to the incoming user
6
- * message by the chat route (change 6), and never to assistant messages or tool
7
- * results. `stripNulCharacters` is the exception — it applies to tool results.
6
+ * message by the chat route, and never to assistant messages or to the result
7
+ * that a tool gives the model. `stripNulCharacters` is the exception — it
8
+ * applies to tool results.
9
+ *
10
+ * `redactSecretForms`, `redactSecretFields`, and `redactSecretAssignments` are
11
+ * the value-only rules: only the shown values of a tool call (`loop/tool-value.ts`)
12
+ * get them. They are name-based rules that would mark prose and sequences in a
13
+ * user message. The model reads the unchanged result.
8
14
  */
9
15
  /**
10
16
  * NFC-normalize and strip control characters.
@@ -30,3 +36,25 @@ export declare function stripNulCharacters(text: string): string;
30
36
  * 40-residue protein sequence passes through unchanged.
31
37
  */
32
38
  export declare function redactSecrets(text: string): string;
39
+ /**
40
+ * A copy of a JSON value in which the value of each object field with a secret name is the redaction marker. The
41
+ * walk goes to each depth, thus the `GITHUB_TOKEN` field of an `env` object is found. An array applies the rule of
42
+ * {@link redactArgvValues} to its strings. The rule belongs to the values of a tool call only. `redactSecrets` stays
43
+ * free of any name-based rule, because a user message holds prose and sequences that such a rule would mark.
44
+ */
45
+ export declare function redactSecretFields(value: unknown): unknown;
46
+ /**
47
+ * Replace the value of each `NAME=value` assignment and of each quoted `"name": value` field whose name ends with a
48
+ * secret word. A caller runs it on a plain text or on one string of a JSON value, never on serialized JSON, because a
49
+ * JSON escape hides the quotes that the rules read. It runs on the text of a tool call value only. See
50
+ * {@link redactSecretFields}.
51
+ */
52
+ export declare function redactSecretAssignments(text: string): string;
53
+ /**
54
+ * Replace the secret that each of these forms holds: a private-key block, the password of a URL, the password of a
55
+ * `-u user:password` option, the value of a `Cookie` header, the value of a `--name value` flag, the value of a
56
+ * `name: value` pair, and each form of {@link redactSecretAssignments}. A name must end with a secret word.
57
+ * It covers these forms only: a text can hold a secret in a different form. It runs on the text of a tool call value
58
+ * only, on a plain text or on one string of a JSON value.
59
+ */
60
+ export declare function redactSecretForms(text: string): string;