@ouispec/agent-worker 0.4.0 → 0.8.0

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 (97) hide show
  1. package/README.md +57 -2
  2. package/dist/approvals/client.d.ts +8 -1
  3. package/dist/approvals/client.d.ts.map +1 -1
  4. package/dist/approvals/client.js +10 -0
  5. package/dist/approvals/client.js.map +1 -1
  6. package/dist/approvals/continuation.d.ts +13 -1
  7. package/dist/approvals/continuation.d.ts.map +1 -1
  8. package/dist/approvals/continuation.js +35 -0
  9. package/dist/approvals/continuation.js.map +1 -1
  10. package/dist/approvals/preview.d.ts +2 -2
  11. package/dist/approvals/preview.d.ts.map +1 -1
  12. package/dist/approvals/preview.js +20 -3
  13. package/dist/approvals/preview.js.map +1 -1
  14. package/dist/attachments/content.d.ts +68 -0
  15. package/dist/attachments/content.d.ts.map +1 -0
  16. package/dist/attachments/content.js +318 -0
  17. package/dist/attachments/content.js.map +1 -0
  18. package/dist/attachments/guard.d.ts +69 -0
  19. package/dist/attachments/guard.d.ts.map +1 -0
  20. package/dist/attachments/guard.js +86 -0
  21. package/dist/attachments/guard.js.map +1 -0
  22. package/dist/attachments/limits.d.ts +46 -0
  23. package/dist/attachments/limits.d.ts.map +1 -0
  24. package/dist/attachments/limits.js +64 -0
  25. package/dist/attachments/limits.js.map +1 -0
  26. package/dist/attachments/store.d.ts +85 -0
  27. package/dist/attachments/store.d.ts.map +1 -0
  28. package/dist/attachments/store.js +2 -0
  29. package/dist/attachments/store.js.map +1 -0
  30. package/dist/attachments/tools.d.ts +12 -0
  31. package/dist/attachments/tools.d.ts.map +1 -0
  32. package/dist/attachments/tools.js +216 -0
  33. package/dist/attachments/tools.js.map +1 -0
  34. package/dist/authz/tool-policy.d.ts +6 -0
  35. package/dist/authz/tool-policy.d.ts.map +1 -1
  36. package/dist/authz/tool-policy.js.map +1 -1
  37. package/dist/index.d.ts +12 -3
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +10 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/lambda/handler.d.ts +2 -2
  42. package/dist/lambda/handler.d.ts.map +1 -1
  43. package/dist/lambda/handler.js +3 -2
  44. package/dist/lambda/handler.js.map +1 -1
  45. package/dist/orchestrator.d.ts.map +1 -1
  46. package/dist/orchestrator.js +613 -101
  47. package/dist/orchestrator.js.map +1 -1
  48. package/dist/prompt/clock.d.ts +0 -17
  49. package/dist/prompt/clock.d.ts.map +1 -1
  50. package/dist/prompt/clock.js +19 -2
  51. package/dist/prompt/clock.js.map +1 -1
  52. package/dist/prompt/user-text.d.ts +19 -0
  53. package/dist/prompt/user-text.d.ts.map +1 -0
  54. package/dist/prompt/user-text.js +20 -0
  55. package/dist/prompt/user-text.js.map +1 -0
  56. package/dist/runtime/turn-runner.d.ts +29 -2
  57. package/dist/runtime/turn-runner.d.ts.map +1 -1
  58. package/dist/runtime/turn-runner.js +118 -9
  59. package/dist/runtime/turn-runner.js.map +1 -1
  60. package/dist/runtime/types.d.ts +84 -6
  61. package/dist/runtime/types.d.ts.map +1 -1
  62. package/dist/stop/partial.d.ts +49 -0
  63. package/dist/stop/partial.d.ts.map +1 -0
  64. package/dist/stop/partial.js +73 -0
  65. package/dist/stop/partial.js.map +1 -0
  66. package/dist/stop/results.d.ts +20 -0
  67. package/dist/stop/results.d.ts.map +1 -0
  68. package/dist/stop/results.js +46 -0
  69. package/dist/stop/results.js.map +1 -0
  70. package/dist/stop/turn-stop.d.ts +114 -0
  71. package/dist/stop/turn-stop.d.ts.map +1 -0
  72. package/dist/stop/turn-stop.js +159 -0
  73. package/dist/stop/turn-stop.js.map +1 -0
  74. package/dist/tools/input-validation.d.ts.map +1 -1
  75. package/dist/tools/input-validation.js +3 -0
  76. package/dist/tools/input-validation.js.map +1 -1
  77. package/dist/tools/types.d.ts +19 -0
  78. package/dist/tools/types.d.ts.map +1 -1
  79. package/dist/tools/types.js.map +1 -1
  80. package/dist/turn-policy.d.ts +14 -0
  81. package/dist/turn-policy.d.ts.map +1 -1
  82. package/dist/turn-policy.js.map +1 -1
  83. package/dist/types.d.ts +84 -3
  84. package/dist/types.d.ts.map +1 -1
  85. package/dist/ui/knowledge.d.ts +28 -2
  86. package/dist/ui/knowledge.d.ts.map +1 -1
  87. package/dist/ui/knowledge.js +117 -13
  88. package/dist/ui/knowledge.js.map +1 -1
  89. package/dist/ui/newest-page-state.d.ts +25 -0
  90. package/dist/ui/newest-page-state.d.ts.map +1 -0
  91. package/dist/ui/newest-page-state.js +91 -0
  92. package/dist/ui/newest-page-state.js.map +1 -0
  93. package/dist/ui/ui-tools.d.ts +20 -2
  94. package/dist/ui/ui-tools.d.ts.map +1 -1
  95. package/dist/ui/ui-tools.js +65 -6
  96. package/dist/ui/ui-tools.js.map +1 -1
  97. package/package.json +6 -6
package/README.md CHANGED
@@ -13,7 +13,7 @@ A missing value fails when the adapter is created, and the error names it. Nothi
13
13
  | Realtime server | `realtime: { url, apiKey }` | The `agent-sdk-realtime` server and its internal key. Turn events go to `POST {url}/api/emit`, and UI action answers are collected from `GET {url}/internal/oui/action-results/:id`. |
14
14
  | Persona | `persona` or `systemPrompt`, exactly one | The assistant's identity comes only from here. The shipped rules name no product. |
15
15
  | Tools | `tools` | A list, or a per-turn resolver. Pass `[]` when the only tools are the tab's UI actions. |
16
- | Persistence | `getDb`, `getHistory`, `persistMessages` | `getDb`'s handle is passed to every callback. `recordTurnStart`, `recordTurnComplete` and `recordTurnFailure` are optional. |
16
+ | Persistence | `getDb`, `getHistory`, `persistMessages` | `getDb`'s handle is passed to every callback. `recordTurnStart`, `recordTurnComplete` and `recordTurnFailure` are optional. See "Stopping a turn" for what each is told of a stopped or superseding turn. |
17
17
 
18
18
  Optional tuning, with its defaults:
19
19
  - `maxRounds`: 12
@@ -23,7 +23,7 @@ Optional tuning, with its defaults:
23
23
  - `turnDeadlineMs`: 14 min (keep it below your host's own limit)
24
24
  - `retries`: 3
25
25
 
26
- Policy hooks: `turnPolicy`, `toolPolicy`, `uiActions`, `approvals`, `logger`.
26
+ Policy hooks: `turnPolicy`, `toolPolicy`, `uiActions`, `approvals`, `stops`, `logger`.
27
27
 
28
28
  ## What a UI client sends with a turn
29
29
 
@@ -56,6 +56,61 @@ In a browser, the turn after the decision comes from `ApprovalCard` (`@ouispec/a
56
56
 
57
57
  Declare a host tool's approval needs on the tool itself: `effect`, `destructive`, `title`, `consequence`, and `argsSensitive: false` when its arguments may be logged. Without an approval store, such a call is refused and never runs. The runtime uses the realtime server's store unless you pass `approvals.store`.
58
58
 
59
+ ## Stopping a turn
60
+
61
+ A turn can be stopped by the person, or superseded by their next message. The request is kept by the realtime server (`@ouispec/agent-realtime`, "Stopping a turn"), and the turn asks for it there for as long as it runs. Nothing needs configuring: the runtime uses the realtime server you already gave it. `stops.graceMs` (default 2 s) is how long an answer already on its way is still waited for.
62
+
63
+ The turn asks its first question before it starts, so a stop asked for while it waited in a queue is heard first: the model is not called, and the turn stores only that it was stopped. Asking never holds a turn up or fails it: if the server cannot be asked, the turn runs and the question is asked again.
64
+
65
+ What a stopped turn does:
66
+
67
+ 1. Everything that was waiting ends: the model's stream, a UI action's answer, a job's outcome.
68
+ 2. Each call keeps exactly one result. A call that finished keeps its result. A UI action that was out takes one last look for its answer, so an action that did run is stored as run and is not done again; with no answer it is stored as sent with its outcome unknown, and the page is treated as unseen. A request no tab took, and an action that had not been sent, are stored as not run. A job the action started is not cancelled.
69
+ 3. `persistMessages` is called with what the turn had produced, and `stopped: { reason, at }`. The last assistant message carries the same marker (`TurnMessage.stopped`). Store it with the message and hand it back in history (`TurnHistoryMessage.stopped`): the model is then told, after that message's text, that the turn was stopped there. A turn that produced nothing still stores one assistant message, whose text is that line.
70
+ 4. Only then is the client told: `agent:turn_complete` with `stopReason` `user_stop`, `superseded` or `deadline`. `recordTurnComplete` receives the same `stopReason`, and the runner's outcome is `stopped`, not `failed`.
71
+
72
+ A stop that arrives once the turn has begun its own end is not one: the turn completes as it would have.
73
+
74
+ A turn that reaches its deadline (`turnDeadlineMs`) ends on the same path, with `stopReason: 'deadline'`: what it did before it ran out of time is kept, marked, and the next turn is told. If its store fails or does not finish in time, nothing of it was kept: the runner records it with `recordTurnFailure` as `TURN_DEADLINE_EXCEEDED`, and its outcome carries `stored: false`. A store that timed out may still finish after that, so record the failure only over a turn that is still running (a conditional update from `running`).
75
+
76
+ For a message sent while a turn is running (a barge-in), your API stops the running turn (`POST /internal/turns/:turnId/stop` with `superseded`), withdraws a waiting approval (`settle` with `expire`), and puts the ids of the turns it stopped on the new turn's payload as `supersedes`. The hooks then let you order the two:
77
+
78
+ | Hook | What it is told, and what it may answer |
79
+ |---|---|
80
+ | `getHistory(conversationId, db, turn)` | `turn.supersedes` names the turns to wait for before reading: read once each is stored, or once you have given up on it. `turn.signal` aborts if this turn is itself stopped while it waits. |
81
+ | `persistMessages(...)` | May answer `{ stored: false }` when you found the turn already given up on by a newer one and stored nothing. The turn is still announced, and nothing that depends on its messages being stored is done. |
82
+ | `recordTurnStart(...)` | May answer `{ run: false, reason }` when your record of the turn shows it already ended or was given up on, which is what a queue's redelivery of an old turn finds. The turn then does nothing: no model call, no UI action, no event. The runner's outcome is `refused`. |
83
+
84
+ Every UI action request names its turn (`turnId`). Give the tab's OUI runtime `accept: acceptCurrentTurn(agent.acceptedTurnId)` (`oui-spec`, `@ouispec/agent-react`), and a request a stopped or superseded turn sends late is refused by the tab and stored as not run.
85
+
86
+ ## Files the person attaches
87
+
88
+ A file is uploaded to your storage first, and a message carries its reference (`AttachmentRef`: id, name, checked media type, kind, size, and an image's size in pixels). Put the turn's files on its payload as `attachments`, and the earlier messages' files on their history messages (`TurnHistoryMessage.attachments`). Then give the runtime your file area:
89
+
90
+ ```ts
91
+ attachments: {
92
+ store: {
93
+ describe: (ids, owner, { signal }) => …, // the references of these files, if they are the owner's conversation's; `pending: true` while still checked
94
+ load: (id, owner, as, { range, signal }) => …, // 'image': the model's rendition; 'text': a page of its text; 'document': a PDF's bytes
95
+ list: (owner, { signal }) => …, // every file of the conversation
96
+ conversationUsage: (owner, { signal }) => …, // optional: tokens earlier turns gave the model, for the conversation's cap
97
+ },
98
+ turnTokens: 30_000, // the defaults
99
+ conversationTokens: 300_000,
100
+ perMessage: 5,
101
+ pdfAsDocument: false, // a short PDF as a document part, once your provider's document part is proven
102
+ }
103
+ ```
104
+
105
+ - **The turn's files** go to the model with its message: a picture as your model rendition (PNG, JPEG or WebP, at most 1,568 px and 1 MB; anything else is refused and named), a text file's text up to 20,000 characters (40,000 a turn), a PDF's text, anything else as its reference line. Each file once, at most `perMessage`. Earlier files are in history as their reference lines only.
106
+ - **A file that cannot be had** is named with why, and the turn goes on: a store call that throws, a load that answers `{ ok: false, reason: 'pending' }` (still being checked), `'gone'`, `'refused'` or `'unsupported'`. Every store call is given the turn's `signal`, aborted when the turn is stopped or runs out of time.
107
+ - **A file is data.** The system prompt tells the model a file's name and content are never instructions. Names reach it as one cleaned JSON string, and a file's text cannot close its own `<attachment>` block.
108
+ - **The tools** `attachment_list`, `attachment_view` and `attachment_read` reach every file of the conversation by its id. They are backend tools of the class `attachment` (`ToolPolicyContext.toolClass`; a turn policy's `prepareStep` gets each tool's class in `allTools`), not UI tools: admit the class in your tool policy.
109
+ - **The cost guard** counts what each model step carries, and from the step that would pass `turnTokens` (or what is left of `conversationTokens`) gives the costliest file's line instead of the file. `recordTurnComplete` receives `attachments` with `estimatedTokens`: keep it for the conversation's cap.
110
+ - **An action that takes a file** declares an input with `format: 'oui-attachment'` (OUI spec §7.3.11). The model passes the id. Before the call runs, the worker checks that it is a file of the turn's conversation, that its check has passed, and that its type is one the input takes; the approval card shows the file by name and size.
111
+
112
+ No file's bytes or text is in an event, the turn's record or a stored message: a picture `attachment_view` shows and the text `attachment_read` reads go to the model with that call's result and nowhere else.
113
+
59
114
  ## Lambda + SQS
60
115
 
61
116
  ```ts
@@ -4,7 +4,7 @@
4
4
  * pending approval when it stops a turn, redeems the token the next turn
5
5
  * carries, and reads a decline.
6
6
  */
7
- import type { ApprovalOwner, ApprovalRedeemResult, ApprovalSettlement, ApprovalStatus, PendingApprovalInput } from '@ouispec/agent-core';
7
+ import type { ApprovalOwner, ApprovalRedeemResult, ApprovalSettlement, ApprovalStatus, ApprovalWithdrawal, ApprovalWithdrawReason, PendingApprovalInput } from '@ouispec/agent-core';
8
8
  export interface ApprovalStoreClient {
9
9
  /** Store a pending approval. Rejects when it was not stored: the call must then not wait on it. */
10
10
  create(pending: PendingApprovalInput): Promise<void>;
@@ -27,6 +27,13 @@ export interface ApprovalStoreClient {
27
27
  * longer lapses. Called after the host has persisted the turn's messages.
28
28
  */
29
29
  confirmExpirySettled?(approvalId: string, owner: ApprovalOwner): Promise<void>;
30
+ /**
31
+ * Expire an approval now, saying why (ADR-0252 §2.6): the turn that asked
32
+ * for it was stopped, so its card must not stay live. Optional: a store
33
+ * without it leaves the approval to its time limit. Rejects when the store
34
+ * cannot be reached.
35
+ */
36
+ withdraw?(approvalId: string, owner: ApprovalOwner, reason: ApprovalWithdrawReason): Promise<ApprovalWithdrawal>;
30
37
  }
31
38
  export interface HttpApprovalStoreClientConfig {
32
39
  /** The realtime server's base URL. */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/approvals/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EAEpB,kBAAkB,EAClB,cAAc,EAEd,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,WAAW,mBAAmB;IAClC,mGAAmG;IACnG,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,uJAAuJ;IACvJ,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACzG,2EAA2E;IAC3E,MA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AI,CAAC,CAAC;IAC3E;;;;;OAKG;IACH,aAAa,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtF;;;OAGG;IACH,oBAAoB,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClH;AAED,MAAM,WAAW,6BAA6B;IAC5C,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,8DAA8D;AAC9D,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,6BAA6B,GAAG,mBAAmB,CAuExG"}
@@ -52,6 +52,16 @@ export function createHttpApprovalStoreClient(config) {
52
52
  throw new Error(`[agent-sdk] The approval store could not confirm approval ${approvalId} as settled: HTTP ${status}`);
53
53
  }
54
54
  },
55
+ async withdraw(approvalId, owner, reason) {
56
+ const { status, json } = await call(`/internal/approvals/${encodeURIComponent(approvalId)}/settle`, { ...owner, expire: reason });
57
+ // A realtime server from before this: it answers as a plain settle would, which is not a withdrawal.
58
+ if (status === 200 && (json.outcome === 'withdrawn' || json.outcome === 'settled' || json.outcome === 'unknown')) {
59
+ return json;
60
+ }
61
+ if (status === 200 || status === 404)
62
+ return { approvalId, outcome: 'unknown' };
63
+ throw new Error(`[agent-sdk] The approval store could not withdraw approval ${approvalId}: HTTP ${status}`);
64
+ },
55
65
  async status(approvalId, userId) {
56
66
  const { status, json } = await call(`/internal/approvals/${encodeURIComponent(approvalId)}?${new URLSearchParams({ userId })}`);
57
67
  if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C,UAAU,CAAC,IAAI,IAAI,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YAChI,IAAI,MAAM,KAAK,GAAG;gBAAE,OAAO,IAAiC,CAAC;YAC7D,IAAI,MAAM,KAAK,GAAG;gBAAE,OAAO,IAAI,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,4DAA4D,UAAU,UAAU,MAAM,EAAE,CAAC,CAAC;QAC5G,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * stored call when there is one, and tells the model what happened in an
6
6
  * `<approval>` block on the user's message.
7
7
  */
8
- import type { ApprovalContinuation, ApprovedCall } from '@ouispec/agent-core';
8
+ import type { ApprovalContinuation, ApprovalWithdrawReason, ApprovedCall } from '@ouispec/agent-core';
9
9
  import type { ApprovalStoreClient } from './client.js';
10
10
  export type ContinuationOutcome =
11
11
  /** Approved and redeemed: run this call, exactly. */
@@ -41,6 +41,12 @@ export interface ApprovalMarker {
41
41
  ran: boolean;
42
42
  /** The user approved it, and the approval expired before the call ran. */
43
43
  expired?: true;
44
+ /**
45
+ * The approval did not run out of time: it was withdrawn (ADR-0252 §2.6),
46
+ * because the user sent a new message while it waited, or stopped the turn
47
+ * that asked for it.
48
+ */
49
+ withdrawn?: ApprovalWithdrawReason;
44
50
  /** The same, in words: what the model reads. */
45
51
  summary: string;
46
52
  }
@@ -50,6 +56,11 @@ export declare function approvalMarker(decided: ApprovalDecided, ran: boolean, n
50
56
  * run it never did. Not "undecided": the person did decide.
51
57
  */
52
58
  export declare function approvedExpiredMarker(now?: Date): ApprovalMarker;
59
+ /**
60
+ * An approval that was withdrawn before it was used: said as what happened,
61
+ * not as time running out. One the user had approved keeps that they did.
62
+ */
63
+ export declare function withdrawnMarker(reason: ApprovalWithdrawReason, approved: boolean, now?: Date): ApprovalMarker;
53
64
  /** A call's result with its approval said first: an object gains `approval`; anything else is put beside it as `result`. */
54
65
  export declare function markedResult(text: string, marker: ApprovalMarker): string;
55
66
  /** The stored result of a call that will never run: declined, expired, or approved where it could not run. */
@@ -96,6 +107,7 @@ export declare function waitingCalls(history: ReadonlyArray<{
96
107
  export declare function expiredNote(expired: {
97
108
  undecided: number;
98
109
  approved: number;
110
+ withdrawn?: number;
99
111
  }): string;
100
112
  export declare function resolveContinuation(store: ApprovalStoreClient | undefined, continuation: ApprovalContinuation, turn: {
101
113
  userId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"continuation.d.ts","sourceRoot":"","sources":["../../src/approvals/continuation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAyB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,MAAM,mBAAmB;AAC7B,qDAAqD;AACnD;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE;AACrC;;;;GAIG;GACD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;CAAE,CAAC;AAEnF,iDAAiD;AACjD,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,eAAe,CAAC;IACzB,iGAAiG;IACjG,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,kFAAkF;IAClF,GAAG,EAAE,OAAO,CAAC;IACb,0EAA0E;IAC1E,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;CACjB;AAUD,wBAAgB,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,GAA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ED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAmBxG;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,mBAAmB,GAAG,SAAS,EACtC,YAAY,EAAE,oBAAoB,EAClC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAC/C,OAAO,CAAC,mBAAmB,CAAC,CA+B9B"}
@@ -16,6 +16,34 @@ export function approvalMarker(decided, ran, now = new Date()) {
16
16
  export function approvedExpiredMarker(now = new Date()) {
17
17
  return { decided: 'approved', by: 'user', at: now.toISOString(), ran: false, expired: true, summary: SUMMARY.approvedExpired };
18
18
  }
19
+ const WITHDRAWN_BECAUSE = {
20
+ superseded: 'the user sent a new message',
21
+ stopped: 'the user stopped the turn that asked for it',
22
+ };
23
+ /**
24
+ * An approval that was withdrawn before it was used: said as what happened,
25
+ * not as time running out. One the user had approved keeps that they did.
26
+ */
27
+ export function withdrawnMarker(reason, approved, now = new Date()) {
28
+ const because = WITHDRAWN_BECAUSE[reason];
29
+ return approved
30
+ ? {
31
+ decided: 'approved',
32
+ by: 'user',
33
+ at: now.toISOString(),
34
+ ran: false,
35
+ expired: true,
36
+ withdrawn: reason,
37
+ summary: `Approved by the user on the approval card, but withdrawn before it ran because ${because}. It was not run.`,
38
+ }
39
+ : {
40
+ decided: 'expired',
41
+ at: now.toISOString(),
42
+ ran: false,
43
+ withdrawn: reason,
44
+ summary: `The approval was withdrawn before the user decided it, because ${because}. It was not run.`,
45
+ };
46
+ }
19
47
  /** A call's result with its approval said first: an object gains `approval`; anything else is put beside it as `result`. */
20
48
  export function markedResult(text, marker) {
21
49
  let value = text;
@@ -104,6 +132,13 @@ export function waitingCalls(history) {
104
132
  */
105
133
  export function expiredNote(expired) {
106
134
  const parts = [];
135
+ const withdrawn = expired.withdrawn ?? 0;
136
+ if (withdrawn === 1) {
137
+ parts.push('An approval asked for earlier in this conversation was withdrawn before it ran, because the user sent a new message or stopped that turn; that action did not run. Run it again only if the user asks for it again.');
138
+ }
139
+ else if (withdrawn > 1) {
140
+ parts.push(`${withdrawn} approvals asked for earlier in this conversation were withdrawn before they ran, because the user sent a new message or stopped that turn; those actions did not run. Run one again only if the user asks for it again.`);
141
+ }
107
142
  if (expired.undecided === 1) {
108
143
  parts.push('An approval asked for earlier in this conversation expired before the user decided it, so that action did not run. Run it again only if the user asks for it again.');
109
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"continuation.js","sourceRoot":"","sources":["../../src/approvals/continuation.ts"],"names":[],"mappings":"AA2CA,MAAM,OAAO,GAAG;IACd,WAAW,EAAE,0DAA0D;IACvE,cAAc,EAAE,gEAAgE;IAChF,QAAQ,EAAE,4DAA4D;IACtE,OAAO,EAAE,0DAA0D;IACnE,eAAe,EAAE,oGAAoG;CAC7G,CAAC;AAEX,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,GAAY,EAAE,MAAY,IAAI,IAAI,EAAE;IAC3F,MAAM,OAAO,GACX,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9I,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAe,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,OAAO,KAAK,UAAU,IAAI,GAAG,EAAE,OAAO,E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AI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,YAAY,CAAC,6DAA6D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;YAC5G,wHAAwH;YACxH,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1E,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC"}
@@ -4,12 +4,12 @@
4
4
  * and the call's arguments. None comes from the model: the model chooses the
5
5
  * call, never how it is described to the person approving it.
6
6
  */
7
- import type { ApprovalPreview } from '@ouispec/agent-core';
7
+ import { type ApprovalPreview, type AttachmentRef } from '@ouispec/agent-core';
8
8
  import type { RegisteredTool } from '../tools/types.js';
9
9
  /** The action's title and what it does, as its declaration states them. */
10
10
  export declare function declaredTitle(tool: RegisteredTool): {
11
11
  title: string;
12
12
  consequence?: string;
13
13
  };
14
- export declare function buildApprovalPreview(tool: RegisteredTool, args: Record<string, unknown>): ApprovalPreview;
14
+ export declare function buildApprovalPreview(tool: RegisteredTool, args: Record<string, unknown>, files?: ReadonlyMap<string, AttachmentRef>): ApprovalPreview;
15
15
  //# sourceMappingURL=preview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/approvals/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,qBAAqB,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAOxD,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAI3F;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CAezG"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../src/approvals/preview.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAkC,KAAK,eAAe,EAAgC,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC7I,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAWxD,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAI3F;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,GAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAa,GACpD,eAAe,CAejB"}
@@ -1,22 +1,39 @@
1
+ /**
2
+ * The approval card's words (ADR-0228 §2.2.2). Every one comes from the
3
+ * tool's declaration — its title, its description, its input schema's labels —
4
+ * and the call's arguments. None comes from the model: the model chooses the
5
+ * call, never how it is described to the person approving it.
6
+ */
7
+ import { attachmentInputOf, formatBytes } from '@ouispec/agent-core';
1
8
  /** The action's title and what it does, as its declaration states them. */
2
9
  export function declaredTitle(tool) {
3
10
  const title = tool.title?.trim() || tool.name;
4
11
  const consequence = (tool.consequence ?? tool.description)?.trim();
5
12
  return consequence && consequence !== title ? { title, consequence } : { title };
6
13
  }
7
- export function buildApprovalPreview(tool, args) {
14
+ export function buildApprovalPreview(tool, args, files = new Map()) {
8
15
  const { title, consequence } = declaredTitle(tool);
9
16
  const properties = (tool.inputSchema.properties ?? {});
10
17
  // The schema's order first, then anything else the call carries.
11
18
  const names = [...Object.keys(properties).filter((k) => k in args), ...Object.keys(args).filter((k) => !(k in properties))];
12
19
  const argumentsShown = names
13
20
  .filter((name) => args[name] !== undefined)
14
- .map((name) => ({ name, label: properties[name]?.title?.trim() || name, value: valueText(args[name], properties[name]) }));
21
+ .map((name) => ({ name, label: properties[name]?.title?.trim() || name, value: valueText(args[name], properties[name], files) }));
15
22
  const listed = argumentsShown.map((a) => `${a.label} ${a.value}`).join(', ');
16
23
  const readback = `${title}${listed ? `: ${listed}` : ''}.${consequence ? ` ${consequence}` : ''}`;
17
24
  return { title, ...(consequence ? { consequence } : {}), arguments: argumentsShown, readback };
18
25
  }
19
- function valueText(value, schema) {
26
+ /** An attached file as the person reads it: its name and size, never its id. */
27
+ function fileText(id, files) {
28
+ const ref = typeof id === 'string' ? files.get(id) : undefined;
29
+ return ref ? `"${ref.name}" (${formatBytes(ref.bytes)})` : 'an attached file';
30
+ }
31
+ function valueText(value, schema, files) {
32
+ if (schema && attachmentInputOf(schema))
33
+ return fileText(value, files);
34
+ if (schema?.type === 'array' && schema.items && attachmentInputOf(schema.items) && Array.isArray(value)) {
35
+ return value.map((v) => fileText(v, files)).join(', ');
36
+ }
20
37
  const named = schema?.oneOf?.find((o) => o.const === value && o.title);
21
38
  if (named?.title)
22
39
  return named.title;
@@ -1 +1 @@
1
- {"version":3,"file":"preview.js","sourceRoot":"","sources":["../../src/approvals/preview.ts"],"names":[],"mappings":"AAcA,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAC,IAAoB;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC;IAC9C,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC;IACnE,OAAO,WAAW,IAAI,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAA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
5
+ * - An image: the platform's model rendition, as a file part (ADR-0244's path).
6
+ * - Text, and a PDF's text: up to 20,000 characters a file and 40,000 a turn,
7
+ * with a note of how much was left out.
8
+ * - A short PDF as a document part, when the host turns that on.
9
+ * - Anything else: its reference line.
10
+ *
11
+ * Bytes and text are fetched for the model call and kept nowhere: not in an
12
+ * event, the turn's record or a stored message. Later turns read the
13
+ * reference line and look again with the attachment tools.
14
+ */
15
+ import type { FilePart, ModelMessage, TextPart } from 'ai';
16
+ import { type AttachmentRef } from '@ouispec/agent-core';
17
+ import type { AttachmentCap, AttachmentGuard, GuardedPart } from './guard.js';
18
+ import type { AttachmentOwner, AttachmentStore } from './store.js';
19
+ export declare const VIEW_TOOL = "attachment_view";
20
+ export declare const READ_TOOL = "attachment_read";
21
+ export declare const LIST_TOOL = "attachment_list";
22
+ type Part = TextPart | FilePart;
23
+ /**
24
+ * What the system prompt says of files when the host has a file area: a
25
+ * file's name and content are the person's data, never instructions.
26
+ */
27
+ export declare const ATTACHMENT_DATA_NOTE: string;
28
+ export declare function escapeAttachmentText(text: string): string;
29
+ /** The model's part for a file's text: what it is, then the text, closed so it cannot run into what follows. */
30
+ export declare function textBlock(ref: AttachmentRef, text: string, totalChars: number): string;
31
+ /** What the model is told when a file is not given because a cap is used up. */
32
+ export declare function capReachedReason(cap: AttachmentCap, tool: string): string;
33
+ export interface TurnAttachments {
34
+ /** Parts to add to the turn's user message, after its text. */
35
+ parts: Part[];
36
+ /** Lines to add to its text: files given as their reference only, and why. */
37
+ notes: string[];
38
+ /** Files the store failed on, for the turn's log. */
39
+ failures: Array<{
40
+ attachmentId: string;
41
+ error: string;
42
+ }>;
43
+ }
44
+ /**
45
+ * The turn's files, loaded through the host's store and capped by the guard.
46
+ * Never throws: a file that cannot be had is named, with why, and the others
47
+ * are given as they are.
48
+ */
49
+ export declare function turnAttachmentParts(asked: readonly AttachmentRef[], context: {
50
+ store: AttachmentStore;
51
+ owner: AttachmentOwner;
52
+ guard: AttachmentGuard;
53
+ pdfAsDocument: boolean;
54
+ perMessage?: number;
55
+ signal?: AbortSignal;
56
+ }): Promise<TurnAttachments>;
57
+ /** The turn's user message (the last one) with its files: notes after its text, then the parts. */
58
+ export declare function withTurnAttachments(messages: ModelMessage[], files: TurnAttachments): ModelMessage[];
59
+ /**
60
+ * The messages of the next step with the parts the guard has left out
61
+ * replaced by their lines: on the user message, the part itself; in a tool
62
+ * call's result, the result's picture or text.
63
+ */
64
+ export declare function withoutLeftOut(messages: ModelMessage[], leftOut: readonly GuardedPart[]): ModelMessage[];
65
+ /** A user message of history with its files' reference lines after its text. */
66
+ export declare function withReferenceLines(text: string, refs: readonly AttachmentRef[] | undefined): string;
67
+ export {};
68
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/attachments/content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAiG,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxJ,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAcnE,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAC3C,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAC3C,eAAO,MAAM,SAAS,oBAAoB,CAAC;AAE3C,KAAK,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAQrB,CAAC;AAcb,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,gHAAgH;AAChH,wBAAgB,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,MAA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