@uns-kit/assistant-workflow 2.0.73 → 2.0.77

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
@@ -20,12 +20,80 @@ pnpm add @uns-kit/assistant-workflow
20
20
  MCP, and controlled REPL integrations;
21
21
  - deterministic plan/run construction, execution queues, parity checks, and
22
22
  safe trace/report serialization;
23
+ - exact host-provided tool handoff selection, bound to a rebuilt invocation,
24
+ reviewed allowlist, and application-owned argument validator;
25
+ - versioned tool-evidence envelope parsing and exact invocation/call binding,
26
+ with application-owned data-schema validation;
23
27
  - definition packages, catalog loading, replay, evaluation, and review helpers.
24
28
 
25
29
  The package deliberately does not contain provider credentials, database access,
26
30
  HTTP transport, UNS-specific tool implementations, or application-specific
27
31
  workflow definitions.
28
32
 
33
+ ## Exact Tool Handoffs
34
+
35
+ When a host has rebuilt a workflow plan and wants to delegate exactly one
36
+ reviewed read-only tool, use `selectAssistantWorkflowApprovedToolInvocation`.
37
+ It does not infer arguments from assistant text or choose among broad tool
38
+ permissions: it binds one host-provided handoff to one invocation in the rebuilt
39
+ plan and rejects ambiguous handoffs.
40
+
41
+ ```ts
42
+ import { selectAssistantWorkflowApprovedToolInvocation } from "@uns-kit/assistant-workflow";
43
+
44
+ const approved = selectAssistantWorkflowApprovedToolInvocation({
45
+ invocations: rebuiltRun.toolInvocationQueue.invocations,
46
+ handoffs: [{
47
+ invocationId: "fetch_document:read_document",
48
+ toolName: "read_document",
49
+ args: { documentId: "manual-1" },
50
+ }],
51
+ policies: [{
52
+ toolName: "read_document",
53
+ normalizeArgs: (args) =>
54
+ typeof args.documentId === "string" && Object.keys(args).length === 1
55
+ ? { documentId: args.documentId }
56
+ : null,
57
+ }],
58
+ allowedToolNames: ["read_document"],
59
+ });
60
+
61
+ if (approved) {
62
+ // `approved.args` passed the application-owned exact argument contract.
63
+ }
64
+ ```
65
+
66
+ Tool schemas remain application-owned. The caller must pass only the exact
67
+ controller/host handoff that it already reviewed; multiple handoffs or multiple
68
+ matching policies return `null`.
69
+
70
+ ## Tool Evidence
71
+
72
+ `tool-evidence` validates the generic envelope and its binding to an approved
73
+ invocation. Applications choose the format/version and own `data` validation;
74
+ the package does not interpret database rows, protocol payloads, or tool-specific
75
+ arguments.
76
+
77
+ ```ts
78
+ import {
79
+ matchesAssistantWorkflowToolEvidenceBinding,
80
+ parseAssistantWorkflowToolEvidence,
81
+ } from "@uns-kit/assistant-workflow/tool-evidence";
82
+
83
+ const evidence = parseAssistantWorkflowToolEvidence(rawEvidence, {
84
+ format: "example.tool-evidence",
85
+ formatVersion: 1,
86
+ parseData: (value) => isMyApplicationData(value) ? value : null,
87
+ });
88
+
89
+ const matches = evidence && matchesAssistantWorkflowToolEvidenceBinding(evidence, {
90
+ invocationId: approved.invocation.id,
91
+ toolName: approved.invocation.toolName,
92
+ callId,
93
+ expiresAt: delegation.expiresAt,
94
+ });
95
+ ```
96
+
29
97
  ## Development
30
98
 
31
99
  ```bash
package/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ export * from "./run-report.js";
50
50
  export * from "./run-report-batch.js";
51
51
  export * from "./run-report-json.js";
52
52
  export * from "./tool-invocations.js";
53
+ export * from "./tool-handoffs.js";
53
54
  export * from "./tool-provider-executors.js";
54
55
  export * from "./tool-result-cache.js";
55
56
  export * from "./tool-runtime.js";
@@ -68,6 +69,7 @@ export * from "./trace-replay.js";
68
69
  export * from "./tool-bindings.js";
69
70
  export * from "./tool-capabilities.js";
70
71
  export * from "./tool-executor.js";
72
+ export * from "./tool-evidence.js";
71
73
  export * from "./tool-fixtures.js";
72
74
  export * from "./value-readers.js";
73
75
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,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B,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -50,6 +50,7 @@ export * from "./run-report.js";
50
50
  export * from "./run-report-batch.js";
51
51
  export * from "./run-report-json.js";
52
52
  export * from "./tool-invocations.js";
53
+ export * from "./tool-handoffs.js";
53
54
  export * from "./tool-provider-executors.js";
54
55
  export * from "./tool-result-cache.js";
55
56
  export * from "./tool-runtime.js";
@@ -68,6 +69,7 @@ export * from "./trace-replay.js";
68
69
  export * from "./tool-bindings.js";
69
70
  export * from "./tool-capabilities.js";
70
71
  export * from "./tool-executor.js";
72
+ export * from "./tool-evidence.js";
71
73
  export * from "./tool-fixtures.js";
72
74
  export * from "./value-readers.js";
73
75
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,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mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./clarification-policy.js\";\nexport * from \"./decision.js\";\nexport * from \"./definition.js\";\nexport * from \"./definition-catalog.js\";\nexport * from \"./definition-catalog-replay.js\";\nexport * from \"./definition-diagnostics.js\";\nexport * from \"./definition-diff.js\";\nexport * from \"./definition-json.js\";\nexport * from \"./definition-manifest.js\";\nexport * from \"./definition-package.js\";\nexport * from \"./definition-package-executor.js\";\nexport * from \"./definition-package-execution-json.js\";\nexport * from \"./definition-package-execution-replay.js\";\nexport * from \"./definition-package-loader.js\";\nexport * from \"./definition-package-resolver.js\";\nexport * from \"./definition-package-review.js\";\nexport * from \"./definition-package-replay.js\";\nexport * from \"./definition-package-run.js\";\nexport * from \"./definition-package-run-report.js\";\nexport * from \"./definition-package-selection.js\";\nexport * from \"./definition-package-smoke.js\";\nexport * from \"./definition-tuning.js\";\nexport * from \"./definition-tuning-approval.js\";\nexport * from \"./definition-tuning-json.js\";\nexport * from \"./definition-tuning-promotion.js\";\nexport * from \"./definition-tuning-replay.js\";\nexport * from \"./definition-tuning-review.js\";\nexport * from \"./definition-tuning-review-artifact.js\";\nexport * from \"./definition-tuning-source-patch.js\";\nexport * from \"./direct-route-invocation.js\";\nexport * from \"./direct-route-policy.js\";\nexport * from \"./eval-case.js\";\nexport * from \"./eval-replay.js\";\nexport * from \"./eval-result.js\";\nexport * from \"./eval-runner.js\";\nexport * from \"./eval-suite.js\";\nexport * from \"./execution-plan.js\";\nexport * from \"./hosted-tool-policy.js\";\nexport * from \"./memory-policy.js\";\nexport * from \"./memory-updates.js\";\nexport * from \"./outcome.js\";\nexport * from \"./outcome-trace.js\";\nexport * from \"./policy-resolution.js\";\nexport * from \"./planner-compiler.js\";\nexport * from \"./planning.js\";\nexport * from \"./run.js\";\nexport * from \"./run-parity.js\";\nexport * from \"./run-evaluation.js\";\nexport * from \"./run-report.js\";\nexport * from \"./run-report-batch.js\";\nexport * from \"./run-report-json.js\";\nexport * from \"./tool-invocations.js\";\nexport * from \"./tool-provider-executors.js\";\nexport * from \"./tool-result-cache.js\";\nexport * from \"./tool-runtime.js\";\nexport * from \"./tool-selection-evaluation.js\";\nexport * from \"./tool-selection-json.js\";\nexport * from \"./tool-selection-policy.js\";\nexport * from \"./tool-selection-rules.js\";\nexport * from \"./tool-selection-replay.js\";\nexport * from \"./tool-selection-trace-export.js\";\nexport * from \"./tool-results.js\";\nexport * from \"./trace-events.js\";\nexport * from \"./trace-payload.js\";\nexport * from \"./trace-stages.js\";\nexport * from \"./trace-report.js\";\nexport * from \"./trace-replay.js\";\nexport * from \"./tool-bindings.js\";\nexport * from \"./tool-capabilities.js\";\nexport * from \"./tool-executor.js\";\nexport * from \"./tool-fixtures.js\";\nexport * from \"./value-readers.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cA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AmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./clarification-policy.js\";\nexport * from \"./decision.js\";\nexport * from \"./definition.js\";\nexport * from \"./definition-catalog.js\";\nexport * from \"./definition-catalog-replay.js\";\nexport * from \"./definition-diagnostics.js\";\nexport * from \"./definition-diff.js\";\nexport * from \"./definition-json.js\";\nexport * from \"./definition-manifest.js\";\nexport * from \"./definition-package.js\";\nexport * from \"./definition-package-executor.js\";\nexport * from \"./definition-package-execution-json.js\";\nexport * from \"./definition-package-execution-replay.js\";\nexport * from \"./definition-package-loader.js\";\nexport * from \"./definition-package-resolver.js\";\nexport * from \"./definition-package-review.js\";\nexport * from \"./definition-package-replay.js\";\nexport * from \"./definition-package-run.js\";\nexport * from \"./definition-package-run-report.js\";\nexport * from \"./definition-package-selection.js\";\nexport * from \"./definition-package-smoke.js\";\nexport * from \"./definition-tuning.js\";\nexport * from \"./definition-tuning-approval.js\";\nexport * from \"./definition-tuning-json.js\";\nexport * from \"./definition-tuning-promotion.js\";\nexport * from \"./definition-tuning-replay.js\";\nexport * from \"./definition-tuning-review.js\";\nexport * from \"./definition-tuning-review-artifact.js\";\nexport * from \"./definition-tuning-source-patch.js\";\nexport * from \"./direct-route-invocation.js\";\nexport * from \"./direct-route-policy.js\";\nexport * from \"./eval-case.js\";\nexport * from \"./eval-replay.js\";\nexport * from \"./eval-result.js\";\nexport * from \"./eval-runner.js\";\nexport * from \"./eval-suite.js\";\nexport * from \"./execution-plan.js\";\nexport * from \"./hosted-tool-policy.js\";\nexport * from \"./memory-policy.js\";\nexport * from \"./memory-updates.js\";\nexport * from \"./outcome.js\";\nexport * from \"./outcome-trace.js\";\nexport * from \"./policy-resolution.js\";\nexport * from \"./planner-compiler.js\";\nexport * from \"./planning.js\";\nexport * from \"./run.js\";\nexport * from \"./run-parity.js\";\nexport * from \"./run-evaluation.js\";\nexport * from \"./run-report.js\";\nexport * from \"./run-report-batch.js\";\nexport * from \"./run-report-json.js\";\nexport * from \"./tool-invocations.js\";\nexport * from \"./tool-handoffs.js\";\nexport * from \"./tool-provider-executors.js\";\nexport * from \"./tool-result-cache.js\";\nexport * from \"./tool-runtime.js\";\nexport * from \"./tool-selection-evaluation.js\";\nexport * from \"./tool-selection-json.js\";\nexport * from \"./tool-selection-policy.js\";\nexport * from \"./tool-selection-rules.js\";\nexport * from \"./tool-selection-replay.js\";\nexport * from \"./tool-selection-trace-export.js\";\nexport * from \"./tool-results.js\";\nexport * from \"./trace-events.js\";\nexport * from \"./trace-payload.js\";\nexport * from \"./trace-stages.js\";\nexport * from \"./trace-report.js\";\nexport * from \"./trace-replay.js\";\nexport * from \"./tool-bindings.js\";\nexport * from \"./tool-capabilities.js\";\nexport * from \"./tool-executor.js\";\nexport * from \"./tool-evidence.js\";\nexport * from \"./tool-fixtures.js\";\nexport * from \"./value-readers.js\";\n"]}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Provider- and transport-neutral envelope for a tool result that may be used
3
+ * as controlled evidence by a later response-synthesis step. Applications own
4
+ * the format string and validate their domain-specific `data` payload.
5
+ */
6
+ export type AssistantWorkflowToolEvidenceEnvelope<TData = unknown> = {
7
+ format: string;
8
+ formatVersion: number;
9
+ invocationId: string;
10
+ toolName: string;
11
+ callId: string;
12
+ issuedAt: string;
13
+ expiresAt: string;
14
+ data: TData;
15
+ };
16
+ export type AssistantWorkflowToolEvidenceContract = {
17
+ format: string;
18
+ formatVersion: number;
19
+ toolNames: readonly string[];
20
+ };
21
+ export type AssistantWorkflowToolEvidenceBinding = {
22
+ invocationId: string;
23
+ toolName: string;
24
+ callId: string;
25
+ expiresAt: string;
26
+ };
27
+ export type ParseAssistantWorkflowToolEvidenceOptions<TData> = {
28
+ format: string;
29
+ formatVersion: number;
30
+ parseData: (value: unknown) => TData | null;
31
+ };
32
+ /**
33
+ * Parses the generic envelope and delegates data validation to the application.
34
+ * The package deliberately does not infer or normalize application result data.
35
+ */
36
+ export declare function parseAssistantWorkflowToolEvidence<TData>(value: unknown, options: ParseAssistantWorkflowToolEvidenceOptions<TData>): AssistantWorkflowToolEvidenceEnvelope<TData> | null;
37
+ /**
38
+ * Checks that the evidence came from the exact invocation/call delegated by the
39
+ * host. Domain-specific argument-to-data checks remain application-owned.
40
+ */
41
+ export declare function matchesAssistantWorkflowToolEvidenceBinding(evidence: AssistantWorkflowToolEvidenceEnvelope, binding: AssistantWorkflowToolEvidenceBinding, nowMs?: number): boolean;
42
+ export declare function supportsAssistantWorkflowToolEvidence(contract: AssistantWorkflowToolEvidenceContract | null | undefined, toolName: string): boolean;
43
+ //# sourceMappingURL=tool-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-evidence.d.ts","sourceRoot":"","sources":["../src/tool-evidence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,qCAAqC,CAAC,KAAK,GAAG,OAAO,IAAI;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,yCAAyC,CAAC,KAAK,IAAI;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,GAAG,IAAI,CAAC;CAC7C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EACtD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,yCAAyC,CAAC,KAAK,CAAC,GACxD,qCAAqC,CAAC,KAAK,CAAC,GAAG,IAAI,CAyBrD;AAED;;;GAGG;AACH,wBAAgB,2CAA2C,CACzD,QAAQ,EAAE,qCAAqC,EAC/C,OAAO,EAAE,oCAAoC,EAC7C,KAAK,SAAa,GACjB,OAAO,CAMT;AAED,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,qCAAqC,GAAG,IAAI,GAAG,SAAS,EAClE,QAAQ,EAAE,MAAM,GACf,OAAO,CAWT"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Parses the generic envelope and delegates data validation to the application.
3
+ * The package deliberately does not infer or normalize application result data.
4
+ */
5
+ export function parseAssistantWorkflowToolEvidence(value, options) {
6
+ if (!isRecord(value))
7
+ return null;
8
+ const format = normalizeFormat(value["format"]);
9
+ const formatVersion = value["formatVersion"];
10
+ const invocationId = normalizeIdentifier(value["invocationId"]);
11
+ const toolName = normalizeToolName(value["toolName"]);
12
+ const callId = normalizeIdentifier(value["callId"]);
13
+ const issuedAt = normalizeTimestamp(value["issuedAt"]);
14
+ const expiresAt = normalizeTimestamp(value["expiresAt"]);
15
+ if (format !== options.format ||
16
+ formatVersion !== options.formatVersion ||
17
+ !invocationId ||
18
+ !toolName ||
19
+ !callId ||
20
+ !issuedAt ||
21
+ !expiresAt ||
22
+ Date.parse(issuedAt) > Date.parse(expiresAt)) {
23
+ return null;
24
+ }
25
+ const data = options.parseData(value["data"]);
26
+ return data === null
27
+ ? null
28
+ : { format, formatVersion, invocationId, toolName, callId, issuedAt, expiresAt, data };
29
+ }
30
+ /**
31
+ * Checks that the evidence came from the exact invocation/call delegated by the
32
+ * host. Domain-specific argument-to-data checks remain application-owned.
33
+ */
34
+ export function matchesAssistantWorkflowToolEvidenceBinding(evidence, binding, nowMs = Date.now()) {
35
+ return evidence.invocationId === binding.invocationId &&
36
+ evidence.toolName === binding.toolName &&
37
+ evidence.callId === binding.callId &&
38
+ evidence.expiresAt === binding.expiresAt &&
39
+ Date.parse(evidence.expiresAt) > nowMs;
40
+ }
41
+ export function supportsAssistantWorkflowToolEvidence(contract, toolName) {
42
+ const normalizedToolName = normalizeToolName(toolName);
43
+ return Boolean(contract &&
44
+ normalizeFormat(contract.format) === contract.format &&
45
+ Number.isInteger(contract.formatVersion) &&
46
+ contract.formatVersion >= 1 &&
47
+ normalizedToolName &&
48
+ Array.isArray(contract.toolNames) &&
49
+ contract.toolNames.some((candidate) => normalizeToolName(candidate) === normalizedToolName));
50
+ }
51
+ function normalizeFormat(value) {
52
+ const format = typeof value === "string" ? value.trim() : "";
53
+ return format && format.length <= 160 ? format : null;
54
+ }
55
+ function normalizeIdentifier(value) {
56
+ return typeof value === "string" && /^[a-zA-Z0-9._:-]{1,200}$/.test(value) ? value : null;
57
+ }
58
+ function normalizeToolName(value) {
59
+ return typeof value === "string" && /^[a-zA-Z0-9_:-]{1,160}$/.test(value) ? value : null;
60
+ }
61
+ function normalizeTimestamp(value) {
62
+ return typeof value === "string" && Number.isFinite(Date.parse(value)) ? value : null;
63
+ }
64
+ function isRecord(value) {
65
+ return typeof value === "object" && value !== null && !Array.isArray(value);
66
+ }
67
+ //# sourceMappingURL=tool-evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-evidence.js","sourceRoot":"","sources":["../src/tool-evidence.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CAChD,KAAc,EACd,OAAyD;IAEzD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAA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AAC;AAC5F,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3F,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACxF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["/**\n * Provider- and transport-neutral envelope for a tool result that may be used\n * as controlled evidence by a later response-synthesis step. Applications own\n * the format string and validate their domain-specific `data` payload.\n */\nexport type AssistantWorkflowToolEvidenceEnvelope<TData = unknown> = {\n format: string;\n formatVersion: number;\n invocationId: string;\n toolName: string;\n callId: string;\n issuedAt: string;\n expiresAt: string;\n data: TData;\n};\n\nexport type AssistantWorkflowToolEvidenceContract = {\n format: string;\n formatVersion: number;\n toolNames: readonly string[];\n};\n\nexport type AssistantWorkflowToolEvidenceBinding = {\n invocationId: string;\n toolName: string;\n callId: string;\n expiresAt: string;\n};\n\nexport type ParseAssistantWorkflowToolEvidenceOptions<TData> = {\n format: string;\n formatVersion: number;\n parseData: (value: unknown) => TData | null;\n};\n\n/**\n * Parses the generic envelope and delegates data validation to the application.\n * The package deliberately does not infer or normalize application result data.\n */\nexport function parseAssistantWorkflowToolEvidence<TData>(\n value: unknown,\n options: ParseAssistantWorkflowToolEvidenceOptions<TData>,\n): AssistantWorkflowToolEvidenceEnvelope<TData> | null {\n if (!isRecord(value)) return null;\n const format = normalizeFormat(value[\"format\"]);\n const formatVersion = value[\"formatVersion\"];\n const invocationId = normalizeIdentifier(value[\"invocationId\"]);\n const toolName = normalizeToolName(value[\"toolName\"]);\n const callId = normalizeIdentifier(value[\"callId\"]);\n const issuedAt = normalizeTimestamp(value[\"issuedAt\"]);\n const expiresAt = normalizeTimestamp(value[\"expiresAt\"]);\n if (\n format !== options.format ||\n formatVersion !== options.formatVersion ||\n !invocationId ||\n !toolName ||\n !callId ||\n !issuedAt ||\n !expiresAt ||\n Date.parse(issuedAt) > Date.parse(expiresAt)\n ) {\n return null;\n }\n const data = options.parseData(value[\"data\"]);\n return data === null\n ? null\n : { format, formatVersion, invocationId, toolName, callId, issuedAt, expiresAt, data };\n}\n\n/**\n * Checks that the evidence came from the exact invocation/call delegated by the\n * host. Domain-specific argument-to-data checks remain application-owned.\n */\nexport function matchesAssistantWorkflowToolEvidenceBinding(\n evidence: AssistantWorkflowToolEvidenceEnvelope,\n binding: AssistantWorkflowToolEvidenceBinding,\n nowMs = Date.now(),\n): boolean {\n return evidence.invocationId === binding.invocationId &&\n evidence.toolName === binding.toolName &&\n evidence.callId === binding.callId &&\n evidence.expiresAt === binding.expiresAt &&\n Date.parse(evidence.expiresAt) > nowMs;\n}\n\nexport function supportsAssistantWorkflowToolEvidence(\n contract: AssistantWorkflowToolEvidenceContract | null | undefined,\n toolName: string,\n): boolean {\n const normalizedToolName = normalizeToolName(toolName);\n return Boolean(\n contract &&\n normalizeFormat(contract.format) === contract.format &&\n Number.isInteger(contract.formatVersion) &&\n contract.formatVersion >= 1 &&\n normalizedToolName &&\n Array.isArray(contract.toolNames) &&\n contract.toolNames.some((candidate) => normalizeToolName(candidate) === normalizedToolName),\n );\n}\n\nfunction normalizeFormat(value: unknown): string | null {\n const format = typeof value === \"string\" ? value.trim() : \"\";\n return format && format.length <= 160 ? format : null;\n}\n\nfunction normalizeIdentifier(value: unknown): string | null {\n return typeof value === \"string\" && /^[a-zA-Z0-9._:-]{1,200}$/.test(value) ? value : null;\n}\n\nfunction normalizeToolName(value: unknown): string | null {\n return typeof value === \"string\" && /^[a-zA-Z0-9_:-]{1,160}$/.test(value) ? value : null;\n}\n\nfunction normalizeTimestamp(value: unknown): string | null {\n return typeof value === \"string\" && Number.isFinite(Date.parse(value)) ? value : null;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import type { AssistantWorkflowToolInvocation } from "./tool-invocations.js";
2
+ export type AssistantWorkflowToolInvocationHandoffArgs = Readonly<Record<string, unknown>>;
3
+ /**
4
+ * Controller or host-provided arguments for one exact invocation in a rebuilt
5
+ * workflow plan. The runtime must never derive a handoff from model text.
6
+ */
7
+ export type AssistantWorkflowToolInvocationHandoff = {
8
+ invocationId: string;
9
+ toolName: string;
10
+ args: AssistantWorkflowToolInvocationHandoffArgs;
11
+ };
12
+ /**
13
+ * Application-owned validation for a reviewed, explicitly handed-off tool.
14
+ * Keeping this as a function lets each application enforce its own precise
15
+ * argument contract without the workflow package owning tool schemas.
16
+ */
17
+ export type AssistantWorkflowToolInvocationHandoffPolicy = {
18
+ toolName: string;
19
+ normalizeArgs: (args: AssistantWorkflowToolInvocationHandoffArgs) => AssistantWorkflowToolInvocationHandoffArgs | null;
20
+ };
21
+ export type AssistantWorkflowApprovedToolInvocation<TPolicy extends AssistantWorkflowToolInvocationHandoffPolicy = AssistantWorkflowToolInvocationHandoffPolicy> = {
22
+ policy: TPolicy;
23
+ invocation: AssistantWorkflowToolInvocation;
24
+ args: AssistantWorkflowToolInvocationHandoffArgs;
25
+ };
26
+ export type SelectAssistantWorkflowApprovedToolInvocationInput<TPolicy extends AssistantWorkflowToolInvocationHandoffPolicy = AssistantWorkflowToolInvocationHandoffPolicy> = {
27
+ invocations: readonly AssistantWorkflowToolInvocation[];
28
+ handoffs: readonly AssistantWorkflowToolInvocationHandoff[];
29
+ policies: readonly TPolicy[];
30
+ allowedToolNames: readonly string[];
31
+ };
32
+ /**
33
+ * Selects one exact, allowlisted invocation from a rebuilt workflow plan.
34
+ *
35
+ * This intentionally accepts exactly one controller/host handoff. Multiple
36
+ * records are rejected rather than silently ignoring broader authorization.
37
+ * Argument validation remains application-owned through the supplied policy.
38
+ */
39
+ export declare function selectAssistantWorkflowApprovedToolInvocation<TPolicy extends AssistantWorkflowToolInvocationHandoffPolicy>(input: SelectAssistantWorkflowApprovedToolInvocationInput<TPolicy>): AssistantWorkflowApprovedToolInvocation<TPolicy> | null;
40
+ //# sourceMappingURL=tool-handoffs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-handoffs.d.ts","sourceRoot":"","sources":["../src/tool-handoffs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAE7E,MAAM,MAAM,0CAA0C,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE3F;;;GAGG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,0CAA0C,CAAC;CAClD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,4CAA4C,GAAG;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,CACb,IAAI,EAAE,0CAA0C,KAC7C,0CAA0C,GAAG,IAAI,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,uCAAuC,CACjD,OAAO,SAAS,4CAA4C,GAAG,4CAA4C,IACzG;IACF,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,+BAA+B,CAAC;IAC5C,IAAI,EAAE,0CAA0C,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,kDAAkD,CAC5D,OAAO,SAAS,4CAA4C,GAAG,4CAA4C,IACzG;IACF,WAAW,EAAE,SAAS,+BAA+B,EAAE,CAAC;IACxD,QAAQ,EAAE,SAAS,sCAAsC,EAAE,CAAC;IAC5D,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAC7B,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,6CAA6C,CAC3D,OAAO,SAAS,4CAA4C,EAE5D,KAAK,EAAE,kDAAkD,CAAC,OAAO,CAAC,GACjE,uCAAuC,CAAC,OAAO,CAAC,GAAG,IAAI,CAgBzD"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Selects one exact, allowlisted invocation from a rebuilt workflow plan.
3
+ *
4
+ * This intentionally accepts exactly one controller/host handoff. Multiple
5
+ * records are rejected rather than silently ignoring broader authorization.
6
+ * Argument validation remains application-owned through the supplied policy.
7
+ */
8
+ export function selectAssistantWorkflowApprovedToolInvocation(input) {
9
+ if (input.handoffs.length !== 1)
10
+ return null;
11
+ const allowedToolNames = new Set(input.allowedToolNames);
12
+ const approved = [];
13
+ for (const policy of input.policies) {
14
+ if (!allowedToolNames.has(policy.toolName))
15
+ continue;
16
+ for (const invocation of input.invocations) {
17
+ if (invocation.toolName !== policy.toolName)
18
+ continue;
19
+ const handoff = findExactHandoff(input.handoffs, invocation);
20
+ if (!handoff)
21
+ continue;
22
+ const args = policy.normalizeArgs(handoff.args);
23
+ if (args)
24
+ approved.push({ policy, invocation, args });
25
+ }
26
+ }
27
+ return approved.length === 1 ? approved[0] ?? null : null;
28
+ }
29
+ function findExactHandoff(handoffs, invocation) {
30
+ const matches = handoffs.filter((handoff) => handoff.invocationId === invocation.id && handoff.toolName === invocation.toolName);
31
+ return matches.length === 1 ? matches[0] ?? null : null;
32
+ }
33
+ //# sourceMappingURL=tool-handoffs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-handoffs.js","sourceRoot":"","sources":["../src/tool-handoffs.ts"],"names":[],"mappings":"AA2CA;;;;;;GAMG;AACH,MAAM,UAAU,6CAA6C,CA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AC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC","sourcesContent":["import type { AssistantWorkflowToolInvocation } from \"./tool-invocations.js\";\n\nexport type AssistantWorkflowToolInvocationHandoffArgs = Readonly<Record<string, unknown>>;\n\n/**\n * Controller or host-provided arguments for one exact invocation in a rebuilt\n * workflow plan. The runtime must never derive a handoff from model text.\n */\nexport type AssistantWorkflowToolInvocationHandoff = {\n invocationId: string;\n toolName: string;\n args: AssistantWorkflowToolInvocationHandoffArgs;\n};\n\n/**\n * Application-owned validation for a reviewed, explicitly handed-off tool.\n * Keeping this as a function lets each application enforce its own precise\n * argument contract without the workflow package owning tool schemas.\n */\nexport type AssistantWorkflowToolInvocationHandoffPolicy = {\n toolName: string;\n normalizeArgs: (\n args: AssistantWorkflowToolInvocationHandoffArgs,\n ) => AssistantWorkflowToolInvocationHandoffArgs | null;\n};\n\nexport type AssistantWorkflowApprovedToolInvocation<\n TPolicy extends AssistantWorkflowToolInvocationHandoffPolicy = AssistantWorkflowToolInvocationHandoffPolicy,\n> = {\n policy: TPolicy;\n invocation: AssistantWorkflowToolInvocation;\n args: AssistantWorkflowToolInvocationHandoffArgs;\n};\n\nexport type SelectAssistantWorkflowApprovedToolInvocationInput<\n TPolicy extends AssistantWorkflowToolInvocationHandoffPolicy = AssistantWorkflowToolInvocationHandoffPolicy,\n> = {\n invocations: readonly AssistantWorkflowToolInvocation[];\n handoffs: readonly AssistantWorkflowToolInvocationHandoff[];\n policies: readonly TPolicy[];\n allowedToolNames: readonly string[];\n};\n\n/**\n * Selects one exact, allowlisted invocation from a rebuilt workflow plan.\n *\n * This intentionally accepts exactly one controller/host handoff. Multiple\n * records are rejected rather than silently ignoring broader authorization.\n * Argument validation remains application-owned through the supplied policy.\n */\nexport function selectAssistantWorkflowApprovedToolInvocation<\n TPolicy extends AssistantWorkflowToolInvocationHandoffPolicy,\n>(\n input: SelectAssistantWorkflowApprovedToolInvocationInput<TPolicy>,\n): AssistantWorkflowApprovedToolInvocation<TPolicy> | null {\n if (input.handoffs.length !== 1) return null;\n\n const allowedToolNames = new Set(input.allowedToolNames);\n const approved: AssistantWorkflowApprovedToolInvocation<TPolicy>[] = [];\n for (const policy of input.policies) {\n if (!allowedToolNames.has(policy.toolName)) continue;\n for (const invocation of input.invocations) {\n if (invocation.toolName !== policy.toolName) continue;\n const handoff = findExactHandoff(input.handoffs, invocation);\n if (!handoff) continue;\n const args = policy.normalizeArgs(handoff.args);\n if (args) approved.push({ policy, invocation, args });\n }\n }\n return approved.length === 1 ? approved[0] ?? null : null;\n}\n\nfunction findExactHandoff(\n handoffs: readonly AssistantWorkflowToolInvocationHandoff[],\n invocation: AssistantWorkflowToolInvocation,\n): AssistantWorkflowToolInvocationHandoff | null {\n const matches = handoffs.filter(\n (handoff) => handoff.invocationId === invocation.id && handoff.toolName === invocation.toolName,\n );\n return matches.length === 1 ? matches[0] ?? null : null;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/assistant-workflow",
3
- "version": "2.0.73",
3
+ "version": "2.0.77",
4
4
  "description": "Typed, provider-neutral workflow definitions, policies, execution plans, and trace helpers for assistants.",
5
5
  "author": "Aljosa Vister",
6
6
  "license": "MIT",
@@ -245,6 +245,10 @@
245
245
  "types": "./dist/tool-executor.d.ts",
246
246
  "default": "./dist/tool-executor.js"
247
247
  },
248
+ "./tool-evidence": {
249
+ "types": "./dist/tool-evidence.d.ts",
250
+ "default": "./dist/tool-evidence.js"
251
+ },
248
252
  "./tool-fixtures": {
249
253
  "types": "./dist/tool-fixtures.d.ts",
250
254
  "default": "./dist/tool-fixtures.js"
@@ -253,6 +257,10 @@
253
257
  "types": "./dist/tool-invocations.d.ts",
254
258
  "default": "./dist/tool-invocations.js"
255
259
  },
260
+ "./tool-handoffs": {
261
+ "types": "./dist/tool-handoffs.d.ts",
262
+ "default": "./dist/tool-handoffs.js"
263
+ },
256
264
  "./tool-provider-executors": {
257
265
  "types": "./dist/tool-provider-executors.d.ts",
258
266
  "default": "./dist/tool-provider-executors.js"