@fabric-harness/sdk 6.9.0 → 6.10.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.
Files changed (106) hide show
  1. package/dist/agent.d.ts.map +1 -1
  2. package/dist/agent.js +8 -0
  3. package/dist/agent.js.map +1 -1
  4. package/dist/channel-runtime.d.ts +2 -0
  5. package/dist/channel-runtime.d.ts.map +1 -1
  6. package/dist/channel-runtime.js +1 -0
  7. package/dist/channel-runtime.js.map +1 -1
  8. package/dist/channel.d.ts +11 -0
  9. package/dist/channel.d.ts.map +1 -1
  10. package/dist/channel.js.map +1 -1
  11. package/dist/context.d.ts +28 -0
  12. package/dist/context.d.ts.map +1 -1
  13. package/dist/context.js +18 -0
  14. package/dist/context.js.map +1 -1
  15. package/dist/conversation-ownership.d.ts +151 -0
  16. package/dist/conversation-ownership.d.ts.map +1 -0
  17. package/dist/conversation-ownership.js +239 -0
  18. package/dist/conversation-ownership.js.map +1 -0
  19. package/dist/dispatch.d.ts +7 -0
  20. package/dist/dispatch.d.ts.map +1 -1
  21. package/dist/dispatch.js.map +1 -1
  22. package/dist/dynamic-agent.d.ts.map +1 -1
  23. package/dist/dynamic-agent.js +8 -0
  24. package/dist/dynamic-agent.js.map +1 -1
  25. package/dist/error.d.ts +1 -1
  26. package/dist/error.d.ts.map +1 -1
  27. package/dist/error.js.map +1 -1
  28. package/dist/experimental.d.ts +6 -5
  29. package/dist/experimental.d.ts.map +1 -1
  30. package/dist/experimental.js +5 -3
  31. package/dist/experimental.js.map +1 -1
  32. package/dist/governed-voice.d.ts.map +1 -1
  33. package/dist/governed-voice.js +5 -0
  34. package/dist/governed-voice.js.map +1 -1
  35. package/dist/index.d.ts +8 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +4 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/loop.d.ts +8 -0
  40. package/dist/loop.d.ts.map +1 -1
  41. package/dist/loop.js +22 -1
  42. package/dist/loop.js.map +1 -1
  43. package/dist/model-pricing.js +1 -1
  44. package/dist/model-pricing.js.map +1 -1
  45. package/dist/model.d.ts +20 -2
  46. package/dist/model.d.ts.map +1 -1
  47. package/dist/model.js +88 -9
  48. package/dist/model.js.map +1 -1
  49. package/dist/persistent-agent.d.ts +1 -1
  50. package/dist/persistent-agent.d.ts.map +1 -1
  51. package/dist/persistent-agent.js.map +1 -1
  52. package/dist/pi-loop-runtime.d.ts.map +1 -1
  53. package/dist/pi-loop-runtime.js +142 -8
  54. package/dist/pi-loop-runtime.js.map +1 -1
  55. package/dist/policied-sandbox.d.ts +9 -3
  56. package/dist/policied-sandbox.d.ts.map +1 -1
  57. package/dist/policied-sandbox.js +290 -54
  58. package/dist/policied-sandbox.js.map +1 -1
  59. package/dist/policy.d.ts +3 -3
  60. package/dist/policy.d.ts.map +1 -1
  61. package/dist/policy.js +115 -64
  62. package/dist/policy.js.map +1 -1
  63. package/dist/proposal-tool.d.ts +260 -0
  64. package/dist/proposal-tool.d.ts.map +1 -0
  65. package/dist/proposal-tool.js +562 -0
  66. package/dist/proposal-tool.js.map +1 -0
  67. package/dist/sandbox-ref.d.ts +2 -2
  68. package/dist/sandbox-ref.d.ts.map +1 -1
  69. package/dist/sandbox-ref.js +143 -70
  70. package/dist/sandbox-ref.js.map +1 -1
  71. package/dist/sandbox.d.ts +8 -0
  72. package/dist/sandbox.d.ts.map +1 -1
  73. package/dist/sandbox.js +22 -1
  74. package/dist/sandbox.js.map +1 -1
  75. package/dist/session.d.ts +71 -3
  76. package/dist/session.d.ts.map +1 -1
  77. package/dist/session.js +590 -160
  78. package/dist/session.js.map +1 -1
  79. package/dist/stop-reason-guard.d.ts +89 -0
  80. package/dist/stop-reason-guard.d.ts.map +1 -0
  81. package/dist/stop-reason-guard.js +261 -0
  82. package/dist/stop-reason-guard.js.map +1 -0
  83. package/dist/strict.d.ts +8 -1
  84. package/dist/strict.d.ts.map +1 -1
  85. package/dist/strict.js +4 -1
  86. package/dist/strict.js.map +1 -1
  87. package/dist/suspending-sandbox.d.ts +2 -2
  88. package/dist/suspending-sandbox.d.ts.map +1 -1
  89. package/dist/suspending-sandbox.js +65 -26
  90. package/dist/suspending-sandbox.js.map +1 -1
  91. package/dist/tools.d.ts +17 -3
  92. package/dist/tools.d.ts.map +1 -1
  93. package/dist/tools.js +104 -48
  94. package/dist/tools.js.map +1 -1
  95. package/dist/types.d.ts +20 -0
  96. package/dist/types.d.ts.map +1 -1
  97. package/dist/types.js.map +1 -1
  98. package/dist/voice-pipeline.d.ts +67 -0
  99. package/dist/voice-pipeline.d.ts.map +1 -1
  100. package/dist/voice-pipeline.js +350 -20
  101. package/dist/voice-pipeline.js.map +1 -1
  102. package/dist/voice-sentences.d.ts +43 -0
  103. package/dist/voice-sentences.d.ts.map +1 -0
  104. package/dist/voice-sentences.js +99 -0
  105. package/dist/voice-sentences.js.map +1 -0
  106. package/package.json +30 -13
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,OAAO,EAAE,iBAAiB,EAA6B,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAa9F,qBAAa,eAAgB,YAAW,WAAW;IAUrC,OAAO,CAAC,QAAQ,CAAC,OAAO;IATpC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAA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AC,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CA4IrF;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,CAAC,OAAO,GAAE,SAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAexE"}
package/dist/agent.js CHANGED
@@ -108,6 +108,10 @@ export class StubFabricAgent {
108
108
  if (sessionOptions.streamRecovery === undefined && this.options.streamRecovery !== undefined) {
109
109
  sessionOptions.streamRecovery = this.options.streamRecovery;
110
110
  }
111
+ if (sessionOptions.stopReasonGuard === undefined &&
112
+ this.options.stopReasonGuard !== undefined) {
113
+ sessionOptions.stopReasonGuard = this.options.stopReasonGuard;
114
+ }
111
115
  if (sessionOptions.persistence === undefined && this.options.persistence !== undefined) {
112
116
  sessionOptions.persistence = this.options.persistence;
113
117
  }
@@ -146,6 +150,10 @@ export class StubFabricAgent {
146
150
  this.options.approvalTimeoutMs !== undefined) {
147
151
  sessionOptions.approvalTimeoutMs = this.options.approvalTimeoutMs;
148
152
  }
153
+ if (sessionOptions.proposalAuthority === undefined &&
154
+ this.options.proposalAuthority !== undefined) {
155
+ sessionOptions.proposalAuthority = this.options.proposalAuthority;
156
+ }
149
157
  if (sessionOptions.sessionRuntime === undefined && this.options.sessionRuntime !== undefined) {
150
158
  sessionOptions.sessionRuntime = this.options.sessionRuntime;
151
159
  }
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,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@ -1,5 +1,7 @@
1
1
  export { bytesToHex, conversationKey, defineChannel, hexToBytes, hmacSha256, parseConversationKey, readJsonBody, readRequestBody, verifyHmacSha256, } from './channel.js';
2
2
  export type { Channel, ChannelContext, ChannelDispatch, ChannelDispatchRequest, ChannelRoute, ParsedConversationKey, RequestBody, } from './channel.js';
3
+ export { ConversationOwnedByPersonError, ConversationOwnershipReadError, agentMaySend, assertAgentMaySend, handBack, inMemoryConversationOwnershipStore, readConversationOwnership, takeOver, withConversationOwnership, } from './conversation-ownership.js';
4
+ export type { ConversationOwner, ConversationOwnership, ConversationOwnershipChannelOptions, ConversationOwnershipClock, ConversationOwnershipReadErrorKind, ConversationOwnershipState, ConversationOwnershipStore, HandBackOptions, PersonOwnedMessage, TakeOverOptions, } from './conversation-ownership.js';
3
5
  export type { ToolDef, ToolEffect } from './tools.js';
4
6
  import type { ToolDef } from './tools.js';
5
7
  /** Edge-safe identity helper equivalent to the root SDK's `defineTool`. */
@@ -1 +1 @@
1
- {"version":3,"file":"channel-runtime.d.ts","sourceRoot":"","sources":["../src/channel-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,OAAO,EACP,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EACrB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAExH"}
1
+ {"version":3,"file":"channel-runtime.d.ts","sourceRoot":"","sources":["../src/channel-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,OAAO,EACP,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EACrB,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,kCAAkC,EAClC,yBAAyB,EACzB,QAAQ,EACR,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,iBAAiB,EACjB,qBAAqB,EACrB,mCAAmC,EACnC,0BAA0B,EAC1B,kCAAkC,EAClC,0BAA0B,EAC1B,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,EAClB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,2EAA2E;AAC3E,wBAAgB,UAAU,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAExH"}
@@ -1,4 +1,5 @@
1
1
  export { bytesToHex, conversationKey, defineChannel, hexToBytes, hmacSha256, parseConversationKey, readJsonBody, readRequestBody, verifyHmacSha256, } from './channel.js';
2
+ export { ConversationOwnedByPersonError, ConversationOwnershipReadError, agentMaySend, assertAgentMaySend, handBack, inMemoryConversationOwnershipStore, readConversationOwnership, takeOver, withConversationOwnership, } from './conversation-ownership.js';
2
3
  /** Edge-safe identity helper equivalent to the root SDK's `defineTool`. */
3
4
  export function defineTool(tool) {
4
5
  return tool;
@@ -1 +1 @@
1
- {"version":3,"file":"channel-runtime.js","sourceRoot":"","sources":["../src/channel-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAatB,2EAA2E;AAC3E,MAAM,UAAU,UAAU,CAAsC,IAA8B;IAC5F,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"channel-runtime.js","sourceRoot":"","sources":["../src/channel-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,aAAa,EACb,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAUtB,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,kCAAkC,EAClC,yBAAyB,EACzB,QAAQ,EACR,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAgBrC,2EAA2E;AAC3E,MAAM,UAAU,UAAU,CAAsC,IAA8B;IAC5F,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/channel.d.ts CHANGED
@@ -38,6 +38,17 @@ export interface ChannelDispatchRequest {
38
38
  dedupeKey?: string;
39
39
  tenantId?: string;
40
40
  actor?: FabricActor;
41
+ /**
42
+ * The conversation key ownership is decided on, when it differs from `instanceId`: for example a
43
+ * Twilio delivery status is dispatched to the instance recorded with the sent message but owned
44
+ * under the conversation's address key. `null` means the channel could not determine the key.
45
+ * When the field is present, `withConversationOwnership` reads ownership of this key instead of
46
+ * `instanceId`, refuses the dispatch unless it is a non-blank string (so `null`, `undefined` and
47
+ * blank fail closed), and removes the field before it dispatches. It is not part
48
+ * of the delivered message; the Node runtime's dispatch does not read it. An unwrapped Twilio
49
+ * channel sets it on its requests too, so whatever supplies dispatch receives it.
50
+ */
51
+ ownershipKey?: string | null;
41
52
  }
42
53
  export type ChannelDispatch = (agent: string, request: ChannelDispatchRequest) => Promise<DispatchReceipt>;
43
54
  export interface ChannelContext {
@@ -1 +1 @@
1
- {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;GAKG;AAEH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;CACtF;AAED,MAAM,WAAW,OAAO;IACtB,qFAAqF;IACrF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IACzC,sFAAsF;IACtF,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;IACtC,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3C;AAED,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CA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IAAI,IAAI;YAAE,MAAM;QAChB,KAAK,IAAI,KAAK,CAAC,UAAU,CAAC;QAC1B,IAAI,KAAK,GAAG,UAAU,EAAE,CAAC;YACvB,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC7C,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAWD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB,EAAE,UAAU,GAAG,kBAAkB;IAClF,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC"}
package/dist/context.d.ts CHANGED
@@ -1,3 +1,31 @@
1
+ import type { DefinedAgent } from './agent-definition.js';
2
+ import type { ModelProvider } from './model.js';
3
+ import type { ModelConfig } from './providers.js';
1
4
  import type { FabricContext, JsonObject } from './types.js';
2
5
  export declare function createFabricContext<TPayload extends JsonObject = JsonObject>(payload: TPayload): FabricContext<TPayload>;
6
+ /** What `runDefinedAgent()` injects into the agent it runs. */
7
+ export interface RunDefinedAgentOptions {
8
+ /**
9
+ * Default provider for the agent's `init()`. Overrides the agent's own `init` setting;
10
+ * an explicit `ctx.session(id, { modelProvider })` still overrides it for that session.
11
+ */
12
+ modelProvider?: ModelProvider;
13
+ /**
14
+ * Default model for the agent's `init()`. Overrides the definition's `model`; an explicit
15
+ * `ctx.session(id, { model })` still overrides it for that session.
16
+ */
17
+ model?: ModelConfig;
18
+ /**
19
+ * Cancellation for the run, exposed to the agent as `ctx.signal`. The agent
20
+ * passes it on, for example as `ctx.prompt(text, { signal: ctx.signal })`.
21
+ */
22
+ signal?: AbortSignal;
23
+ }
24
+ /**
25
+ * Run a `defineAgent()` agent in process with an injected model provider,
26
+ * model and abort signal. The agent's `init()` options are kept, and the
27
+ * provider and model given here replace the ones they name as `init()`
28
+ * defaults; an explicit `ctx.session(id, { model, modelProvider })` overrides them.
29
+ */
30
+ export declare function runDefinedAgent<TInput, TOutput>(agent: DefinedAgent<TInput, TOutput>, input: TInput, options?: RunDefinedAgentOptions): Promise<TOutput>;
3
31
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE5D,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,UAAU,GAAG,UAAU,EAC1E,OAAO,EAAE,QAAQ,GAChB,aAAa,CAAC,QAAQ,CAAC,CAKzB"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAa,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvE,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,UAAU,GAAG,UAAU,EAC1E,OAAO,EAAE,QAAQ,GAChB,aAAa,CAAC,QAAQ,CAAC,CAKzB;AAED,+DAA+D;AAC/D,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,OAAO,EACnD,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,OAAO,CAAC,CAYlB"}
package/dist/context.js CHANGED
@@ -5,4 +5,22 @@ export function createFabricContext(payload) {
5
5
  payload,
6
6
  };
7
7
  }
8
+ /**
9
+ * Run a `defineAgent()` agent in process with an injected model provider,
10
+ * model and abort signal. The agent's `init()` options are kept, and the
11
+ * provider and model given here replace the ones they name as `init()`
12
+ * defaults; an explicit `ctx.session(id, { model, modelProvider })` overrides them.
13
+ */
14
+ export async function runDefinedAgent(agent, input, options = {}) {
15
+ const context = {
16
+ payload: input,
17
+ init: (initOptions = {}) => init({
18
+ ...initOptions,
19
+ ...(options.modelProvider !== undefined ? { modelProvider: options.modelProvider } : {}),
20
+ ...(options.model !== undefined ? { model: options.model } : {}),
21
+ }),
22
+ ...(options.signal !== undefined ? { signal: options.signal } : {}),
23
+ };
24
+ return agent(context);
25
+ }
8
26
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC,MAAM,UAAU,mBAAmB,CACjC,OAAiB;IAEjB,OAAO;QACL,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMlC,MAAM,UAAU,mBAAmB,CACjC,OAAiB;IAEjB,OAAO;QACL,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC;AAqBD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAoC,EACpC,KAAa,EACb,UAAkC,EAAE;IAEpC,MAAM,OAAO,GAA0B;QACrC,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC,cAAyB,EAAE,EAAE,EAAE,CACpC,IAAI,CAAC;YACH,GAAG,WAAW;YACd,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxF,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjE,CAAC;QACJ,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,CAAC;IACF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,151 @@
1
+ import type { Channel, ChannelDispatchRequest } from './channel.js';
2
+ /**
3
+ * Conversation ownership lets a person take a conversation over from an agent and hand it back.
4
+ * The record is keyed by the channel's conversation key: the dispatch `ownershipKey` when the
5
+ * channel sets one, otherwise the dispatch `instanceId`. A conversation with no record is owned by the agent. The application
6
+ * supplies the store, so the record can live under its own governed state.
7
+ */
8
+ export type ConversationOwner = 'agent' | 'person';
9
+ /**
10
+ * One ownership record. Times are UTC ISO 8601 instants in the form `Date#toISOString` writes
11
+ * (`2026-11-19T12:00:00.000Z`); a reader treats any other form as an invalid record.
12
+ */
13
+ export interface ConversationOwnership {
14
+ owner: ConversationOwner;
15
+ /** The person who took the conversation over or handed it back. */
16
+ takenBy: string;
17
+ /** When the record was written. */
18
+ takenAt: string;
19
+ /** When a person's ownership lapses and the agent owns the conversation again. Ignored for an agent record. */
20
+ expiresAt?: string;
21
+ }
22
+ /**
23
+ * Application-owned ownership records. Implement it over durable storage: `setOwnership` should
24
+ * resolve only once the record is durable, and `getOwnership` should reject (not resolve
25
+ * `undefined`) when it cannot read the store, because `undefined` means the agent owns the
26
+ * conversation.
27
+ */
28
+ export interface ConversationOwnershipStore {
29
+ getOwnership(conversationKey: string): Promise<ConversationOwnership | undefined>;
30
+ setOwnership(conversationKey: string, ownership: ConversationOwnership): Promise<void>;
31
+ }
32
+ /** Who owns a conversation now, after expiry is applied, and the record that decided it, if any. */
33
+ export type ConversationOwnershipState = {
34
+ owner: 'agent';
35
+ ownership?: ConversationOwnership;
36
+ } | {
37
+ owner: 'person';
38
+ ownership: ConversationOwnership;
39
+ };
40
+ export interface ConversationOwnershipClock {
41
+ /** Milliseconds since the epoch; `Date.now` when omitted. */
42
+ now?: () => number;
43
+ }
44
+ /**
45
+ * The agent may not act on this conversation because a person owns it. The message names neither
46
+ * the conversation key nor the person, since a key can carry phone numbers; read the fields.
47
+ */
48
+ export declare class ConversationOwnedByPersonError extends Error {
49
+ readonly conversationKey: string;
50
+ readonly ownership: ConversationOwnership;
51
+ name: string;
52
+ constructor(conversationKey: string, ownership: ConversationOwnership);
53
+ }
54
+ /**
55
+ * Why ownership could not be read: the store rejected, it returned a record of the wrong shape, or
56
+ * the dispatch did not identify a conversation to read (it has an `ownershipKey` field that is not a non-blank string).
57
+ */
58
+ export type ConversationOwnershipReadErrorKind = 'read_failed' | 'invalid_record' | 'unknown_conversation';
59
+ /**
60
+ * Ownership could not be read, so the caller treats the conversation as not agent-owned: an agent
61
+ * send is refused and an inbound message is not dispatched.
62
+ */
63
+ export declare class ConversationOwnershipReadError extends Error {
64
+ readonly kind: ConversationOwnershipReadErrorKind;
65
+ /** The key that was read; `undefined` for `unknown_conversation`. */
66
+ readonly conversationKey: string | undefined;
67
+ name: string;
68
+ constructor(kind: ConversationOwnershipReadErrorKind,
69
+ /** The key that was read; `undefined` for `unknown_conversation`. */
70
+ conversationKey: string | undefined, cause?: unknown);
71
+ }
72
+ /**
73
+ * Reads who owns a conversation now. A missing record, or a person's record whose `expiresAt` is
74
+ * at or before `now`, means the agent. Rejects with {@link ConversationOwnershipReadError} when
75
+ * the store rejects or returns a record of the wrong shape.
76
+ */
77
+ export declare function readConversationOwnership(store: Pick<ConversationOwnershipStore, 'getOwnership'>, conversationKey: string, options?: ConversationOwnershipClock): Promise<ConversationOwnershipState>;
78
+ /** Whether an agent may send on this conversation now. Rejects, rather than answering, when ownership cannot be read. */
79
+ export declare function agentMaySend(store: Pick<ConversationOwnershipStore, 'getOwnership'>, conversationKey: string, options?: ConversationOwnershipClock): Promise<boolean>;
80
+ /**
81
+ * Resolves when an agent may send on this conversation now; rejects with
82
+ * {@link ConversationOwnedByPersonError} when a person owns it, or with
83
+ * {@link ConversationOwnershipReadError} when ownership cannot be read. Call it immediately before
84
+ * the provider request: a takeover written after this resolves is not seen by that send.
85
+ */
86
+ export declare function assertAgentMaySend(store: Pick<ConversationOwnershipStore, 'getOwnership'>, conversationKey: string, options?: ConversationOwnershipClock): Promise<void>;
87
+ export interface TakeOverOptions extends ConversationOwnershipClock {
88
+ /** The person taking the conversation over. */
89
+ by: string;
90
+ /** When the takeover lapses on its own: a `Date`, or a string in the `Date#toISOString` form. Must be later than `now`. */
91
+ expiresAt?: Date | string;
92
+ }
93
+ /** Records that a person owns the conversation. Resolves the record written. */
94
+ export declare function takeOver(store: Pick<ConversationOwnershipStore, 'setOwnership'>, conversationKey: string, options: TakeOverOptions): Promise<ConversationOwnership>;
95
+ export interface HandBackOptions extends ConversationOwnershipClock {
96
+ /** The person handing the conversation back to the agent. */
97
+ by: string;
98
+ }
99
+ /** Records that the agent owns the conversation again. Resolves the record written. */
100
+ export declare function handBack(store: Pick<ConversationOwnershipStore, 'setOwnership'>, conversationKey: string, options: HandBackOptions): Promise<ConversationOwnership>;
101
+ /**
102
+ * Test/development ownership store. Not durable: records live in process memory. It validates and
103
+ * keeps its own copy of each record and returns a fresh copy from `getOwnership`.
104
+ */
105
+ export declare function inMemoryConversationOwnershipStore(): ConversationOwnershipStore;
106
+ /** An inbound message that reached a person-owned conversation instead of the agent. */
107
+ export interface PersonOwnedMessage {
108
+ /** The agent the channel would have dispatched to. */
109
+ agent: string;
110
+ /** The dispatch request the channel built, unchanged. */
111
+ request: ChannelDispatchRequest;
112
+ /** The person's ownership record. */
113
+ ownership: ConversationOwnership;
114
+ }
115
+ export interface ConversationOwnershipChannelOptions extends ConversationOwnershipClock {
116
+ store: Pick<ConversationOwnershipStore, 'getOwnership'>;
117
+ /**
118
+ * Awaited for each dispatch the channel makes on a person-owned conversation; the agent is not
119
+ * dispatched to. A rejection rejects the channel's dispatch call, so the webhook request fails.
120
+ */
121
+ onPersonOwnedMessage: (message: PersonOwnedMessage) => void | Promise<void>;
122
+ }
123
+ /**
124
+ * Wraps a channel whose inbound goes through the route-provided `ChannelContext.dispatch`, so each
125
+ * dispatch it makes checks the conversation's owner first. On a person-owned conversation the
126
+ * receipt the channel gets back has no agent submission behind it, and it carries
127
+ * `handledBy: 'person'`; a receipt from the runtime's own dispatch has no `handledBy`. Code that
128
+ * reads the receipt (the generated webhook channel returns it whole as its 202 body) can tell the
129
+ * two outcomes apart by that field. Polling a person-handled `dispatchId` still finds nothing.
130
+ *
131
+ * Ownership is read for the request's `ownershipKey` when it has one, otherwise for its
132
+ * `instanceId`; the request still goes to its `instanceId`, and `ownershipKey` is removed before
133
+ * the runtime's dispatch is called. While a person owns that conversation, the request goes to
134
+ * `onPersonOwnedMessage` and the channel's dispatch call resolves a receipt whose `dispatchId` is
135
+ * the request's `dedupeKey` (or a random id); no agent submission exists for it. When ownership
136
+ * cannot be read, or the request has an `ownershipKey` field that is not a non-blank string (a
137
+ * channel sends `null` when it could not tell which conversation the dispatch belongs to), the
138
+ * dispatch call rejects with
139
+ * {@link ConversationOwnershipReadError} and nothing is dispatched.
140
+ * Work a channel does outside its dispatch calls, such as Twilio's keyword callbacks and delivery
141
+ * hooks, is not affected. The wrapper reads ownership when the channel dispatches; a takeover
142
+ * written after that read does not stop the agent turn that dispatch starts.
143
+ *
144
+ * The returned channel is a new object with the original's prototype and own properties, with
145
+ * `routes` replaced, so a class-based channel keeps its methods and `instanceof`. The original is
146
+ * not changed. It is a copy, so a channel whose methods read `#private` fields is not supported
147
+ * (the copy does not carry them); pass such a channel's behavior as a plain object, as
148
+ * `defineChannel` returns.
149
+ */
150
+ export declare function withConversationOwnership<C extends Channel>(channel: C, options: ConversationOwnershipChannelOptions): C;
151
+ //# sourceMappingURL=conversation-ownership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-ownership.d.ts","sourceRoot":"","sources":["../src/conversation-ownership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAmC,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAGrG;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,iBAAiB,CAAC;IACzB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,+GAA+G;IAC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AO,EAAE,sBAAsB,CAAC;IAChC,qCAAqC;IACrC,SAAS,EAAE,qBAAqB,CAAC;CAClC;AAED,MAAM,WAAW,mCAAoC,SAAQ,0BAA0B;IACrF,KAAK,EAAE,IAAI,CAAC,0BAA0B,EAAE,cAAc,CAAC,CAAC;IACxD;;;OAGG;IACH,oBAAoB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,mCAAmC,GAAG,CAAC,CAkCxH"}
@@ -0,0 +1,239 @@
1
+ /**
2
+ * The agent may not act on this conversation because a person owns it. The message names neither
3
+ * the conversation key nor the person, since a key can carry phone numbers; read the fields.
4
+ */
5
+ export class ConversationOwnedByPersonError extends Error {
6
+ conversationKey;
7
+ ownership;
8
+ name = 'ConversationOwnedByPersonError';
9
+ constructor(conversationKey, ownership) {
10
+ super('A person owns this conversation; the agent may not send on it until it is handed back');
11
+ this.conversationKey = conversationKey;
12
+ this.ownership = ownership;
13
+ }
14
+ }
15
+ /**
16
+ * Ownership could not be read, so the caller treats the conversation as not agent-owned: an agent
17
+ * send is refused and an inbound message is not dispatched.
18
+ */
19
+ export class ConversationOwnershipReadError extends Error {
20
+ kind;
21
+ conversationKey;
22
+ name = 'ConversationOwnershipReadError';
23
+ constructor(kind,
24
+ /** The key that was read; `undefined` for `unknown_conversation`. */
25
+ conversationKey, cause) {
26
+ super(kind === 'read_failed'
27
+ ? 'Conversation ownership could not be read; refusing to act for the agent'
28
+ : kind === 'invalid_record'
29
+ ? 'Conversation ownership store returned an invalid record; refusing to act for the agent'
30
+ : 'The dispatch does not identify the conversation whose ownership decides it; refusing to act for the agent', { cause });
31
+ this.kind = kind;
32
+ this.conversationKey = conversationKey;
33
+ }
34
+ }
35
+ const text = (value) => (typeof value === 'string' && value.trim() ? value : undefined);
36
+ // A timestamp is accepted only in the exact form Date#toISOString writes (UTC, millisecond precision,
37
+ // "Z" suffix) and only when it round-trips, so a date Date.parse would roll over (2026-02-30 becomes
38
+ // March 2) or an offset form is refused rather than reinterpreted (tests: conversation-ownership.test.ts).
39
+ const ISO_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
40
+ const isTime = (value) => {
41
+ if (typeof value !== 'string' || !ISO_INSTANT.test(value))
42
+ return false;
43
+ const at = new Date(value);
44
+ return Number.isFinite(at.getTime()) && at.toISOString() === value;
45
+ };
46
+ /**
47
+ * `Date#toISOString` of a time, or `"Invalid Date"` where that would throw. Not validated here: the
48
+ * record it goes into is checked by {@link requireRecord}, which rejects a signed six-digit year too.
49
+ */
50
+ function instant(ms) {
51
+ const value = new Date(ms);
52
+ return Number.isNaN(value.getTime()) ? String(value) : value.toISOString();
53
+ }
54
+ function requireKey(conversationKey) {
55
+ const key = text(conversationKey);
56
+ if (!key)
57
+ throw new TypeError('Conversation key must be a non-blank string');
58
+ return key;
59
+ }
60
+ /**
61
+ * Copies a record's documented fields, or returns undefined when it does not have the shape: owner
62
+ * exactly `agent` or `person`, a non-blank `takenBy`, a `takenAt` in the `Date#toISOString` form,
63
+ * and `expiresAt` absent or in that form. The reader and the writers (`takeOver`, `handBack`, the
64
+ * in-memory store) all validate with this function (writers through {@link requireRecord}), so a
65
+ * writer refuses what the reader would reject.
66
+ */
67
+ function readOwnershipRecord(value) {
68
+ if (typeof value !== 'object' || value === null)
69
+ return undefined;
70
+ const source = value;
71
+ const { owner, takenBy, takenAt, expiresAt } = source;
72
+ if (owner !== 'agent' && owner !== 'person')
73
+ return undefined;
74
+ if (!text(takenBy) || !isTime(takenAt))
75
+ return undefined;
76
+ if (expiresAt !== undefined && !isTime(expiresAt))
77
+ return undefined;
78
+ return { owner, takenBy: takenBy, takenAt, ...(expiresAt !== undefined ? { expiresAt } : {}) };
79
+ }
80
+ /**
81
+ * Reads who owns a conversation now. A missing record, or a person's record whose `expiresAt` is
82
+ * at or before `now`, means the agent. Rejects with {@link ConversationOwnershipReadError} when
83
+ * the store rejects or returns a record of the wrong shape.
84
+ */
85
+ export async function readConversationOwnership(store, conversationKey, options = {}) {
86
+ const key = requireKey(conversationKey);
87
+ let found;
88
+ try {
89
+ found = await store.getOwnership(key);
90
+ }
91
+ catch (cause) {
92
+ throw new ConversationOwnershipReadError('read_failed', key, cause);
93
+ }
94
+ if (found === undefined)
95
+ return { owner: 'agent' };
96
+ const ownership = readOwnershipRecord(found);
97
+ if (!ownership)
98
+ throw new ConversationOwnershipReadError('invalid_record', key);
99
+ const now = (options.now ?? Date.now)();
100
+ const lapsed = ownership.expiresAt !== undefined && Date.parse(ownership.expiresAt) <= now;
101
+ return ownership.owner === 'person' && !lapsed ? { owner: 'person', ownership } : { owner: 'agent', ownership };
102
+ }
103
+ /** Whether an agent may send on this conversation now. Rejects, rather than answering, when ownership cannot be read. */
104
+ export async function agentMaySend(store, conversationKey, options = {}) {
105
+ return (await readConversationOwnership(store, conversationKey, options)).owner === 'agent';
106
+ }
107
+ /**
108
+ * Resolves when an agent may send on this conversation now; rejects with
109
+ * {@link ConversationOwnedByPersonError} when a person owns it, or with
110
+ * {@link ConversationOwnershipReadError} when ownership cannot be read. Call it immediately before
111
+ * the provider request: a takeover written after this resolves is not seen by that send.
112
+ */
113
+ export async function assertAgentMaySend(store, conversationKey, options = {}) {
114
+ const state = await readConversationOwnership(store, conversationKey, options);
115
+ if (state.owner === 'person')
116
+ throw new ConversationOwnedByPersonError(conversationKey, state.ownership);
117
+ }
118
+ /** Records that a person owns the conversation. Resolves the record written. */
119
+ export async function takeOver(store, conversationKey, options) {
120
+ const key = requireKey(conversationKey);
121
+ const by = text(options.by);
122
+ if (!by)
123
+ throw new TypeError('takeOver needs a non-blank "by"');
124
+ const now = (options.now ?? Date.now)();
125
+ let expiresAt;
126
+ if (options.expiresAt !== undefined) {
127
+ const at = options.expiresAt instanceof Date ? options.expiresAt.getTime() : isTime(options.expiresAt) ? Date.parse(options.expiresAt) : Number.NaN;
128
+ if (!Number.isFinite(at) || at <= now)
129
+ throw new TypeError('takeOver expiresAt must be a valid time after now');
130
+ expiresAt = instant(at);
131
+ }
132
+ const ownership = requireRecord('takeOver', { owner: 'person', takenBy: by, takenAt: instant(now), ...(expiresAt !== undefined ? { expiresAt } : {}) });
133
+ await store.setOwnership(key, { ...ownership });
134
+ return ownership;
135
+ }
136
+ /** Records that the agent owns the conversation again. Resolves the record written. */
137
+ export async function handBack(store, conversationKey, options) {
138
+ const key = requireKey(conversationKey);
139
+ const by = text(options.by);
140
+ if (!by)
141
+ throw new TypeError('handBack needs a non-blank "by"');
142
+ const ownership = requireRecord('handBack', { owner: 'agent', takenBy: by, takenAt: instant((options.now ?? Date.now)()) });
143
+ await store.setOwnership(key, { ...ownership });
144
+ return ownership;
145
+ }
146
+ /**
147
+ * The record as the reader would return it. Throws a TypeError when the reader would reject it; each
148
+ * writer calls this before it writes, so it does not persist a record its own reader rejects (for
149
+ * example a time whose ISO form has a six-digit year, from a far-future Date or an injected clock).
150
+ */
151
+ function requireRecord(writer, ownership) {
152
+ const record = readOwnershipRecord(ownership);
153
+ if (!record)
154
+ throw new TypeError(`${writer}: invalid conversation ownership record (times must be Date#toISOString instants between years 0 and 9999)`);
155
+ return record;
156
+ }
157
+ /**
158
+ * Test/development ownership store. Not durable: records live in process memory. It validates and
159
+ * keeps its own copy of each record and returns a fresh copy from `getOwnership`.
160
+ */
161
+ export function inMemoryConversationOwnershipStore() {
162
+ const records = new Map();
163
+ return {
164
+ async getOwnership(conversationKey) {
165
+ const record = records.get(conversationKey);
166
+ return record ? { ...record } : undefined;
167
+ },
168
+ async setOwnership(conversationKey, ownership) {
169
+ records.set(requireKey(conversationKey), requireRecord('setOwnership', ownership));
170
+ },
171
+ };
172
+ }
173
+ /**
174
+ * Wraps a channel whose inbound goes through the route-provided `ChannelContext.dispatch`, so each
175
+ * dispatch it makes checks the conversation's owner first. On a person-owned conversation the
176
+ * receipt the channel gets back has no agent submission behind it, and it carries
177
+ * `handledBy: 'person'`; a receipt from the runtime's own dispatch has no `handledBy`. Code that
178
+ * reads the receipt (the generated webhook channel returns it whole as its 202 body) can tell the
179
+ * two outcomes apart by that field. Polling a person-handled `dispatchId` still finds nothing.
180
+ *
181
+ * Ownership is read for the request's `ownershipKey` when it has one, otherwise for its
182
+ * `instanceId`; the request still goes to its `instanceId`, and `ownershipKey` is removed before
183
+ * the runtime's dispatch is called. While a person owns that conversation, the request goes to
184
+ * `onPersonOwnedMessage` and the channel's dispatch call resolves a receipt whose `dispatchId` is
185
+ * the request's `dedupeKey` (or a random id); no agent submission exists for it. When ownership
186
+ * cannot be read, or the request has an `ownershipKey` field that is not a non-blank string (a
187
+ * channel sends `null` when it could not tell which conversation the dispatch belongs to), the
188
+ * dispatch call rejects with
189
+ * {@link ConversationOwnershipReadError} and nothing is dispatched.
190
+ * Work a channel does outside its dispatch calls, such as Twilio's keyword callbacks and delivery
191
+ * hooks, is not affected. The wrapper reads ownership when the channel dispatches; a takeover
192
+ * written after that read does not stop the agent turn that dispatch starts.
193
+ *
194
+ * The returned channel is a new object with the original's prototype and own properties, with
195
+ * `routes` replaced, so a class-based channel keeps its methods and `instanceof`. The original is
196
+ * not changed. It is a copy, so a channel whose methods read `#private` fields is not supported
197
+ * (the copy does not carry them); pass such a channel's behavior as a plain object, as
198
+ * `defineChannel` returns.
199
+ */
200
+ export function withConversationOwnership(channel, options) {
201
+ const { store, onPersonOwnedMessage, now } = options ?? {};
202
+ if (typeof store?.getOwnership !== 'function')
203
+ throw new TypeError('withConversationOwnership needs a store with getOwnership');
204
+ if (typeof onPersonOwnedMessage !== 'function')
205
+ throw new TypeError('withConversationOwnership needs an onPersonOwnedMessage callback');
206
+ const clock = now ? { now } : {};
207
+ const gate = (dispatch) => async (agent, request) => {
208
+ // A request that has an ownershipKey field is decided on it alone, never on instanceId; a field
209
+ // that is present but not a non-blank string (undefined, null, blank) fails closed like a failed read (tests: "refuses, without
210
+ // reading the store or dispatching, a dispatch whose ownershipKey is ...").
211
+ const { ownershipKey, ...forwarded } = request;
212
+ let conversationKey = request.instanceId;
213
+ if ('ownershipKey' in request) {
214
+ const key = text(ownershipKey);
215
+ if (!key)
216
+ throw new ConversationOwnershipReadError('unknown_conversation', undefined);
217
+ conversationKey = key;
218
+ }
219
+ const state = await readConversationOwnership(store, conversationKey, clock);
220
+ if (state.owner === 'agent')
221
+ return dispatch(agent, forwarded);
222
+ await onPersonOwnedMessage({ agent, request, ownership: state.ownership });
223
+ return { dispatchId: text(request.dedupeKey) ?? crypto.randomUUID(), acceptedAt: new Date((now ?? Date.now)()).toISOString(), handledBy: 'person' };
224
+ };
225
+ // Keep the prototype chain, so methods defined on a class prototype (conversationKey,
226
+ // parseConversationKey) still work and instanceof holds; the input channel is not changed. The
227
+ // wrapped routes go into the descriptor map, so nothing is redefined on the copy (a frozen
228
+ // channel's `routes` is non-configurable, and redefining it would throw).
229
+ const routes = channel.routes.map((route) => ({
230
+ ...route,
231
+ handler: (request, context) => route.handler(request, { ...context, dispatch: gate(context.dispatch) }),
232
+ }));
233
+ const wrapped = Object.create(Object.getPrototypeOf(channel), {
234
+ ...Object.getOwnPropertyDescriptors(channel),
235
+ routes: { value: routes, enumerable: true, writable: true, configurable: true },
236
+ });
237
+ return wrapped;
238
+ }
239
+ //# sourceMappingURL=conversation-ownership.js.map