@keemakr/agent-sdk 1.3.0 → 1.4.0-dev-20261115054516

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -298,6 +298,8 @@ export const approvals = approvalResolvedHandler(); // POST /approvals/:dedupeKe
298
298
  - A `decision` kind may name `audience: 'requester'`: the person who asked confirms it themselves, and nobody else decides it (no fallback). Core takes it only from that person's own turn (`409 requester_required` otherwise).
299
299
  - Testkit (`@keemakr/agent-sdk/testkit`): `previewApprovalCard`, `previewApprovalRoute`, `simulateApprovalDecision`, `simulateApprovalSettled`, `simulateApprovalChain`.
300
300
 
301
+ A tool-call approval in chat can carry one button that opens one of your own screens and answers nothing (`toolApprovals` in the manifest, core feature `tool_approval_screens`): `{ "tool": "send_forms", "open": { "label": "Tick and untick them", "screen": "lead", "params": { "lead": { "fromInput": "leadId" } } } }`. The screen must be in your `screenRegistry`; each param is a short id, a literal or a top-level field of the tool's input. See `docs/building-department-agents.md` §3b.
302
+
301
303
  A decision can also be shown in chat: answer with a `proposalCard({ approvalRef, ... })` that names the card you proposed. `recordListCard()` and `receiptCard()` build the other two platform chat cards, and `cardActions()` handles a click on their buttons (`previewCard`, `simulateClick` and `simulateUndo` in the testkit).
302
304
 
303
305
  Full guide: keemakr-core `docs/building-department-agents.md` §3b (approvals), §6a (chat cards), §6f (department settings) and §6l (send cards that settled).
@@ -421,6 +423,15 @@ It throws `CoreFeaturesMissing`, naming the missing features and the core's vers
421
423
  error or a refused grant throws from both. `requiredFeatures(entry)` lists what a manifest needs; see
422
424
  keemakr-core `docs/building-department-agents.md` §6p.
423
425
 
426
+ ## Plain step labels
427
+
428
+ "What Kee did" shows each step your department took by its tool's name made readable
429
+ (`read_diary` → "Read diary"). Give a manifest agent `tools: [{ name, stepLabel }]` to say what a
430
+ tool is doing in the person's words ("Reading the diary"): at most 40 characters of plain words, no
431
+ digits, `@`, `/` or `:`. No call is needed and no core feature is checked: a core that does not know
432
+ the key shows the readable name. Core shows the labels only for a company where staff have turned on
433
+ `operator.step-labels` (off by default). See keemakr-core `docs/agent-platform-sdk.md`, "Step labels".
434
+
424
435
  ## Suggest a name for your department
425
436
 
426
437
  `manifest.department.display_name` ("Penny") and `epithet` ("the Bookkeeper") suggest a character
@@ -101,6 +101,18 @@ export interface OpenAppCanvas {
101
101
  /** A second line under the label. Core cuts it at 120 characters. */
102
102
  description?: string;
103
103
  }
104
+ /**
105
+ * What the reader might ask next: up to three chips under your reply, each sending its text as the
106
+ * reader's own message ("Which forms are not back?"). Words only, never a target. Each ask follows
107
+ * the Operator starter rules (one line, at most 120 characters, no machinery words, at most one
108
+ * `<placeholder>`, which fills the message box instead of sending); core drops one that breaks a
109
+ * rule, and withholds the card when none is left. An older client shows the asks as plain text.
110
+ * Core draws them only for a company with the release key `operator.next-asks` on (off by default).
111
+ */
112
+ export interface NextAsksCanvas {
113
+ type: 'next_asks';
114
+ asks: string[];
115
+ }
104
116
  /**
105
117
  * The limits core enforces on the three platform cards. Pinned to core's api-spec `CARD_LIMITS`
106
118
  * by a test in core, so the builders refuse exactly what ingestion would withhold.
package/dist/canvases.js CHANGED
@@ -6,7 +6,8 @@
6
6
  // names the type), because a client cannot draw a type it does not know. The types core keeps on
7
7
  // web and desktop today:
8
8
  //
9
- // report, image, connect_integration, connect_provider, run-status, open_screen, open_app
9
+ // report, image, connect_integration, connect_provider, run-status, open_screen, open_app,
10
+ // next_asks
10
11
  // record_list, proposal, receipt the platform chat cards (C1.10), built below
11
12
  //
12
13
  // A proposal is kept only when its `approvalRef` names an approval card your department proposed
@@ -1,4 +1,4 @@
1
- import type { ChannelAction, ChannelDelivery } from './channel.js';
1
+ import type { BookingConversationState, ChannelAction, ChannelDelivery } from './channel.js';
2
2
  export interface KbFixture {
3
3
  chunkId: string;
4
4
  title: string | null;
@@ -13,6 +13,11 @@ export interface FakeCoreOptions {
13
13
  groundedOn: string[];
14
14
  status: string;
15
15
  };
16
+ /**
17
+ * What `ctx.booking.state()` returns. A function, so a fixture can change as the test goes on.
18
+ * Absent, the route answers 404 as an older core does, and `state()` resolves null.
19
+ */
20
+ bookingState?: BookingConversationState | (() => BookingConversationState);
16
21
  /** What `ctx.kb.search()` returns. A function, so a fixture can vary by query. */
17
22
  kb?: KbFixture[] | ((query: string) => KbFixture[]);
18
23
  /** What `ctx.history()` returns. */
@@ -79,6 +84,10 @@ export interface FakeCore {
79
84
  handle: string | null;
80
85
  name: string | null;
81
86
  asserted_name?: string | null;
87
+ verified_handles?: Array<{
88
+ kind: 'email' | 'phone';
89
+ value: string;
90
+ }>;
82
91
  };
83
92
  binding?: Record<string, unknown>;
84
93
  language?: {
@@ -72,6 +72,15 @@ export async function startFakeCore(options = {}) {
72
72
  };
73
73
  if (url.pathname === '/.well-known/jwks.json')
74
74
  return json(200, { keys: [jwk] });
75
+ if (url.pathname === '/api/capability/booking/state') {
76
+ if (!options.bookingState)
77
+ return json(404, {
78
+ code: 'booking_state_unavailable',
79
+ error: 'No booking state fixture',
80
+ });
81
+ const state = typeof options.bookingState === 'function' ? options.bookingState() : options.bookingState;
82
+ return json(200, state);
83
+ }
75
84
  if (url.pathname === '/api/capability/booking/workflow') {
76
85
  let raw = '';
77
86
  req.on('data', (c) => (raw += c));
package/dist/channel.d.ts CHANGED
@@ -40,6 +40,24 @@ export interface BookingWorkflowContext {
40
40
  completedAt?: string;
41
41
  awaitingConfirmation: boolean;
42
42
  }
43
+ /**
44
+ * Where this conversation's booking request stands, from `ctx.booking.state()`: core reads it from
45
+ * its own records, so it holds in any language the replies were written in. `none`: no request;
46
+ * `open`: times listed, no summary yet; `awaiting_confirmation`: a summary waits for the customer's
47
+ * yes; `submitted`: a yes is being carried out, or the request went to staff; `completed`,
48
+ * `failed`, `expired`: settled. A yes on a `completed` request carries nothing out again.
49
+ */
50
+ export interface BookingConversationState {
51
+ state: 'none' | 'open' | 'awaiting_confirmation' | 'submitted' | 'completed' | 'failed' | 'expired';
52
+ /**
53
+ * The `status` of the last `ctx.booking.process` call on the conversation's current summary.
54
+ * Absent before a summary is read back (and once times listed since replace it), or when core
55
+ * did not keep one.
56
+ */
57
+ lastStatus?: string;
58
+ /** When core last carried out a booking, move or cancellation in this conversation. */
59
+ completedAt?: string;
60
+ }
43
61
  /**
44
62
  * What `ctx.booking.process` takes. Core validates it strictly and refuses unknown fields, so an
45
63
  * older core rejects a field it does not know rather than ignoring it.
@@ -184,6 +202,14 @@ export interface ChannelContact {
184
202
  * web chat, SMS and email is one person: key your own state on it rather than on a channel handle.
185
203
  */
186
204
  person_id?: string;
205
+ /**
206
+ * The contact's VERIFIED email and phone, when the company names this agent in core's
207
+ * `channels.dispatch.verified-handles`; absent otherwise. Never a typed address.
208
+ */
209
+ verified_handles?: Array<{
210
+ kind: 'email' | 'phone';
211
+ value: string;
212
+ }>;
187
213
  }
188
214
  /** The envelope core POSTs. Loose by rule — core adds fields without asking packs first. */
189
215
  export interface ChannelDelivery {
@@ -457,6 +483,14 @@ export interface ChannelContext {
457
483
  confirmVerification(challengeId: string, code: string): Promise<{
458
484
  verified: boolean;
459
485
  }>;
486
+ /**
487
+ * Where this conversation's booking request stands, read live from core (so it already
488
+ * reflects a `process` call made earlier in this turn). Resolves null when core cannot say: an
489
+ * older core, or one where the business has not turned it on. Read it instead of the words of
490
+ * core's replies; fall back to `setup.booking.context` on null. Nothing is called until you
491
+ * call it.
492
+ */
493
+ state(): Promise<BookingConversationState | null>;
460
494
  };
461
495
  /** Earlier turns in this conversation, under `channel:history`. */
462
496
  history(limit?: number): Promise<Array<{
package/dist/channel.js CHANGED
@@ -344,6 +344,16 @@ export function createChannelAgent(options) {
344
344
  headers: { 'x-keemakr-delivery-id': body.delivery_id },
345
345
  }), 'booking verification'));
346
346
  },
347
+ async state() {
348
+ const res = await authed('/api/capability/booking/state', {
349
+ method: 'GET',
350
+ headers: { 'x-keemakr-delivery-id': body.delivery_id },
351
+ });
352
+ // An older core has no such route, and one where it is off answers the same: no answer.
353
+ if (res.status === 404)
354
+ return null;
355
+ return (await readOrRefuse(res, 'booking state'));
356
+ },
347
357
  async process(input) {
348
358
  const res = await authed('/api/capability/booking/workflow', {
349
359
  method: 'POST',
@@ -55,6 +55,7 @@ export const MANIFEST_KEY_FEATURES = {
55
55
  // An older core strips the hosts, and every image or video named by signed URL shows "Media
56
56
  // unavailable" (KEE-989).
57
57
  mediaHosts: 'media_urls',
58
+ toolApprovals: 'tool_approval_screens',
58
59
  };
59
60
  /** Each key of `manifest.department` → the core feature it needs, or null. */
60
61
  export const DEPARTMENT_KEY_FEATURES = {
@@ -148,6 +149,10 @@ export const DEPENDENCY_KEY_FEATURES = {
148
149
  capabilities: null,
149
150
  turn_effects: null,
150
151
  namespace: 'memory_namespaces',
152
+ // A connection dependency's operations list (KEE-2035). An older core strips it, which leaves
153
+ // the install unnarrowed, as a core with `capability.connection-operations.dependency-lists` off
154
+ // does: the department works the same either way, so nothing is needed.
155
+ operations: null,
151
156
  };
152
157
  function isObject(value) {
153
158
  return typeof value === 'object' && value !== null && !Array.isArray(value);
package/dist/index.d.ts CHANGED
@@ -29,8 +29,8 @@ export { buildBriefView, playBriefScript, checkBriefItem, itemIsLive, urlAllowed
29
29
  export { keemakrToolDirectory } from './tool-directory.js';
30
30
  export { refreshGrant, REFRESH_THRESHOLD_SECONDS } from './refresh.js';
31
31
  export { formatRecordRef, parseRecordRef, normalizeRecordRefText, recordRefNamespace, isRecordRef, isApprovalRef, RecordRefError, type RecordRef, type ApprovalRef, type RecordRefNamespace, } from './refs.js';
32
- export { audioCanvas, imageCanvas, recordListCard, proposalCard, receiptCard, namesMachinery, CARD_LIMITS, CHANGE_OWNER_KEY, type AudioCanvas, type Canvas, type ImageCanvas, type OpenAppCanvas, type OpenScreenCanvas, type ReportCanvas, type RecordListCanvas, type ProposalCanvas, type ReceiptCanvas, type CardActionDeclaration, type CardTone, } from './canvases.js';
32
+ export { audioCanvas, imageCanvas, recordListCard, proposalCard, receiptCard, namesMachinery, CARD_LIMITS, CHANGE_OWNER_KEY, type AudioCanvas, type Canvas, type ImageCanvas, type OpenAppCanvas, type NextAsksCanvas, type OpenScreenCanvas, type ReportCanvas, type RecordListCanvas, type ProposalCanvas, type ReceiptCanvas, type CardActionDeclaration, type CardTone, } from './canvases.js';
33
33
  export { cardActions, type CardActions, type CardActionsOptions, type CardActionContext, type CardActionAnswer, type CardActionHandler, type UndoContext, type UndoAnswer, type UndoHandler, type ProposeApprovalContext, type ProposeApprovalAnswer, type ProposeApprovalHandler, type ChangeOwnerContext, type ChangeOwnerHandler, type OwnerChangeReason, } from './cards.js';
34
34
  export type { RecordHeader, RecordDisplayValue, FacetRow, Activity, PageFacet, PageInput, PageViewer, PagePart, PagePartView, RecordPage, IdentityKey, RecordLink, ActionIdMode, } from './record-page.js';
35
35
  export { declaredActionId } from './record-page.js';
36
- export { createChannelAgent, assertTrustworthyCore, ChannelReachError, ChannelRecordConflict, ChannelReplyNotDeliverable, isApprovalRequired, isHoldSettled, isOutcomeUnknown, isWriteDone, type ChannelWriteDone, type ChannelWriteResult, type ChannelWriteOptions, type ChannelApprovalRequired, type ChannelHoldSettled, type ChannelOutcomeUnknown, type HeldActionStatus, type ChannelReach, type ChannelRecord, type ChannelContact, type ChannelContactHandle, type ChannelAction, type ChannelAgent, type ChannelAgentOptions, type ChannelContext, type ChannelDelivery, type BookingWorkflowInput, type BookingWorkflowContext, type ChannelTurnEffects, type ChannelQuestion, type QuestionRef, type ChannelEmail, type ChannelMessage, type HandoffReason, type Usage, } from './channel.js';
36
+ export { createChannelAgent, assertTrustworthyCore, ChannelReachError, ChannelRecordConflict, ChannelReplyNotDeliverable, isApprovalRequired, isHoldSettled, isOutcomeUnknown, isWriteDone, type ChannelWriteDone, type ChannelWriteResult, type ChannelWriteOptions, type ChannelApprovalRequired, type ChannelHoldSettled, type ChannelOutcomeUnknown, type HeldActionStatus, type ChannelReach, type ChannelRecord, type ChannelContact, type ChannelContactHandle, type ChannelAction, type ChannelAgent, type ChannelAgentOptions, type ChannelContext, type ChannelDelivery, type BookingWorkflowInput, type BookingWorkflowContext, type BookingConversationState, type ChannelTurnEffects, type ChannelQuestion, type QuestionRef, type ChannelEmail, type ChannelMessage, type HandoffReason, type Usage, } from './channel.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keemakr/agent-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0-dev-20261115054516",
4
4
  "description": "The floor for keemakr marketplace agents: verify the capability grant and reach tenant connections, memory, and shared platform tools through keemakr-core — without holding raw secrets or resolving the tenant yourself.",
5
5
  "license": "MIT",
6
6
  "type": "module",