@axiastudio/aioc 0.1.0-rc.1 → 0.2.0-next.1

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/README.md CHANGED
@@ -8,13 +8,14 @@ Project home and documentation: [https://axiastudio.github.io/aioc](https://axia
8
8
 
9
9
  ## Release Status
10
10
 
11
- This package is currently in release-candidate phase (`0.1.0-rc.1`) and is not yet stable.
12
- The core runtime surface is expected to remain frozen except for bug fixes, cleanup, and documentation adjustments before `0.1.0`.
11
+ This package is stable as of `0.1.0`.
12
+ The core runtime surface is compatibility-managed. Breaking changes to the stable surface should ship only with explicit migration guidance and release notes.
13
13
 
14
- ### What Stable Means
14
+ ### Stable Scope
15
15
 
16
- AIOC will move from release candidate to stable when the core runtime surface is confirmed, the public documentation matches the actual exported contract, `RunRecord` and replay/compare workflows are considered reliable, and the SDK has been validated in real applications beyond toy examples.
16
+ AIOC `0.1.0` stabilizes the core runtime surface, public documentation aligned to the exported contract, `RunRecord` and replay/compare workflows, and the governance-first runtime model validated in real applications beyond toy examples.
17
17
 
18
+ - Release notes: `CHANGELOG.md`
18
19
  - Historical beta contract snapshot: `docs/BETA-CONTRACT.md`
19
20
  - Historical alpha contract snapshot: `docs/ALPHA-CONTRACT.md`
20
21
  - Privacy baseline: `docs/PRIVACY-BASELINE.md`
@@ -96,7 +97,9 @@ console.log(result.finalOutput);
96
97
  - provider setup helpers `setupMistral(...)`, `setupOpenAI(...)`, `setupProvider(...)`
97
98
  - run logger hook `run(..., { logger })`
98
99
  - run record hook `run(..., { record })`
100
+ - run output adapter `toRunOutputEvents(...)`
99
101
  - run-record utilities `extractToolCalls(...)`, `compareRunRecords(...)`, `replayFromRunRecord(...)`
102
+ - thread history utilities `toThreadHistory(...)`, `appendUserMessage(...)`, `replaceThreadHistory(...)`, `applyRunResultHistory(...)`
100
103
  - JSON helper `toJsonValue(...)`
101
104
 
102
105
  ## Policy Gate (Minimal)
@@ -258,7 +261,11 @@ AIOC adopts the following non-negotiable principles:
258
261
  - `docs/RFC-0002-policy-gates-for-tools-and-handoffs.md` (`Accepted`)
259
262
  - `docs/RFC-0003-run-record-audit-trail-and-persistence.md` (`Accepted`)
260
263
  - `docs/RFC-0004-policy-outcomes-and-approval-model.md` (`Accepted`)
261
- - `docs/RFC-0005-suspended-proposals-and-approval-lifecycle.md` (`Draft`)
264
+ - `docs/RFC-0005-suspended-proposals-and-approval-lifecycle.md` (`Accepted`)
265
+ - `docs/RFC-0006-approval-evidence-helpers.md` (`Draft`)
266
+ - `docs/RFC-0007-thread-state-utilities.md` (`Accepted`)
267
+ - `docs/RFC-0008-run-stream-consumer-utilities.md` (`Accepted`)
268
+ - `docs/RFC-0009-governance-events-and-exporters.md` (`Experimental`)
262
269
  - `docs/PRIVACY-BASELINE.md`
263
270
 
264
271
  ## Historical Snapshots
@@ -0,0 +1,78 @@
1
+ import { Agent } from "./agent";
2
+ import type { Tool } from "./tool";
3
+ import type { NonStreamRunOptions } from "./types";
4
+ export interface HarnessDescriptorMetadata {
5
+ name?: string;
6
+ version?: string;
7
+ [key: string]: unknown;
8
+ }
9
+ export interface HarnessRuntimeDescriptor {
10
+ entry_agent: string;
11
+ max_turns?: number;
12
+ }
13
+ export interface HarnessToolDescriptor {
14
+ target: string;
15
+ }
16
+ export interface HarnessAgentDescriptor {
17
+ name?: string;
18
+ handoffDescription?: string;
19
+ instructions?: string;
20
+ model?: string;
21
+ modelSettings?: Record<string, unknown>;
22
+ tools?: string[];
23
+ handoffs?: string[];
24
+ }
25
+ export interface HarnessContextReferenceDescriptor {
26
+ type?: string;
27
+ optional?: boolean;
28
+ [key: string]: unknown;
29
+ }
30
+ export type HarnessContextReferenceEntry = boolean | HarnessContextReferenceDescriptor;
31
+ export interface HarnessContextFieldDescriptor {
32
+ type: string;
33
+ default?: unknown;
34
+ optional?: boolean;
35
+ mutable?: boolean;
36
+ redact?: boolean;
37
+ [key: string]: unknown;
38
+ }
39
+ export interface HarnessContextDescriptor {
40
+ fields?: Record<string, HarnessContextFieldDescriptor>;
41
+ references?: Record<string, HarnessContextReferenceEntry>;
42
+ }
43
+ export interface AgentHarnessDescriptor {
44
+ descriptor_version?: string;
45
+ metadata?: HarnessDescriptorMetadata;
46
+ runtime: HarnessRuntimeDescriptor;
47
+ context?: HarnessContextDescriptor;
48
+ tools?: Record<string, HarnessToolDescriptor>;
49
+ agent_defaults?: Pick<HarnessAgentDescriptor, "model" | "modelSettings" | "instructions">;
50
+ agents: Record<string, HarnessAgentDescriptor>;
51
+ }
52
+ export interface AgentHarnessRegistry<TContext = unknown> {
53
+ tools?: Record<string, Tool<TContext>>;
54
+ registryVersion?: string;
55
+ }
56
+ export interface CreateHarnessContextInput {
57
+ message?: string;
58
+ now?: string | Date;
59
+ overrides?: unknown;
60
+ }
61
+ export interface AgentHarnessMetadata {
62
+ name?: string;
63
+ version?: string;
64
+ descriptorVersion?: string;
65
+ descriptorHash: string;
66
+ registryVersion?: string;
67
+ }
68
+ export interface AgentHarness<TContext = unknown> {
69
+ entryAgent: Agent<TContext>;
70
+ agents: Map<string, Agent<TContext>>;
71
+ descriptorHash: string;
72
+ metadata: AgentHarnessMetadata;
73
+ runOptions: Omit<NonStreamRunOptions<TContext>, "stream">;
74
+ createContext(input?: CreateHarnessContextInput): TContext;
75
+ }
76
+ export declare function hashAgentHarnessDescriptor(descriptor: AgentHarnessDescriptor): string;
77
+ export declare function buildAgentHarness<TContext = unknown>(descriptor: AgentHarnessDescriptor, registry?: AgentHarnessRegistry<TContext>): AgentHarness<TContext>;
78
+ //# sourceMappingURL=harness-descriptor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness-descriptor.d.ts","sourceRoot":"","sources":["../src/harness-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA0B,MAAM,SAAS,CAAC;AAExD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,M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AE,oBAAoB,CAAC;IAC/B,UAAU,EAAE,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC1D,aAAa,CAAC,KAAK,CAAC,EAAE,yBAAyB,GAAG,QAAQ,CAAC;CAC5D;AAoSD,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,sBAAsB,GACjC,MAAM,CAER;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,GAAG,OAAO,EAClD,UAAU,EAAE,sBAAsB,EAClC,QAAQ,GAAE,oBAAoB,CAAC,QAAQ,CAAM,GAC5C,YAAY,CAAC,QAAQ,CAAC,CAmExB"}
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hashAgentHarnessDescriptor = hashAgentHarnessDescriptor;
4
+ exports.buildAgentHarness = buildAgentHarness;
5
+ const agent_1 = require("./agent");
6
+ const canonical_json_1 = require("./canonical-json");
7
+ const CONTEXT_PROMPT_PLACEHOLDER = /\{\{\s*context\.([^}]+?)\s*\}\}/g;
8
+ function cloneJsonValue(value) {
9
+ if (typeof value === "undefined") {
10
+ return undefined;
11
+ }
12
+ return JSON.parse(JSON.stringify(value));
13
+ }
14
+ function isPlainObject(value) {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+ function normalizePromptPath(path, label) {
18
+ const segments = path
19
+ .split(".")
20
+ .map((segment) => segment.trim())
21
+ .filter((segment) => segment.length > 0);
22
+ if (segments.length === 0) {
23
+ throw new Error(`${label} cannot be empty.`);
24
+ }
25
+ for (const segment of segments) {
26
+ if (!/^[A-Za-z0-9_-]+$/.test(segment)) {
27
+ throw new Error(`${label} contains invalid segment "${segment}".`);
28
+ }
29
+ }
30
+ return segments.join(".");
31
+ }
32
+ function createPromptReferenceRules(descriptor) {
33
+ const rules = new Map();
34
+ for (const [path, reference] of Object.entries(descriptor.context?.references ?? {})) {
35
+ if (reference === false) {
36
+ continue;
37
+ }
38
+ const normalizedPath = normalizePromptPath(path, "Context reference path");
39
+ if (reference === true) {
40
+ rules.set(normalizedPath, { optional: false });
41
+ continue;
42
+ }
43
+ if (!isPlainObject(reference)) {
44
+ throw new Error(`Context reference "${path}" must be true, false, or an object.`);
45
+ }
46
+ rules.set(normalizedPath, { optional: Boolean(reference.optional) });
47
+ }
48
+ return rules;
49
+ }
50
+ function collectContextPromptPaths(template) {
51
+ const paths = new Set();
52
+ for (const match of template.matchAll(CONTEXT_PROMPT_PLACEHOLDER)) {
53
+ const rawPath = match[1];
54
+ if (!rawPath) {
55
+ continue;
56
+ }
57
+ paths.add(normalizePromptPath(rawPath, `Context prompt placeholder "${match[0]}"`));
58
+ }
59
+ return [...paths];
60
+ }
61
+ function readPromptPath(context, path) {
62
+ let cursor = context;
63
+ for (const segment of normalizePromptPath(path, "Context prompt path").split(".")) {
64
+ if (typeof cursor !== "object" || cursor === null || !(segment in cursor)) {
65
+ return { exists: false, value: undefined };
66
+ }
67
+ cursor = cursor[segment];
68
+ }
69
+ return { exists: true, value: cursor };
70
+ }
71
+ function stringifyPromptValue(value) {
72
+ if (typeof value === "string") {
73
+ return value;
74
+ }
75
+ if (typeof value === "number" ||
76
+ typeof value === "boolean" ||
77
+ typeof value === "bigint") {
78
+ return String(value);
79
+ }
80
+ if (typeof value === "undefined") {
81
+ return "";
82
+ }
83
+ const json = JSON.stringify(value);
84
+ return typeof json === "undefined" ? String(value) : json;
85
+ }
86
+ function renderInstructionTemplate(template, context, promptAccessRules) {
87
+ return template.replace(CONTEXT_PROMPT_PLACEHOLDER, (placeholder, rawPath) => {
88
+ const path = normalizePromptPath(rawPath, `Context prompt placeholder "${placeholder}"`);
89
+ const rule = promptAccessRules.get(path);
90
+ if (!rule) {
91
+ throw new Error(`Harness descriptor instruction references undeclared context path "${path}".`);
92
+ }
93
+ const resolved = readPromptPath(context, path);
94
+ if (!resolved.exists || typeof resolved.value === "undefined") {
95
+ if (rule.optional) {
96
+ return "";
97
+ }
98
+ throw new Error(`Harness descriptor instruction could not resolve required context path "${path}".`);
99
+ }
100
+ return stringifyPromptValue(resolved.value);
101
+ });
102
+ }
103
+ function compileAgentInstructions(agentId, instructions, promptAccessRules) {
104
+ if (typeof instructions === "undefined") {
105
+ return undefined;
106
+ }
107
+ const promptPaths = collectContextPromptPaths(instructions);
108
+ if (promptPaths.length === 0) {
109
+ return instructions;
110
+ }
111
+ for (const path of promptPaths) {
112
+ if (!promptAccessRules.has(path)) {
113
+ throw new Error(`Agent "${agentId}" instruction references undeclared context path "${path}".`);
114
+ }
115
+ }
116
+ return (runContext) => renderInstructionTemplate(instructions, runContext.context, promptAccessRules);
117
+ }
118
+ function setPath(target, path, value) {
119
+ const segments = path.split(".").filter((segment) => segment.length > 0);
120
+ if (segments.length === 0) {
121
+ throw new Error("Context field path cannot be empty.");
122
+ }
123
+ let cursor = target;
124
+ for (const segment of segments.slice(0, -1)) {
125
+ const existing = cursor[segment];
126
+ if (typeof existing !== "object" || existing === null) {
127
+ const next = {};
128
+ cursor[segment] = next;
129
+ cursor = next;
130
+ continue;
131
+ }
132
+ cursor = existing;
133
+ }
134
+ cursor[segments[segments.length - 1]] = value;
135
+ }
136
+ function mergeObject(target, source) {
137
+ for (const [key, value] of Object.entries(source)) {
138
+ const current = target[key];
139
+ if (current &&
140
+ typeof current === "object" &&
141
+ !Array.isArray(current) &&
142
+ value &&
143
+ typeof value === "object" &&
144
+ !Array.isArray(value)) {
145
+ mergeObject(current, value);
146
+ continue;
147
+ }
148
+ target[key] = cloneJsonValue(value);
149
+ }
150
+ }
151
+ function resolveDefaultValue(value, input) {
152
+ if (value === "{{input.message}}") {
153
+ return input.message ?? "";
154
+ }
155
+ if (value === "{{runtime.now_iso}}") {
156
+ const now = input.now ?? new Date();
157
+ return now instanceof Date ? now.toISOString() : now;
158
+ }
159
+ return cloneJsonValue(value);
160
+ }
161
+ function createContextFromDescriptor(descriptor, input = {}) {
162
+ const context = {};
163
+ for (const [path, field] of Object.entries(descriptor.context?.fields ?? {})) {
164
+ if (!("default" in field)) {
165
+ continue;
166
+ }
167
+ setPath(context, path, resolveDefaultValue(field.default, input));
168
+ }
169
+ if (input.overrides &&
170
+ typeof input.overrides === "object" &&
171
+ !Array.isArray(input.overrides)) {
172
+ mergeObject(context, input.overrides);
173
+ }
174
+ return context;
175
+ }
176
+ function resolveTool(toolId, descriptor, registry) {
177
+ const toolDescriptor = descriptor.tools?.[toolId];
178
+ if (!toolDescriptor) {
179
+ throw new Error(`Harness descriptor references unknown tool "${toolId}".`);
180
+ }
181
+ const toolDefinition = registry.tools?.[toolDescriptor.target];
182
+ if (!toolDefinition) {
183
+ throw new Error(`Harness registry is missing target "${toolDescriptor.target}" for tool "${toolId}".`);
184
+ }
185
+ return toolDefinition;
186
+ }
187
+ function hashAgentHarnessDescriptor(descriptor) {
188
+ return `sha256:${(0, canonical_json_1.hashCanonicalJsonValue)(descriptor)}`;
189
+ }
190
+ function buildAgentHarness(descriptor, registry = {}) {
191
+ const descriptorHash = hashAgentHarnessDescriptor(descriptor);
192
+ const agents = new Map();
193
+ const promptAccessRules = createPromptReferenceRules(descriptor);
194
+ for (const [agentId, agentDescriptor] of Object.entries(descriptor.agents)) {
195
+ const instructions = agentDescriptor.instructions ?? descriptor.agent_defaults?.instructions;
196
+ const agent = new agent_1.Agent({
197
+ name: agentDescriptor.name ?? agentId,
198
+ handoffDescription: agentDescriptor.handoffDescription,
199
+ instructions: compileAgentInstructions(agentId, instructions, promptAccessRules),
200
+ model: agentDescriptor.model ?? descriptor.agent_defaults?.model,
201
+ modelSettings: agentDescriptor.modelSettings ??
202
+ descriptor.agent_defaults?.modelSettings,
203
+ tools: (agentDescriptor.tools ?? []).map((toolId) => resolveTool(toolId, descriptor, registry)),
204
+ handoffs: [],
205
+ });
206
+ agents.set(agentId, agent);
207
+ }
208
+ for (const [agentId, agentDescriptor] of Object.entries(descriptor.agents)) {
209
+ const agent = agents.get(agentId);
210
+ if (!agent) {
211
+ continue;
212
+ }
213
+ agent.handoffs = (agentDescriptor.handoffs ?? []).map((handoffId) => {
214
+ const handoffAgent = agents.get(handoffId);
215
+ if (!handoffAgent) {
216
+ throw new Error(`Harness descriptor references unknown handoff agent "${handoffId}" from "${agentId}".`);
217
+ }
218
+ return handoffAgent;
219
+ });
220
+ }
221
+ const entryAgent = agents.get(descriptor.runtime.entry_agent);
222
+ if (!entryAgent) {
223
+ throw new Error(`Harness descriptor entry_agent "${descriptor.runtime.entry_agent}" does not exist.`);
224
+ }
225
+ return {
226
+ entryAgent,
227
+ agents,
228
+ descriptorHash,
229
+ metadata: {
230
+ name: descriptor.metadata?.name,
231
+ version: descriptor.metadata?.version,
232
+ descriptorVersion: descriptor.descriptor_version,
233
+ descriptorHash,
234
+ registryVersion: registry.registryVersion,
235
+ },
236
+ runOptions: {
237
+ maxTurns: descriptor.runtime.max_turns,
238
+ },
239
+ createContext: (input) => createContextFromDescriptor(descriptor, input),
240
+ };
241
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./agent";
2
2
  export * from "./config";
3
3
  export * from "./errors";
4
4
  export * from "./guardrails";
5
+ export * from "./harness-descriptor";
5
6
  export * from "./json";
6
7
  export * from "./logger";
7
8
  export * from "./messages";
@@ -13,9 +14,11 @@ export * from "./providers/chat-completions";
13
14
  export * from "./providers/mistral";
14
15
  export * from "./providers/openai";
15
16
  export * from "./run";
17
+ export * from "./run-output-events";
16
18
  export * from "./run-record";
17
19
  export * from "./run-record-utils";
18
20
  export * from "./run-context";
21
+ export * from "./thread-history";
19
22
  export * from "./tool";
20
23
  export * from "./types";
21
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC;AACtB,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ __exportStar(require("./agent"), exports);
18
18
  __exportStar(require("./config"), exports);
19
19
  __exportStar(require("./errors"), exports);
20
20
  __exportStar(require("./guardrails"), exports);
21
+ __exportStar(require("./harness-descriptor"), exports);
21
22
  __exportStar(require("./json"), exports);
22
23
  __exportStar(require("./logger"), exports);
23
24
  __exportStar(require("./messages"), exports);
@@ -29,8 +30,10 @@ __exportStar(require("./providers/chat-completions"), exports);
29
30
  __exportStar(require("./providers/mistral"), exports);
30
31
  __exportStar(require("./providers/openai"), exports);
31
32
  __exportStar(require("./run"), exports);
33
+ __exportStar(require("./run-output-events"), exports);
32
34
  __exportStar(require("./run-record"), exports);
33
35
  __exportStar(require("./run-record-utils"), exports);
34
36
  __exportStar(require("./run-context"), exports);
37
+ __exportStar(require("./thread-history"), exports);
35
38
  __exportStar(require("./tool"), exports);
36
39
  __exportStar(require("./types"), exports);
@@ -8,7 +8,6 @@ export interface ToolResultEnvelope {
8
8
  data: unknown | null;
9
9
  }
10
10
  export declare function createDeniedPolicyResult(reason: string, metadata?: Record<string, unknown>): PolicyResult;
11
- export declare function createDeprecatedPolicyFieldResult(fieldName: string, replacementField: string, receivedValue?: unknown): PolicyResult;
12
11
  export declare function toAllowedToolResultEnvelope(data: unknown): ToolResultEnvelope;
13
12
  export declare function materializePolicyResult(policyResult: PolicyResult): PolicyResult;
14
13
  export declare function resolveResultMode(policyResult: PolicyResult): PolicyResultMode;
@@ -1 +1 @@
1
- {"version":3,"file":"policy-outcomes.d.ts","sourceRoot":"","sources":["../src/policy-outcomes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,MAAM,wBAAwB,GAAG,IAAI,GAAG,QAAQ,GAAG,mBAAmB,CAAC;AAE7E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,wBAAwB,CAAC;IACjC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAA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CACtB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,YAAY,CAOd;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB,CAO7E;AAoBD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,YAAY,GACzB,YAAY,CAYd;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,YAAY,GACzB,gBAAgB,CAElB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EACF;IACE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,GACJ,kBAAkB,CA+CpB"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createDeniedPolicyResult = createDeniedPolicyResult;
4
- exports.createDeprecatedPolicyFieldResult = createDeprecatedPolicyFieldResult;
5
4
  exports.toAllowedToolResultEnvelope = toAllowedToolResultEnvelope;
6
5
  exports.materializePolicyResult = materializePolicyResult;
7
6
  exports.resolveResultMode = resolveResultMode;
@@ -15,13 +14,6 @@ function createDeniedPolicyResult(reason, metadata) {
15
14
  metadata,
16
15
  };
17
16
  }
18
- function createDeprecatedPolicyFieldResult(fieldName, replacementField, receivedValue) {
19
- return createDeniedPolicyResult(`deprecated_policy_field_${fieldName}`, {
20
- deprecatedField: fieldName,
21
- replacementField,
22
- receivedValue,
23
- });
24
- }
25
17
  function toAllowedToolResultEnvelope(data) {
26
18
  return {
27
19
  status: "ok",
@@ -8,6 +8,7 @@ export declare class ChatCompletionsProvider implements ModelProvider {
8
8
  private baseURL;
9
9
  private headers;
10
10
  constructor(options: ChatCompletionsProviderOptions);
11
+ protected getInstructionRole(): "system" | "developer";
11
12
  stream<TContext = unknown>(request: ProviderRequest<TContext>): AsyncIterable<ProviderEvent>;
12
13
  }
13
14
  //# sourceMappingURL=chat-completions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-completions.d.ts","sourceRoot":"","sources":["../../src/providers/chat-completions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEvE,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AA6SD,qBAAa,uBAAwB,YAAW,aAAa;IAC3D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAc;gBAEjB,OAAO,EAAE,8BAA8B;IAK5C,MAAM,CAAC,QAAQ,GAAG,OAAO,EAC9B,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GACjC,aAAa,CAAC,aAAa,CAAC;CAoHhC"}
1
+ {"version":3,"file":"chat-completions.d.ts","sourceRoot":"","sources":["../../src/providers/chat-completions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEvE,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AA8SD,qBAAa,uBAAwB,YAAW,aAAa;IAC3D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAc;gBAEjB,OAAO,EAAE,8BAA8B;IAKnD,SAAS,CAAC,kBAAkB,IAAI,QAAQ,GAAG,WAAW;IAI/C,MAAM,CAAC,QAAQ,GAAG,OAAO,EAC9B,OAAO,EAAE,eAAe,CAAC,QAAQ,CAAC,GACjC,aAAa,CAAC,aAAa,CAAC;CAwHhC"}
@@ -69,11 +69,11 @@ function normalizeMessageContent(content) {
69
69
  }
70
70
  return stringifySafe(content);
71
71
  }
72
- function toChatMessages(items, systemPrompt) {
72
+ function toChatMessages(items, systemPrompt, instructionRole = "system") {
73
73
  const messages = [];
74
74
  if (systemPrompt) {
75
75
  messages.push({
76
- role: "system",
76
+ role: instructionRole,
77
77
  content: systemPrompt,
78
78
  });
79
79
  }
@@ -208,10 +208,13 @@ class ChatCompletionsProvider {
208
208
  this.baseURL = normalizeBaseURL(options.baseURL);
209
209
  this.headers = buildHeaders(options);
210
210
  }
211
+ getInstructionRole() {
212
+ return "system";
213
+ }
211
214
  async *stream(request) {
212
215
  const payload = {
213
216
  model: request.model,
214
- messages: toChatMessages(request.messages, request.systemPrompt),
217
+ messages: toChatMessages(request.messages, request.systemPrompt, this.getInstructionRole()),
215
218
  tools: request.tools.length > 0 ? toTools(request.tools) : undefined,
216
219
  tool_choice: request.tools.length > 0 ? "auto" : undefined,
217
220
  stream: true,
@@ -7,5 +7,6 @@ export type OpenAIProviderOptions = Omit<ChatCompletionsProviderOptions, "baseUR
7
7
  };
8
8
  export declare class OpenAIProvider extends ChatCompletionsProvider {
9
9
  constructor(options: OpenAIProviderOptions);
10
+ protected getInstructionRole(): "developer";
10
11
  }
11
12
  //# sourceMappingURL=openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,8BAA8B,EAC9B,SAAS,GAAG,SAAS,CACtB,GAAG;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAcF,qBAAa,cAAe,SAAQ,uBAAuB;gBAC7C,OAAO,EAAE,qBAAqB;CAO3C"}
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,8BAA8B,EAC9B,SAAS,GAAG,SAAS,CACtB,GAAG;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAcF,qBAAa,cAAe,SAAQ,uBAAuB;gBAC7C,OAAO,EAAE,qBAAqB;cAQvB,kBAAkB,IAAI,WAAW;CAGrD"}
@@ -19,5 +19,8 @@ class OpenAIProvider extends chat_completions_1.ChatCompletionsProvider {
19
19
  headers: toOpenAIHeaders(options),
20
20
  });
21
21
  }
22
+ getInstructionRole() {
23
+ return "developer";
24
+ }
22
25
  }
23
26
  exports.OpenAIProvider = OpenAIProvider;
@@ -0,0 +1,31 @@
1
+ import type { Agent } from "./agent";
2
+ import { type ExtractedToolCall } from "./run-record-utils";
3
+ import type { StreamedRunResult } from "./run";
4
+ import type { AgentInputItem, ToolCallItem, ToolCallOutputItem } from "./types";
5
+ export type RunOutputEvent<TContext = unknown> = {
6
+ type: "text_delta";
7
+ delta: string;
8
+ } | {
9
+ type: "completed";
10
+ finalOutput: string;
11
+ history: AgentInputItem[];
12
+ lastAgent: Agent<TContext>;
13
+ toolCalls: ExtractedToolCall[];
14
+ } | {
15
+ type: "agent_updated";
16
+ agent: Agent<TContext>;
17
+ } | {
18
+ type: "tool_call";
19
+ item: ToolCallItem;
20
+ } | {
21
+ type: "tool_output";
22
+ item: ToolCallOutputItem;
23
+ output: unknown;
24
+ toolCall?: ToolCallItem;
25
+ };
26
+ export declare function toRunOutputEvents<TContext = unknown>(result: StreamedRunResult<TContext>, options?: {
27
+ emitAgentUpdates?: boolean;
28
+ emitToolCalls?: boolean;
29
+ emitToolOutputs?: boolean;
30
+ }): AsyncIterable<RunOutputEvent<TContext>>;
31
+ //# sourceMappingURL=run-output-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-output-events.d.ts","sourceRoot":"","sources":["../src/run-output-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEhF,MAAM,MAAM,cAAc,CAAC,QAAQ,GAAG,OAAO,IACzC;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC3B,SAAS,EAAE,iBAAiB,EAAE,CAAC;CAChC,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CACxB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB,CAAC;AAEN,wBAAuB,iBAAiB,CAAC,QAAQ,GAAG,OAAO,EACzD,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EACnC,OAAO,CAAC,EAAE;IACR,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GACA,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAmEzC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toRunOutputEvents = toRunOutputEvents;
4
+ const run_record_utils_1 = require("./run-record-utils");
5
+ async function* toRunOutputEvents(result, options) {
6
+ const toolCallsById = new Map();
7
+ let finalOutput = "";
8
+ let hasSeenInitialAgent = false;
9
+ for await (const event of result.toStream()) {
10
+ if (event.type === "raw_model_stream_event") {
11
+ if (typeof event.data.delta === "string") {
12
+ yield {
13
+ type: "text_delta",
14
+ delta: event.data.delta,
15
+ };
16
+ }
17
+ continue;
18
+ }
19
+ if (event.type === "agent_updated_stream_event") {
20
+ if (!hasSeenInitialAgent) {
21
+ hasSeenInitialAgent = true;
22
+ continue;
23
+ }
24
+ if (options?.emitAgentUpdates) {
25
+ yield {
26
+ type: "agent_updated",
27
+ agent: event.agent,
28
+ };
29
+ }
30
+ continue;
31
+ }
32
+ if (event.item.type === "tool_call_item") {
33
+ toolCallsById.set(event.item.callId, event.item);
34
+ if (options?.emitToolCalls) {
35
+ yield {
36
+ type: "tool_call",
37
+ item: event.item,
38
+ };
39
+ }
40
+ continue;
41
+ }
42
+ if (event.item.type === "tool_call_output_item") {
43
+ if (options?.emitToolOutputs) {
44
+ const toolCall = toolCallsById.get(event.item.callId);
45
+ yield {
46
+ type: "tool_output",
47
+ item: event.item,
48
+ output: event.item.output,
49
+ ...(toolCall ? { toolCall } : {}),
50
+ };
51
+ }
52
+ continue;
53
+ }
54
+ finalOutput = event.item.content;
55
+ }
56
+ const history = [...result.history];
57
+ yield {
58
+ type: "completed",
59
+ finalOutput,
60
+ history,
61
+ lastAgent: result.lastAgent,
62
+ toolCalls: (0, run_record_utils_1.extractToolCalls)(history),
63
+ };
64
+ }
package/dist/run.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAuChC,OAAO,EACL,cAAc,EAEd,mBAAmB,EAGnB,SAAS,EACT,cAAc,EACd,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAUjB,KAAK,eAAe,CAAC,QAAQ,IAAI;IAC/B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC5B,CAAC;AAGF,YAAY,EACV,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAswB3B,qBAAa,iBAAiB,CAAC,QAAQ,GAAG,OAAO;IAC/C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAA0C;IACxD,OAAO,CAAC,KAAK,CAA4B;gBAGvC,MAAM,EAAE,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,EAC/C,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC;IAMlC,QAAQ,IAAI,aAAa,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAQnD,IAAI,OAAO,IAAI,cAAc,EAAE,CAE9B;IAED,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,CAE/B;CACF;AAED,wBAAsB,GAAG,CAAC,QAAQ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ED,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,CAE/B;CACF;AAED,wBAAsB,GAAG,CAAC,QAAQ,GAAG,OAAO,EAC1C,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,EAC9B,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,EAChC,OAAO,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAClC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAExC,wBAAsB,GAAG,CAAC,QAAQ,GAAG,OAAO,EAC1C,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,EAC9B,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,EAChC,OAAO,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,GACtC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC"}
package/dist/run.js CHANGED
@@ -124,10 +124,16 @@ function isPolicyResultShape(value) {
124
124
  validResultMode &&
125
125
  validExpiresAt);
126
126
  }
127
- // TODO: Remove this beta-only migration guard before stable.
128
- function hasLegacyDenyMode(value) {
127
+ function hasDeprecatedDenyMode(value) {
129
128
  return typeof value === "object" && value !== null && "denyMode" in value;
130
129
  }
130
+ function createDeprecatedDenyModeResult(receivedValue) {
131
+ return (0, policy_outcomes_1.createDeniedPolicyResult)("deprecated_policy_field_denyMode", {
132
+ deprecatedField: "denyMode",
133
+ replacementField: "resultMode",
134
+ receivedValue,
135
+ });
136
+ }
131
137
  async function emitPolicyDecision(params) {
132
138
  const { agentName, turn, callId, policyResult, logEmitter, onPolicyDecision, } = params;
133
139
  const resultMode = policyResult.decision === "allow"
@@ -195,8 +201,8 @@ async function evaluateToolPolicy(agent, call, parsedArguments, runContext, turn
195
201
  catch (error) {
196
202
  return (0, policy_outcomes_1.createDeniedPolicyResult)("policy_error", toErrorMetadata(error));
197
203
  }
198
- if (hasLegacyDenyMode(rawResult)) {
199
- return (0, policy_outcomes_1.createDeprecatedPolicyFieldResult)("denyMode", "resultMode", rawResult.denyMode);
204
+ if (hasDeprecatedDenyMode(rawResult)) {
205
+ return createDeprecatedDenyModeResult(rawResult.denyMode);
200
206
  }
201
207
  if (!isPolicyResultShape(rawResult)) {
202
208
  return (0, policy_outcomes_1.createDeniedPolicyResult)("invalid_policy_result");
@@ -228,8 +234,8 @@ async function evaluateHandoffPolicy(fromAgent, toAgent, call, handoffPayload, r
228
234
  catch (error) {
229
235
  return (0, policy_outcomes_1.createDeniedPolicyResult)("policy_error", toErrorMetadata(error));
230
236
  }
231
- if (hasLegacyDenyMode(rawResult)) {
232
- return (0, policy_outcomes_1.createDeprecatedPolicyFieldResult)("denyMode", "resultMode", rawResult.denyMode);
237
+ if (hasDeprecatedDenyMode(rawResult)) {
238
+ return createDeprecatedDenyModeResult(rawResult.denyMode);
233
239
  }
234
240
  if (!isPolicyResultShape(rawResult)) {
235
241
  return (0, policy_outcomes_1.createDeniedPolicyResult)("invalid_policy_result");
@@ -0,0 +1,10 @@
1
+ import type { AgentInputItem, RunResult } from "./types";
2
+ export interface ThreadHistoryState {
3
+ history: AgentInputItem[];
4
+ }
5
+ export type RunHistorySource<TContext = unknown> = Pick<RunResult<TContext>, "history">;
6
+ export declare function toThreadHistory(input: string | readonly AgentInputItem[]): AgentInputItem[];
7
+ export declare function appendUserMessage(history: readonly AgentInputItem[], content: string): AgentInputItem[];
8
+ export declare function replaceThreadHistory<TThread extends ThreadHistoryState>(thread: TThread, history: readonly AgentInputItem[]): TThread;
9
+ export declare function applyRunResultHistory<TContext, TThread extends ThreadHistoryState>(thread: TThread, result: RunHistorySource<TContext>): TThread;
10
+ //# sourceMappingURL=thread-history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-history.d.ts","sourceRoot":"","sources":["../src/thread-history.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,gBAAgB,CAAC,QAAQ,GAAG,OAAO,IAAI,IAAI,CACrD,SAAS,CAAC,QAAQ,CAAC,EACnB,SAAS,CACV,CAAC;AAEF,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,GACxC,cAAc,EAAE,CAMlB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,OAAO,EAAE,MAAM,GACd,cAAc,EAAE,CAElB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,kBAAkB,EACrE,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,SAAS,cAAc,EAAE,GACjC,OAAO,CAKT;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EACR,OAAO,SAAS,kBAAkB,EAClC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GAAG,OAAO,CAE9D"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toThreadHistory = toThreadHistory;
4
+ exports.appendUserMessage = appendUserMessage;
5
+ exports.replaceThreadHistory = replaceThreadHistory;
6
+ exports.applyRunResultHistory = applyRunResultHistory;
7
+ const messages_1 = require("./messages");
8
+ function toThreadHistory(input) {
9
+ if (typeof input === "string") {
10
+ return [(0, messages_1.user)(input)];
11
+ }
12
+ return [...input];
13
+ }
14
+ function appendUserMessage(history, content) {
15
+ return [...history, (0, messages_1.user)(content)];
16
+ }
17
+ function replaceThreadHistory(thread, history) {
18
+ return {
19
+ ...thread,
20
+ history: [...history],
21
+ };
22
+ }
23
+ function applyRunResultHistory(thread, result) {
24
+ return replaceThreadHistory(thread, result.history);
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiastudio/aioc",
3
- "version": "0.1.0-rc.1",
3
+ "version": "0.2.0-next.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -22,6 +22,7 @@
22
22
  "example:approval-required": "tsx src/examples/basic/approval-required.ts",
23
23
  "example:approval-evidence": "tsx src/examples/basic/approval-evidence.ts",
24
24
  "example:tool-policy": "tsx src/examples/basic/tools.ts",
25
+ "example:harness": "tsx src/examples/harness-descriptor/customer-support.ts",
25
26
  "example:run-record": "tsx src/examples/basic/run-record-sink.ts",
26
27
  "example:rru:01-extract": "tsx src/examples/run-record-utils-minimal/01-extract-tool-calls.ts",
27
28
  "example:rru:02-compare": "tsx src/examples/run-record-utils-minimal/02-compare-run-records.ts",
@@ -69,11 +70,13 @@
69
70
  },
70
71
  "dependencies": {
71
72
  "dotenv": "^17.2.3",
73
+ "js-yaml": "^4.1.1",
72
74
  "zod": "^3.25.76",
73
75
  "zod-to-json-schema": "^3.24.6"
74
76
  },
75
77
  "devDependencies": {
76
78
  "@eslint/js": "^9.35.0",
79
+ "@types/js-yaml": "^4.0.9",
77
80
  "@types/node": "^22.15.3",
78
81
  "eslint": "^9.35.0",
79
82
  "eslint-config-prettier": "^10.1.8",