@dsh-enhanced/assistant-work-items 0.0.0-stage → 0.1.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +685 -2
  3. package/cordis.patch.yml +11 -0
  4. package/lib/acceptance-binding.d.ts +86 -0
  5. package/lib/acceptance-binding.d.ts.map +1 -0
  6. package/lib/acceptance-binding.js +250 -0
  7. package/lib/acceptance-binding.js.map +1 -0
  8. package/lib/admission.d.ts +95 -0
  9. package/lib/admission.d.ts.map +1 -0
  10. package/lib/admission.js +642 -0
  11. package/lib/admission.js.map +1 -0
  12. package/lib/authority.d.ts +92 -0
  13. package/lib/authority.d.ts.map +1 -0
  14. package/lib/authority.js +205 -0
  15. package/lib/authority.js.map +1 -0
  16. package/lib/config.d.ts +365 -0
  17. package/lib/config.d.ts.map +1 -0
  18. package/lib/config.js +672 -0
  19. package/lib/config.js.map +1 -0
  20. package/lib/continuation-contract.d.ts +126 -0
  21. package/lib/continuation-contract.d.ts.map +1 -0
  22. package/lib/continuation-contract.js +109 -0
  23. package/lib/continuation-contract.js.map +1 -0
  24. package/lib/continuation-record.d.ts +32 -0
  25. package/lib/continuation-record.d.ts.map +1 -0
  26. package/lib/continuation-record.js +57 -0
  27. package/lib/continuation-record.js.map +1 -0
  28. package/lib/continuation.d.ts +89 -0
  29. package/lib/continuation.d.ts.map +1 -0
  30. package/lib/continuation.js +607 -0
  31. package/lib/continuation.js.map +1 -0
  32. package/lib/diagnosis-contract.d.ts +95 -0
  33. package/lib/diagnosis-contract.d.ts.map +1 -0
  34. package/lib/diagnosis-contract.js +167 -0
  35. package/lib/diagnosis-contract.js.map +1 -0
  36. package/lib/diagnosis.d.ts +70 -0
  37. package/lib/diagnosis.d.ts.map +1 -0
  38. package/lib/diagnosis.js +466 -0
  39. package/lib/diagnosis.js.map +1 -0
  40. package/lib/dispatch.d.ts +100 -0
  41. package/lib/dispatch.d.ts.map +1 -0
  42. package/lib/dispatch.js +317 -0
  43. package/lib/dispatch.js.map +1 -0
  44. package/lib/engineering-context.d.ts +86 -0
  45. package/lib/engineering-context.d.ts.map +1 -0
  46. package/lib/engineering-context.js +263 -0
  47. package/lib/engineering-context.js.map +1 -0
  48. package/lib/evaluation.d.ts +125 -0
  49. package/lib/evaluation.d.ts.map +1 -0
  50. package/lib/evaluation.js +295 -0
  51. package/lib/evaluation.js.map +1 -0
  52. package/lib/event-follow.d.ts +93 -0
  53. package/lib/event-follow.d.ts.map +1 -0
  54. package/lib/event-follow.js +150 -0
  55. package/lib/event-follow.js.map +1 -0
  56. package/lib/feedback-targets.d.ts +91 -0
  57. package/lib/feedback-targets.d.ts.map +1 -0
  58. package/lib/feedback-targets.js +362 -0
  59. package/lib/feedback-targets.js.map +1 -0
  60. package/lib/index.d.ts +27 -0
  61. package/lib/index.d.ts.map +1 -0
  62. package/lib/index.js +25 -0
  63. package/lib/index.js.map +1 -0
  64. package/lib/intake-admission.d.ts +49 -0
  65. package/lib/intake-admission.d.ts.map +1 -0
  66. package/lib/intake-admission.js +100 -0
  67. package/lib/intake-admission.js.map +1 -0
  68. package/lib/intake-evaluation-runtime.d.ts +74 -0
  69. package/lib/intake-evaluation-runtime.d.ts.map +1 -0
  70. package/lib/intake-evaluation-runtime.js +343 -0
  71. package/lib/intake-evaluation-runtime.js.map +1 -0
  72. package/lib/intake-evaluation.d.ts +180 -0
  73. package/lib/intake-evaluation.d.ts.map +1 -0
  74. package/lib/intake-evaluation.js +440 -0
  75. package/lib/intake-evaluation.js.map +1 -0
  76. package/lib/intake.d.ts +118 -0
  77. package/lib/intake.d.ts.map +1 -0
  78. package/lib/intake.js +137 -0
  79. package/lib/intake.js.map +1 -0
  80. package/lib/ledger.d.ts +86 -0
  81. package/lib/ledger.d.ts.map +1 -0
  82. package/lib/ledger.js +145 -0
  83. package/lib/ledger.js.map +1 -0
  84. package/lib/mandate.d.ts +45 -0
  85. package/lib/mandate.d.ts.map +1 -0
  86. package/lib/mandate.js +168 -0
  87. package/lib/mandate.js.map +1 -0
  88. package/lib/outcome.d.ts +137 -0
  89. package/lib/outcome.d.ts.map +1 -0
  90. package/lib/outcome.js +303 -0
  91. package/lib/outcome.js.map +1 -0
  92. package/lib/owner-access.d.ts +35 -0
  93. package/lib/owner-access.d.ts.map +1 -0
  94. package/lib/owner-access.js +152 -0
  95. package/lib/owner-access.js.map +1 -0
  96. package/lib/owner-continuation.d.ts +27 -0
  97. package/lib/owner-continuation.d.ts.map +1 -0
  98. package/lib/owner-continuation.js +131 -0
  99. package/lib/owner-continuation.js.map +1 -0
  100. package/lib/owner-recall.d.ts +85 -0
  101. package/lib/owner-recall.d.ts.map +1 -0
  102. package/lib/owner-recall.js +134 -0
  103. package/lib/owner-recall.js.map +1 -0
  104. package/lib/owner-replies.d.ts +44 -0
  105. package/lib/owner-replies.d.ts.map +1 -0
  106. package/lib/owner-replies.js +232 -0
  107. package/lib/owner-replies.js.map +1 -0
  108. package/lib/peers.d.ts +622 -0
  109. package/lib/peers.d.ts.map +1 -0
  110. package/lib/peers.js +10 -0
  111. package/lib/peers.js.map +1 -0
  112. package/lib/policy-notice.d.ts +31 -0
  113. package/lib/policy-notice.d.ts.map +1 -0
  114. package/lib/policy-notice.js +137 -0
  115. package/lib/policy-notice.js.map +1 -0
  116. package/lib/reply-contract.d.ts +67 -0
  117. package/lib/reply-contract.d.ts.map +1 -0
  118. package/lib/reply-contract.js +58 -0
  119. package/lib/reply-contract.js.map +1 -0
  120. package/lib/service.d.ts +625 -0
  121. package/lib/service.d.ts.map +1 -0
  122. package/lib/service.js +2388 -0
  123. package/lib/service.js.map +1 -0
  124. package/lib/settlement.d.ts +74 -0
  125. package/lib/settlement.d.ts.map +1 -0
  126. package/lib/settlement.js +233 -0
  127. package/lib/settlement.js.map +1 -0
  128. package/lib/signals.d.ts +176 -0
  129. package/lib/signals.d.ts.map +1 -0
  130. package/lib/signals.js +497 -0
  131. package/lib/signals.js.map +1 -0
  132. package/lib/store.d.ts +789 -0
  133. package/lib/store.d.ts.map +1 -0
  134. package/lib/store.js +3266 -0
  135. package/lib/store.js.map +1 -0
  136. package/lib/tools.d.ts +7 -0
  137. package/lib/tools.d.ts.map +1 -0
  138. package/lib/tools.js +443 -0
  139. package/lib/tools.js.map +1 -0
  140. package/lib/types.d.ts +831 -0
  141. package/lib/types.d.ts.map +1 -0
  142. package/lib/types.js +29 -0
  143. package/lib/types.js.map +1 -0
  144. package/lib/version.d.ts +2 -0
  145. package/lib/version.d.ts.map +1 -0
  146. package/lib/version.js +2 -0
  147. package/lib/version.js.map +1 -0
  148. package/lib/workspace.d.ts +43 -0
  149. package/lib/workspace.d.ts.map +1 -0
  150. package/lib/workspace.js +137 -0
  151. package/lib/workspace.js.map +1 -0
  152. package/package.json +101 -3
@@ -0,0 +1,35 @@
1
+ import type { ToolExecution } from '@deepseek-ai/dsh-tools';
2
+ import type { NormalizedConfig } from './config.js';
3
+ import type { PeerDeliveryService, PeerOwnerAliasReceipt, PeerOwnerRouteReceipt, PeerPolicyService } from './peers.js';
4
+ import type { WorkItemStore } from './store.js';
5
+ export type OwnerWorkItemExecution = Pick<ToolExecution, 'agent' | 'callId' | 'name' | 'arguments' | 'signal'>;
6
+ export type OwnerStoreScope = Parameters<WorkItemStore['listOwnerItems']>[0];
7
+ export interface WorkItemOwnerAccessDependencies {
8
+ config: NormalizedConfig;
9
+ store: () => WorkItemStore | undefined;
10
+ delivery: () => PeerDeliveryService | undefined;
11
+ policy: () => PeerPolicyService | undefined;
12
+ access?: WorkItemOwnerAccess;
13
+ }
14
+ export declare function ownerArgumentsOf(value: unknown, allowed: readonly string[], label?: string): Record<string, unknown>;
15
+ /** Root owner scope reached through a read-only linked alias. Never a v2 owner receipt. */
16
+ export type OwnerAliasRoute = Omit<PeerOwnerRouteReceipt, 'receiptVersion'> & {
17
+ readonly receiptVersion?: never;
18
+ readonly alias: PeerOwnerAliasReceipt['alias'];
19
+ };
20
+ export interface WorkItemOwnerAccessContext {
21
+ store: WorkItemStore;
22
+ owner: Readonly<OwnerStoreScope>;
23
+ /** Exact v2 owner receipt, or (inspect-work-items only) the alias-rooted owner scope. */
24
+ route: Readonly<PeerOwnerRouteReceipt | OwnerAliasRoute>;
25
+ delivery: PeerDeliveryService;
26
+ assertCurrent: () => void;
27
+ }
28
+ /** Exact current native-call authority shared by owner reads and continuation.
29
+ * No cached proof grants later execution; every downstream boundary rechecks. */
30
+ export declare class WorkItemOwnerAccess {
31
+ private readonly dependencies;
32
+ constructor(dependencies: WorkItemOwnerAccessDependencies);
33
+ withOwner<T>(execution: OwnerWorkItemExecution, args: Record<string, unknown>, allowed: readonly string[], action: 'inspect-work-items' | 'continue-work-items', consume: boolean, callback: (context: WorkItemOwnerAccessContext) => T): T;
34
+ }
35
+ //# sourceMappingURL=owner-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-access.d.ts","sourceRoot":"","sources":["../src/owner-access.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACtH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG/C,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAA;AAC9G,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5E,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,gBAAgB,CAAA;IACxB,KAAK,EAAE,MAAM,aAAa,GAAG,SAAS,CAAA;IACtC,QAAQ,EAAE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igest } from '@dsh-enhanced/task-acceptance-contract';
3
+ import { WorkItemError } from './types.js';
4
+ // Shared across read and continuation entrypoints, including separate access instances.
5
+ const busy = new WeakSet();
6
+ const peerIdentity = (value) => value === undefined ? undefined : value[symbols.original] ?? value;
7
+ export function ownerArgumentsOf(value, allowed, label = 'owner recall') {
8
+ if (!value || typeof value !== 'object' || Array.isArray(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
9
+ throw new WorkItemError('invalid-input', `${label} requires plain arguments`);
10
+ const output = {};
11
+ for (const key of Reflect.ownKeys(value)) {
12
+ if (typeof key !== 'string' || !allowed.includes(key))
13
+ throw new WorkItemError('invalid-input', `unknown ${label} argument`);
14
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
15
+ if (!descriptor.enumerable || !('value' in descriptor) || descriptor.value === undefined || !['number', 'string'].includes(typeof descriptor.value))
16
+ throw new WorkItemError('invalid-input', `invalid ${label} argument`);
17
+ output[key] = descriptor.value;
18
+ }
19
+ return Object.freeze(output);
20
+ }
21
+ /** Exact current native-call authority shared by owner reads and continuation.
22
+ * No cached proof grants later execution; every downstream boundary rechecks. */
23
+ export class WorkItemOwnerAccess {
24
+ dependencies;
25
+ constructor(dependencies) {
26
+ this.dependencies = dependencies;
27
+ }
28
+ withOwner(execution, args, allowed, action, consume, callback) {
29
+ const { config } = this.dependencies, scope = config.scope, continuing = action === 'continue-work-items';
30
+ const label = continuing ? 'owner continuation' : 'owner recall';
31
+ function fail(message) { throw new WorkItemError('identity-mismatch', `${label} ${message}`); }
32
+ const automationId = continuing ? config.ownerContinuation?.automationId : config.workerAutomationId;
33
+ if (!config.ownerRecall || !config.enabled || config.mode !== 'active' || !scope || !config.workerAutomationId || !automationId
34
+ || continuing && !config.ownerContinuation)
35
+ fail('is disabled');
36
+ if (continuing ? execution.name !== 'work_item_continue' : !['work_item_list', 'work_item_recall'].includes(execution.name))
37
+ fail('tool identity mismatch');
38
+ if (acceptanceCanonicalJson(args) !== acceptanceCanonicalJson(ownerArgumentsOf(execution.arguments, allowed, label)))
39
+ fail('arguments do not match the actual call');
40
+ const agent = execution.agent;
41
+ if (!agent || busy.has(agent))
42
+ fail('requires a non-reentrant foreground caller');
43
+ busy.add(agent);
44
+ try {
45
+ const delivery = this.dependencies.delivery(), policy = this.dependencies.policy(), store = this.dependencies.store();
46
+ if (!delivery?.validateOwnerAgentForRoute || !delivery.inspectOwnerForegroundToolCall || !policy?.authorizeAgent || !policy.evaluateAgent || !store || store.closed)
47
+ fail('peers unavailable');
48
+ if (typeof execution.callId !== 'string' || execution.callId.length === 0 || execution.callId.length > 512)
49
+ fail('requires actual call identity');
50
+ const expiresAt = continuing ? Math.min(scope.expiresAt, config.ownerContinuation.expiresAt) : scope.expiresAt;
51
+ const argumentsJson = JSON.stringify(ownerArgumentsOf(execution.arguments, allowed, label)), name = execution.name, callId = execution.callId, signal = execution.signal;
52
+ const deliveryIdentity = peerIdentity(delivery), policyIdentity = peerIdentity(policy);
53
+ const observe = () => {
54
+ if (execution.agent !== agent || execution.signal !== signal || execution.name !== name || execution.callId !== callId
55
+ || JSON.stringify(ownerArgumentsOf(execution.arguments, allowed, label)) !== argumentsJson
56
+ || peerIdentity(this.dependencies.delivery()) !== deliveryIdentity || peerIdentity(this.dependencies.policy()) !== policyIdentity || this.dependencies.store() !== store
57
+ || store.closed || signal.aborted || Date.now() >= expiresAt)
58
+ fail('authority changed');
59
+ const route = delivery.validateOwnerAgentForRoute(agent, scope.ownerRouteId);
60
+ // Read-only linked alias: only for inspect-work-items, only when the
61
+ // caller is not the exact owner, only for an owner-allowlisted alias
62
+ // principal, and re-validated on every observation.
63
+ if (!route && !continuing && config.ownerRecall.linkedAliases !== undefined && delivery.inspectOwnerAliasRoute && delivery.inspectOwnerAliasForegroundToolCall)
64
+ return observeAlias();
65
+ if (!route || route.receiptVersion !== 2 || route.authorityId !== scope.ownerRouteId || route.principalId !== scope.principalId
66
+ || route.workspace !== scope.workspace || route.agentPreset !== scope.preset || typeof route.authorityHash !== 'string' || !route.authorityHash || !route.principalRecordId
67
+ || !Number.isSafeInteger(route.principalVersion) || route.principalVersion < 1 || !Number.isSafeInteger(route.generation) || route.generation < 1
68
+ || !Number.isSafeInteger(route.bindingVersion) || route.bindingVersion < 1)
69
+ fail('requires the current exact owner');
70
+ const proof = delivery.inspectOwnerForegroundToolCall({ agent, authorityId: scope.ownerRouteId, callId: String(execution.callId), toolName: execution.name, argumentsJson });
71
+ if (!proof || typeof proof !== 'object' || proof.protocol !== 'assistant-delivery/foreground-tool-call/v1')
72
+ fail('requires an actual human foreground tool call');
73
+ return { route: { receiptVersion: route.receiptVersion, authorityId: route.authorityId, authorityHash: route.authorityHash,
74
+ principalId: route.principalId, principalRecordId: route.principalRecordId, principalVersion: route.principalVersion,
75
+ workspace: route.workspace, agentPreset: route.agentPreset, bindingVersion: route.bindingVersion, generation: route.generation }, proof: acceptanceDigest(proof) };
76
+ };
77
+ const observeAlias = () => {
78
+ const alias = delivery.inspectOwnerAliasRoute(agent, scope.ownerRouteId);
79
+ const counter = (value) => Number.isSafeInteger(value) && value >= 1;
80
+ if (!alias || alias.protocol !== 'assistant-delivery/owner-alias-receipt/v1' || 'receiptVersion' in alias
81
+ || alias.authorityId !== scope.ownerRouteId || alias.workspace !== scope.workspace || alias.agentPreset !== scope.preset
82
+ || typeof alias.authorityHash !== 'string' || !alias.authorityHash || !alias.root || !alias.alias
83
+ || alias.root.principalId !== scope.principalId || typeof alias.root.principalRecordId !== 'string' || !alias.root.principalRecordId
84
+ || !counter(alias.root.principalVersion) || !counter(alias.root.generation) || !counter(alias.root.bindingVersion)
85
+ || typeof alias.alias.principalRecordId !== 'string' || !alias.alias.principalRecordId
86
+ || alias.alias.principalRecordId === alias.root.principalRecordId || alias.alias.principalId === alias.root.principalId
87
+ || alias.alias.sessionId !== String(agent.session.id) || !counter(alias.alias.principalVersion)
88
+ || !counter(alias.alias.bindingVersion) || !counter(alias.alias.bindingGeneration))
89
+ fail('requires the current exact owner or its linked alias');
90
+ // A Delivery link alone is not consent: the owner must name this alias
91
+ // principal in ownerRecall.linkedAliases. Absent allowlist = no alias.
92
+ if (!config.ownerRecall.linkedAliases?.includes(alias.alias.principalId))
93
+ fail('linked alias is not allowlisted by the owner');
94
+ const proof = delivery.inspectOwnerAliasForegroundToolCall({ agent, authorityId: scope.ownerRouteId, callId: String(execution.callId), toolName: execution.name, argumentsJson });
95
+ if (!proof || typeof proof !== 'object' || proof.protocol !== 'assistant-delivery/owner-alias-foreground-tool-call/v1')
96
+ fail('requires an actual human foreground tool call');
97
+ const route = { authorityId: alias.authorityId, authorityHash: alias.authorityHash,
98
+ principalId: alias.root.principalId, principalRecordId: alias.root.principalRecordId, principalVersion: alias.root.principalVersion,
99
+ workspace: alias.workspace, agentPreset: alias.agentPreset, bindingVersion: alias.root.bindingVersion, generation: alias.root.generation,
100
+ alias: Object.freeze({ ...alias.alias }) };
101
+ return { route, proof: acceptanceDigest(proof) };
102
+ };
103
+ const initial = observe(), identity = acceptanceDigest(initial);
104
+ const current = () => { if (acceptanceDigest(observe()) !== identity)
105
+ fail('owner/call changed'); };
106
+ const resource = Object.freeze({ kind: 'automation', id: automationId });
107
+ // A linked alias spends its own bounded quota: the matching rule must be
108
+ // budgeted, and the charge must land in the alias principal's own Policy
109
+ // partition, never in the owner's shared rule scope.
110
+ const aliasPrincipal = 'alias' in initial.route ? initial.route.alias.principalId : undefined;
111
+ if (aliasPrincipal !== undefined && typeof policy.authorizeAgentForPrincipal !== 'function')
112
+ fail('linked alias reads require per-principal Policy budgets');
113
+ const budgeted = (decision) => {
114
+ const budget = decision?.budget;
115
+ return !!budget && typeof budget === 'object' && typeof budget.id === 'string' && budget.id.length > 0
116
+ && typeof budget.amount === 'number' && Number.isFinite(budget.amount) && budget.amount > 0;
117
+ };
118
+ const evaluate = () => {
119
+ current();
120
+ const decision = policy.evaluateAgent(agent, action, resource);
121
+ current();
122
+ if (decision?.effect !== 'allow')
123
+ fail(continuing ? 'permission denied' : 'read permission denied');
124
+ if (aliasPrincipal !== undefined && !budgeted(decision))
125
+ fail('linked alias read requires a budgeted Policy rule');
126
+ };
127
+ evaluate();
128
+ if (consume) {
129
+ const idempotencyKey = `${continuing ? 'work-items-owner-continue' : aliasPrincipal !== undefined ? 'work-items-alias-read' : 'work-items-owner-read'}:${acceptanceDigest({ owner: initial.route, sessionId: String(agent.session.id), callId: execution.callId, name: execution.name, args })}`;
130
+ const decision = aliasPrincipal === undefined ? policy.authorizeAgent(agent, action, resource, { idempotencyKey })
131
+ : policy.authorizeAgentForPrincipal(agent, action, resource, { idempotencyKey, principal: aliasPrincipal });
132
+ current();
133
+ if (decision?.effect !== 'allow')
134
+ fail(continuing ? 'permission denied' : 'read permission denied');
135
+ if (aliasPrincipal !== undefined && decision.budgetPrincipal !== aliasPrincipal)
136
+ fail('linked alias read was not charged to the alias principal');
137
+ }
138
+ evaluate();
139
+ const owner = { principalId: initial.route.principalId, principalRecordId: initial.route.principalRecordId,
140
+ principalVersion: initial.route.principalVersion, workspace: scope.workspace, preset: scope.preset, ownerRouteId: scope.ownerRouteId,
141
+ workerAutomationId: config.workerAutomationId, ...(config.ownerContinuation ? { continuationAutomationId: config.ownerContinuation.automationId } : {}),
142
+ generation: initial.route.generation, bindingVersion: initial.route.bindingVersion };
143
+ const result = callback({ store, owner: Object.freeze(owner), route: Object.freeze(initial.route), delivery, assertCurrent: evaluate });
144
+ evaluate();
145
+ return result;
146
+ }
147
+ finally {
148
+ busy.delete(agent);
149
+ }
150
+ }
151
+ }
152
+ //# sourceMappingURL=owner-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-access.js","sourceRoot":"","sources":["../src/owner-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAIlG,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAW1C,wFAAwF;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AE,CAAA;YACtF,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAA;YACvI,QAAQ,EAAE,CAAC;YAAC,OAAO,MAAM,CAAA;QAC3B,CAAC;gBAAS,CAAC;YAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAAC,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ import type { WorkItemContinuation } from './continuation.js';
2
+ import { type WorkItemContinuationAdmission } from './continuation-record.js';
3
+ import { type OwnerWorkItemExecution, type WorkItemOwnerAccessDependencies } from './owner-access.js';
4
+ import { type WorkItemAdmitInput, type WorkItemAdmitResult } from './types.js';
5
+ export interface OwnerWorkItemContinueInput {
6
+ item_id: string;
7
+ }
8
+ export interface WorkItemOwnerContinuationDependencies extends WorkItemOwnerAccessDependencies {
9
+ runtime: () => WorkItemContinuation | undefined;
10
+ admit: (input: WorkItemAdmitInput, continuation: WorkItemContinuationAdmission) => WorkItemAdmitResult;
11
+ }
12
+ /** The model chooses only an owner-filtered parent id. The new instruction and
13
+ * supplier come exclusively from the current persisted human foreground task. */
14
+ export declare class WorkItemOwnerContinuation {
15
+ #private;
16
+ private readonly dependencies;
17
+ constructor(dependencies: WorkItemOwnerContinuationDependencies);
18
+ preauthorize(execution: OwnerWorkItemExecution): boolean;
19
+ continue(execution: OwnerWorkItemExecution, input: OwnerWorkItemContinueInput): Readonly<{
20
+ itemId: string;
21
+ parentItemId: string;
22
+ rootItemId: string;
23
+ state: string;
24
+ replayed: boolean;
25
+ }>;
26
+ }
27
+ //# sourceMappingURL=owner-continuation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-continuation.d.ts","sourceRoot":"","sources":["../src/owner-continuation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAE7D,OAAO,EAA2E,KAAK,6BAA6B,EAAE,MAAM,0BAA0B,CAAA;AACtJ,OAAO,EAAyC,KAAK,sBAAsB,EAAmC,KAAK,+BAA+B,EAAE,MAAM,mBAAmB,CAAA;AAE7K,OAAO,EAAiB,KAAK,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAE7F,MAAM,WAAW,0BAA0B;IAAG,OAAO,EAAE,MAAM,CAAA;CAAE;AAC/D,MAAM,WAAW,qCAAsC,SAAQ,+BAA+B;IAC5F,OAAO,EAAE,MAAM,oBAAoB,GAAG,SAAS,CAAA;IAC/C,KAAK,EAAE,CAAC,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,6BAA6B,KAAK,mBAAmB,CAAA;CACvG;AAiBD;iFACiF;AACjF,qBAAa,yBAAyB;;IAExB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAAZ,YAAY,EAAE,qCAAqC;IA4BhF,YAAY,CAAC,SAAS,EAAE,sBAAsB,GAAG,OAAO;IAYxD,QAAQ,CAAC,SAAS,EAAE,sBAAsB,EAAE,KAAK,EAAE,0BAA0B,GAAG,QAAQ,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;CA6CzL"}
@@ -0,0 +1,131 @@
1
+ import { acceptanceCanonicalJson, acceptanceDigest } from '@dsh-enhanced/task-acceptance-contract';
2
+ import { truncateUtf8 } from './config.js';
3
+ import { MAX_CONTINUATION_INPUT_BYTES, continuationDigest, continuationSourceKey } from './continuation-record.js';
4
+ import { WorkItemOwnerAccess, ownerArgumentsOf } from './owner-access.js';
5
+ import { WorkItemError } from './types.js';
6
+ const HEX = /^[a-f0-9]{64}$/u;
7
+ const ALLOWED = ['item_id'];
8
+ const PAGE = 8192;
9
+ function fail(message) { throw new WorkItemError('identity-mismatch', `owner continuation ${message}`); }
10
+ function argumentsOf(execution, input) {
11
+ if (execution.name !== 'work_item_continue')
12
+ fail('tool identity mismatch');
13
+ const args = ownerArgumentsOf(input, ALLOWED, 'owner continuation');
14
+ if (typeof args.item_id !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/u.test(args.item_id))
15
+ throw new WorkItemError('invalid-input', 'invalid owner continuation item selector');
16
+ return args;
17
+ }
18
+ function validModel(value) {
19
+ return !!value && typeof value.provider === 'string' && typeof value.model === 'string'
20
+ && Object.keys(value).every(key => ['provider', 'model', 'reasoningEffort'].includes(key))
21
+ && [value.provider, value.model, ...(value.reasoningEffort === undefined ? [] : [value.reasoningEffort])].every(part => typeof part === 'string' && part.trim() === part && part.length > 0 && Buffer.byteLength(part) <= 4096 && !/\p{Cc}/u.test(part));
22
+ }
23
+ /** The model chooses only an owner-filtered parent id. The new instruction and
24
+ * supplier come exclusively from the current persisted human foreground task. */
25
+ export class WorkItemOwnerContinuation {
26
+ dependencies;
27
+ #access;
28
+ constructor(dependencies) {
29
+ this.dependencies = dependencies;
30
+ this.#access = dependencies.access ?? new WorkItemOwnerAccess(dependencies);
31
+ }
32
+ #readPage(execution, context, offset) {
33
+ context.assertCurrent();
34
+ const read = context.delivery.readOwnerForegroundToolInput;
35
+ if (!read || !execution.agent)
36
+ fail('live human input reader is unavailable');
37
+ const page = read.call(context.delivery, { agent: execution.agent, authorityId: context.route.authorityId, callId: String(execution.callId),
38
+ toolName: execution.name, argumentsJson: JSON.stringify(ownerArgumentsOf(execution.arguments, ALLOWED, 'owner continuation')), offset, maxBytes: PAGE });
39
+ context.assertCurrent();
40
+ const proof = context.delivery.inspectOwnerForegroundToolCall({ agent: execution.agent, authorityId: context.route.authorityId,
41
+ callId: String(execution.callId), toolName: execution.name, argumentsJson: JSON.stringify(execution.arguments) });
42
+ if (!page || page.protocol !== 'assistant-delivery/foreground-tool-input/v1' || !HEX.test(page.sourceDigest)
43
+ || page.modelSelectionState !== 'frozen' || !validModel(page.modelSelection)
44
+ || page.attestation?.protocol !== 'assistant-delivery/foreground-tool-call/v1' || acceptanceDigest(page.attestation) !== acceptanceDigest(proof))
45
+ fail('human input or actual supplier is unproven');
46
+ const task = page.attestation.task, data = page.input;
47
+ if (!task || !task.scope || !task.owner || !task.binding || task.protocol !== 'assistant-delivery/foreground-task/v1' || task.sessionId !== String(execution.agent.session.id)
48
+ || task.scope.workspace !== context.route.workspace || task.scope.preset !== context.route.agentPreset
49
+ || task.owner.principalRecordId !== context.route.principalRecordId || task.owner.principalVersion !== context.route.principalVersion
50
+ || task.binding.version !== context.route.bindingVersion || task.binding.generation !== context.route.generation
51
+ || typeof task.binding.id !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9:._-]{0,255}$/u.test(task.binding.id)
52
+ || typeof data?.text !== 'string' || Buffer.from(data.text, 'utf8').toString('utf8') !== data.text || !HEX.test(data.fullTextDigest)
53
+ || !Number.isSafeInteger(data.fullBytes) || data.fullBytes < 1 || data.fullBytes > MAX_CONTINUATION_INPUT_BYTES
54
+ || data.offset !== offset || data.returnedBytes !== Buffer.byteLength(data.text) || data.returnedBytes < 1 || data.returnedBytes > PAGE
55
+ || offset + data.returnedBytes > data.fullBytes || (data.nextOffset === undefined ? offset + data.returnedBytes !== data.fullBytes
56
+ : data.nextOffset !== offset + data.returnedBytes || data.nextOffset >= data.fullBytes))
57
+ fail('human input page binding differs');
58
+ return page;
59
+ }
60
+ preauthorize(execution) {
61
+ try {
62
+ const args = argumentsOf(execution, execution.arguments), runtime = this.dependencies.runtime();
63
+ if (!runtime)
64
+ return false;
65
+ return this.#access.withOwner(execution, args, ALLOWED, 'continue-work-items', false, context => {
66
+ if (!context.store.listOwnerItems(context.owner, undefined, 1, String(args.item_id))[0])
67
+ return false;
68
+ this.#readPage(execution, context, 0);
69
+ return this.dependencies.runtime() === runtime;
70
+ });
71
+ }
72
+ catch {
73
+ return false;
74
+ }
75
+ }
76
+ continue(execution, input) {
77
+ const args = argumentsOf(execution, input), runtime = this.dependencies.runtime();
78
+ if (!runtime)
79
+ throw new WorkItemError('missing-dependency', 'owner continuation runtime is unavailable');
80
+ return this.#access.withOwner(execution, args, ALLOWED, 'continue-work-items', true, context => {
81
+ const parent = context.store.listOwnerItems(context.owner, undefined, 1, String(args.item_id))[0];
82
+ if (!parent)
83
+ throw new WorkItemError('not-found', 'no owner work item matches this continuation selector');
84
+ const first = this.#readPage(execution, context, 0), firstFingerprint = acceptanceDigest(first);
85
+ const identity = acceptanceCanonicalJson({ attestation: first.attestation, sourceDigest: first.sourceDigest,
86
+ modelSelection: first.modelSelection, fullTextDigest: first.input.fullTextDigest, fullBytes: first.input.fullBytes });
87
+ let page = first, text = '', count = 0;
88
+ for (;;) {
89
+ if (++count > 34 || acceptanceCanonicalJson({ attestation: page.attestation, sourceDigest: page.sourceDigest,
90
+ modelSelection: page.modelSelection, fullTextDigest: page.input.fullTextDigest, fullBytes: page.input.fullBytes }) !== identity)
91
+ fail('human input changed during pagination');
92
+ text += page.input.text;
93
+ if (Buffer.byteLength(text) > MAX_CONTINUATION_INPUT_BYTES)
94
+ fail('human input exceeds byte bound');
95
+ if (page.input.nextOffset === undefined)
96
+ break;
97
+ page = this.#readPage(execution, context, page.input.nextOffset);
98
+ }
99
+ if (Buffer.byteLength(text) !== first.input.fullBytes || continuationDigest(text) !== first.input.fullTextDigest)
100
+ fail('human input full digest differs');
101
+ const source = Object.freeze({ sourceDigest: first.sourceDigest, inputText: text, modelSelection: Object.freeze({ ...first.modelSelection }) });
102
+ const assertCurrent = () => {
103
+ context.assertCurrent();
104
+ if (this.dependencies.runtime() !== runtime || acceptanceDigest(this.#readPage(execution, context, 0)) !== firstFingerprint)
105
+ fail('source or runtime changed before admission');
106
+ };
107
+ assertCurrent();
108
+ const continuation = runtime.prepare(parent.id, source, assertCurrent);
109
+ if (continuation.parentItemId !== parent.id || continuation.sourceDigest !== source.sourceDigest || continuation.sourceKey !== continuationSourceKey(parent.id, source.sourceDigest))
110
+ fail('runtime admission identity differs');
111
+ assertCurrent();
112
+ const result = this.dependencies.admit({ kind: 'owner-continuation', externalId: continuation.sourceKey,
113
+ title: truncateUtf8(`Continue: ${parent.title}`, 256).value,
114
+ brief: 'Continue this owner task. Call work_item_read_context to read the authenticated owner instruction and linked history before acting.',
115
+ originBindingId: first.attestation.task.binding.id,
116
+ provenance: { source: 'owner-continuation', sourceVersion: 'assistant-work-items/owner-continuation/v1', signalDigest: source.sourceDigest,
117
+ observedAt: Date.now(), evidence: { parentItemId: parent.id, sourceDigest: source.sourceDigest } } }, continuation);
118
+ assertCurrent();
119
+ const record = context.store.getContinuation(result.item.id);
120
+ if (!record || record.parentItemId !== parent.id || record.sourceKey !== continuation.sourceKey || record.sourceDigest !== source.sourceDigest
121
+ || record.rootItemId !== (context.store.getContinuation(parent.id)?.rootItemId ?? parent.id)
122
+ || result.item.workerAutomationId !== this.dependencies.config.ownerContinuation.automationId)
123
+ fail('admitted continuation record differs');
124
+ runtime.wakePending();
125
+ assertCurrent();
126
+ return Object.freeze({ itemId: result.item.id, parentItemId: record.parentItemId, rootItemId: record.rootItemId,
127
+ state: context.store.findItemById(result.item.id)?.state ?? result.item.state, replayed: !result.created });
128
+ });
129
+ }
130
+ }
131
+ //# sourceMappingURL=owner-continuation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-continuation.js","sourceRoot":"","sources":["../src/owner-continuation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,OAAO,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,qBAAqB,EAAsC,MAAM,0BAA0B,CAAA;AACtJ,OAAO,EAAE,mBAAmB,EAAE,gBAA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AA;YAC9I,OAAO,CAAC,WAAW,EAAE,CAAA;YACrB,aAAa,EAAE,CAAA;YACf,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7G,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;QAC/G,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ import { type OwnerWorkItemExecution, type WorkItemOwnerAccessDependencies } from './owner-access.js';
2
+ import { type WorkItemResumeReport } from './types.js';
3
+ export interface OwnerWorkItemListInput {
4
+ after?: string;
5
+ limit?: number;
6
+ }
7
+ export interface OwnerWorkItemRecallInput {
8
+ item_id: string;
9
+ report_revision?: number;
10
+ offset?: number;
11
+ max_bytes?: number;
12
+ }
13
+ export type { OwnerWorkItemExecution } from './owner-access.js';
14
+ export interface OwnerWorkItemSummary {
15
+ continuation?: Readonly<{
16
+ parentItemId: string;
17
+ rootItemId: string;
18
+ }>;
19
+ itemId: string;
20
+ kind: string;
21
+ title: string;
22
+ state: string;
23
+ stateReason: string | null;
24
+ lastReport?: WorkItemResumeReport;
25
+ attempt: number;
26
+ maxAttempts: number;
27
+ lastReportStatus: string | null;
28
+ observed: boolean;
29
+ createdAt: number;
30
+ updatedAt: number;
31
+ }
32
+ /** Separate foreground read capability. It never admits, recovers, claims or dispatches. */
33
+ export declare class WorkItemOwnerRecall {
34
+ #private;
35
+ constructor(dependencies: WorkItemOwnerAccessDependencies);
36
+ preauthorize(execution: OwnerWorkItemExecution): boolean;
37
+ list(execution: OwnerWorkItemExecution, input: OwnerWorkItemListInput): Readonly<{
38
+ nextCursor?: string;
39
+ items: readonly Readonly<{
40
+ lastReport?: WorkItemResumeReport;
41
+ continuation?: Readonly<{
42
+ parentItemId: string;
43
+ rootItemId: string;
44
+ }>;
45
+ itemId: string;
46
+ kind: string;
47
+ title: string;
48
+ state: string;
49
+ stateReason: string | null;
50
+ attempt: number;
51
+ maxAttempts: number;
52
+ lastReportStatus: string | null;
53
+ observed: boolean;
54
+ createdAt: number;
55
+ updatedAt: number;
56
+ }>[];
57
+ }>;
58
+ recall(execution: OwnerWorkItemExecution, input: OwnerWorkItemRecallInput): Readonly<{
59
+ item: Readonly<OwnerWorkItemSummary>;
60
+ content: Readonly<{
61
+ storedTruncated: boolean;
62
+ nextOffset?: number;
63
+ text: string;
64
+ fullBytes: number;
65
+ returnedBytes: number;
66
+ offset: number;
67
+ nextRevision?: number;
68
+ previousRevision?: number;
69
+ reportRevision?: number;
70
+ status?: import("./types.js").WorkItemReportStatus;
71
+ recordedAt?: number;
72
+ kind: "brief" | "report";
73
+ }>;
74
+ reports: readonly Readonly<{
75
+ summary: string;
76
+ summaryTruncated: boolean;
77
+ revision: number;
78
+ status: import("./types.js").WorkItemReportStatus;
79
+ recordedAt: number;
80
+ }>[];
81
+ reportsTotal: number;
82
+ latestOutcome: import("./types.js").WorkItemResumeOutcome | null;
83
+ }>;
84
+ }
85
+ //# sourceMappingURL=owner-recall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-recall.d.ts","sourceRoot":"","sources":["../src/owner-recall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwD,KAAK,sBAAsB,EAAE,KAAK,+BAA+B,EAAE,MAAM,mBAAmB,CAAA;AAG3J,OAAO,EAAsC,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAE1F,MAAM,WAAW,sBAAsB;IAAG,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAC1E,MAAM,WAAW,wBAAwB;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