@axiastudio/aioc 0.1.0-rc.1 → 0.1.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,16 @@ 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
+ Current stable release: `0.1.1`.
12
+ AIOC is stable as of `0.1.0`.
13
+ The core runtime surface is compatibility-managed. Breaking changes to the stable surface should ship only with explicit migration guidance and release notes.
13
14
 
14
- ### What Stable Means
15
+ ### Stable Scope
15
16
 
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.
17
+ AIOC `0.1.0` stabilized 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.
18
+ AIOC `0.1.1` adds thread-history utilities, the run-output stream adapter, and provider-specific instruction-role documentation without changing the stable governance model.
17
19
 
20
+ - Release notes: `CHANGELOG.md`
18
21
  - Historical beta contract snapshot: `docs/BETA-CONTRACT.md`
19
22
  - Historical alpha contract snapshot: `docs/ALPHA-CONTRACT.md`
20
23
  - Privacy baseline: `docs/PRIVACY-BASELINE.md`
@@ -96,7 +99,9 @@ console.log(result.finalOutput);
96
99
  - provider setup helpers `setupMistral(...)`, `setupOpenAI(...)`, `setupProvider(...)`
97
100
  - run logger hook `run(..., { logger })`
98
101
  - run record hook `run(..., { record })`
102
+ - run output adapter `toRunOutputEvents(...)`
99
103
  - run-record utilities `extractToolCalls(...)`, `compareRunRecords(...)`, `replayFromRunRecord(...)`
104
+ - thread history utilities `toThreadHistory(...)`, `appendUserMessage(...)`, `replaceThreadHistory(...)`, `applyRunResultHistory(...)`
100
105
  - JSON helper `toJsonValue(...)`
101
106
 
102
107
  ## Policy Gate (Minimal)
@@ -258,7 +263,10 @@ AIOC adopts the following non-negotiable principles:
258
263
  - `docs/RFC-0002-policy-gates-for-tools-and-handoffs.md` (`Accepted`)
259
264
  - `docs/RFC-0003-run-record-audit-trail-and-persistence.md` (`Accepted`)
260
265
  - `docs/RFC-0004-policy-outcomes-and-approval-model.md` (`Accepted`)
261
- - `docs/RFC-0005-suspended-proposals-and-approval-lifecycle.md` (`Draft`)
266
+ - `docs/RFC-0005-suspended-proposals-and-approval-lifecycle.md` (`Accepted`)
267
+ - `docs/RFC-0006-approval-evidence-helpers.md` (`Draft`)
268
+ - `docs/RFC-0007-thread-state-utilities.md` (`Accepted`)
269
+ - `docs/RFC-0008-run-stream-consumer-utilities.md` (`Accepted`)
262
270
  - `docs/PRIVACY-BASELINE.md`
263
271
 
264
272
  ## Historical Snapshots
package/dist/index.d.ts CHANGED
@@ -13,9 +13,11 @@ export * from "./providers/chat-completions";
13
13
  export * from "./providers/mistral";
14
14
  export * from "./providers/openai";
15
15
  export * from "./run";
16
+ export * from "./run-output-events";
16
17
  export * from "./run-record";
17
18
  export * from "./run-record-utils";
18
19
  export * from "./run-context";
20
+ export * from "./thread-history";
19
21
  export * from "./tool";
20
22
  export * from "./types";
21
23
  //# 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,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
@@ -29,8 +29,10 @@ __exportStar(require("./providers/chat-completions"), exports);
29
29
  __exportStar(require("./providers/mistral"), exports);
30
30
  __exportStar(require("./providers/openai"), exports);
31
31
  __exportStar(require("./run"), exports);
32
+ __exportStar(require("./run-output-events"), exports);
32
33
  __exportStar(require("./run-record"), exports);
33
34
  __exportStar(require("./run-record-utils"), exports);
34
35
  __exportStar(require("./run-context"), exports);
36
+ __exportStar(require("./thread-history"), exports);
35
37
  __exportStar(require("./tool"), exports);
36
38
  __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,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,YAAY,CAOd;AAED,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,EACxB,aAAa,CAAC,EAAE,OAAO,GACtB,YAAY,CAMd;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,CAC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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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AAc,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.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [