@oneie/sdk 0.13.9 → 0.14.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 (62) hide show
  1. package/LICENSE +81 -13
  2. package/README.md +3 -3
  3. package/dist/brain.d.ts +2 -0
  4. package/dist/brain.d.ts.map +1 -1
  5. package/dist/brain.js +8 -0
  6. package/dist/brain.js.map +1 -1
  7. package/dist/client.d.ts +46 -3
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +67 -5
  10. package/dist/client.js.map +1 -1
  11. package/dist/compile.d.ts.map +1 -1
  12. package/dist/compile.js +6 -3
  13. package/dist/compile.js.map +1 -1
  14. package/dist/errors.d.ts +8 -0
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js +16 -0
  17. package/dist/errors.js.map +1 -1
  18. package/dist/generated/fn-map.d.ts +15 -0
  19. package/dist/generated/fn-map.d.ts.map +1 -0
  20. package/dist/generated/fn-map.js +1170 -0
  21. package/dist/generated/fn-map.js.map +1 -0
  22. package/dist/generated/schemas/index.d.ts +241 -0
  23. package/dist/generated/schemas/index.d.ts.map +1 -0
  24. package/dist/generated/schemas/index.js +129 -0
  25. package/dist/generated/schemas/index.js.map +1 -0
  26. package/dist/generated/schemas.d.ts +804 -0
  27. package/dist/generated/schemas.d.ts.map +1 -0
  28. package/dist/generated/schemas.js +643 -0
  29. package/dist/generated/schemas.js.map +1 -0
  30. package/dist/generated/skins/engineering.d.ts +37 -0
  31. package/dist/generated/skins/engineering.d.ts.map +1 -0
  32. package/dist/generated/skins/engineering.js +33 -0
  33. package/dist/generated/skins/engineering.js.map +1 -0
  34. package/dist/index.d.ts +7 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +5 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/plugin-build.d.ts +18 -0
  39. package/dist/plugin-build.d.ts.map +1 -0
  40. package/dist/plugin-build.js +15 -0
  41. package/dist/plugin-build.js.map +1 -0
  42. package/dist/receivers.d.ts +373 -10
  43. package/dist/receivers.d.ts.map +1 -1
  44. package/dist/receivers.js +372 -5
  45. package/dist/receivers.js.map +1 -1
  46. package/dist/schemas.d.ts +2 -2
  47. package/dist/skills.d.ts +7 -5
  48. package/dist/skills.d.ts.map +1 -1
  49. package/dist/skills.js.map +1 -1
  50. package/dist/templates.d.ts +1 -0
  51. package/dist/templates.d.ts.map +1 -1
  52. package/dist/templates.js +950 -72
  53. package/dist/templates.js.map +1 -1
  54. package/dist/trail.d.ts +25 -0
  55. package/dist/trail.d.ts.map +1 -0
  56. package/dist/trail.js +25 -0
  57. package/dist/trail.js.map +1 -0
  58. package/dist/types.d.ts +49 -0
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js +9 -0
  61. package/dist/types.js.map +1 -1
  62. package/package.json +10 -3
package/dist/receivers.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { AgentActionResponseSchema, AgentStatusResponseSchema, CapabilityItemSchema, PayResponseSchema, RegisterResponseSchema, StatsSchema, StepKind, WorkflowDiffSchema, } from "./schemas.js";
3
3
  import { FieldSchema, ResourceTypeSchema } from "./types.js";
4
+ import { GroupEntitySchema } from "./generated/schemas/index.js";
4
5
  /**
5
6
  * Declare a receiver contract. Identity at runtime — its only job is to pin the
6
7
  * `Req`/`Res` generics so the catalog infers payload + outcome types.
@@ -26,6 +27,42 @@ export const RECEIVERS = {
26
27
  response: z.object({ ok: z.literal(true), actorId: z.string(), slug: z.string(), apiKey: z.string(), credits: z.number() }),
27
28
  effect: "ask", auth: "public", reversible: false, idempotent: false,
28
29
  }),
30
+ "agent:own-link": receiver({
31
+ receiver: "agent:own-link",
32
+ summary: "Generate a signed ownership invitation link for a registered agent; optionally deliver it as a native button on Telegram or Discord",
33
+ request: z.object({
34
+ agent_id: z.string().describe("The agent's actor ID (aid from world_actors / actorId from auth.md registration)"),
35
+ channel_group: z.string().optional().describe("Optional delivery channel: tg-<chat_id> / dc-<channel_id> / web-<group>"),
36
+ workspace: z.string().optional().describe("Workspace slug for credential lookup when channel_group is set"),
37
+ }),
38
+ response: z.object({
39
+ ok: z.literal(true),
40
+ adopt_url: z.string(),
41
+ expires_in: z.number(),
42
+ agent_id: z.string(),
43
+ delivered: z.boolean().optional(),
44
+ }),
45
+ effect: "ask", auth: "owner", reversible: false, idempotent: false,
46
+ }),
47
+ "agent:provision": receiver({
48
+ receiver: "agent:provision",
49
+ summary: "Zero-to-live in one unauthenticated call — register + workspace + publish agent + import skills + invite owner",
50
+ request: z.object({
51
+ name: z.string().optional(),
52
+ agentName: z.string().optional(),
53
+ content: z.string().optional(),
54
+ skills: z.array(z.string()).optional(),
55
+ invite: z.object({ email: z.string().email().optional(), role: z.string().optional() }).optional(),
56
+ live: z.boolean().optional(),
57
+ }),
58
+ response: z.object({
59
+ uid: z.string(),
60
+ workspace: z.string(),
61
+ apiKey: z.string(),
62
+ inviteUrl: z.string().optional(),
63
+ }),
64
+ effect: "ask", auth: "none", reversible: false, idempotent: false,
65
+ }),
29
66
  "agent:bootstrap": receiver({
30
67
  receiver: "agent:bootstrap",
31
68
  summary: "Atomically provision a workspace + actor + scoped key; optionally invite an initial human owner",
@@ -168,7 +205,12 @@ export const RECEIVERS = {
168
205
  "world:create-group": receiver({
169
206
  receiver: "world:create-group",
170
207
  summary: "Create a group in the caller's workspace",
171
- request: z.object({ name: z.string(), type: z.string(), tags: z.array(z.string()).optional() }),
208
+ request: z.object({
209
+ name: z.string(),
210
+ // "group" is the D1 group_type for campaigns/collections; absent from the TypeDB enum
211
+ type: GroupEntitySchema.shape["group-type"].or(z.literal("group")),
212
+ tags: z.array(z.string()).optional(),
213
+ }),
172
214
  response: z.object({ gid: z.string() }), effect: "ask", auth: "manage_groups",
173
215
  }),
174
216
  "world:update-group": receiver({
@@ -309,6 +351,30 @@ export const RECEIVERS = {
309
351
  request: z.object({ group: z.string().optional(), key: z.string(), fields: z.array(FieldSchema), label: z.string().optional() }),
310
352
  response: ok, effect: "ask", auth: "manage_things",
311
353
  }),
354
+ "lifecycle:save": receiver({
355
+ receiver: "lifecycle:save",
356
+ summary: "Save a lifecycle definition to a workspace (operator push from data/lifecycles/*.toml via `one push`)",
357
+ request: z.object({ slug: z.string(), lifecycle: z.string(), def: z.record(z.string(), z.unknown()) }),
358
+ response: z.object({ ok: z.literal(true), id: z.string() }),
359
+ effect: "ask", auth: "manage_lifecycle", reversible: false,
360
+ examples: [{ slug: "acme", lifecycle: "marketing", def: { id: "marketing", name: "Marketing Funnel", version: 1, stages: [], transitions: [], arcs: [], monotonic: true } }],
361
+ }),
362
+ "tools:connect": receiver({
363
+ receiver: "tools:connect",
364
+ summary: "Connect a Composio API-KEY toolkit to a workspace headlessly (OAuth stays in the browser flow)",
365
+ request: z.object({ slug: z.string(), toolkit: z.string(), credentials: z.record(z.string(), z.string()).optional(), authScheme: z.string().optional() }),
366
+ response: z.object({ ok: z.literal(true), connectionId: z.string().optional(), authUrl: z.string().optional() }),
367
+ effect: "ask", auth: "manage_integrations", reversible: false,
368
+ examples: [{ slug: "acme", toolkit: "stripe", credentials: { api_key: "sk_test_..." } }],
369
+ }),
370
+ "brand:set": receiver({
371
+ receiver: "brand:set",
372
+ summary: "Write up to 6 brand color tokens (primary/secondary/accent/bg/text/border) to a workspace theme",
373
+ request: z.object({ slug: z.string(), tokens: z.object({ primary: z.string().optional(), secondary: z.string().optional(), accent: z.string().optional(), bg: z.string().optional(), text: z.string().optional(), border: z.string().optional() }) }),
374
+ response: z.object({ ok: z.literal(true), theme: z.record(z.string(), z.unknown()) }),
375
+ effect: "ask", auth: "manage_workspace", reversible: true,
376
+ examples: [{ slug: "acme", tokens: { primary: "hsl(216 55% 25%)", secondary: "hsl(160 40% 45%)" } }],
377
+ }),
312
378
  "world:create-thing": receiver({
313
379
  receiver: "world:create-thing",
314
380
  summary: "Create a thing (skill, token, product) in the world",
@@ -385,6 +451,33 @@ export const RECEIVERS = {
385
451
  response: z.object({ outcome: z.literal("granted"), id: z.string(), grantee: z.string(), scope: z.string() }),
386
452
  effect: "ask", auth: "mint_capability", reversible: false,
387
453
  }),
454
+ // ── model router (C3/C4 — do-metabolism) ──
455
+ "world:pick-model": receiver({
456
+ receiver: "world:pick-model",
457
+ summary: "Return the best proven model for a task shape (warmed/cold/toxic-escalate/fallback-unreachable)",
458
+ request: z.object({ shape: z.string().min(1) }),
459
+ response: z.object({
460
+ ok: z.boolean(),
461
+ model: z.string().optional(),
462
+ effort: z.string().optional(),
463
+ reason: z.enum(['warmed', 'cold', 'toxic-escalate', 'fallback-unreachable']).optional(),
464
+ }),
465
+ effect: "ask", auth: "none", reversible: true,
466
+ }),
467
+ "world:seed-router": receiver({
468
+ receiver: "world:seed-router",
469
+ summary: "Seed initial shape→model capability rows (platform-gated, idempotent)",
470
+ request: z.object({ shapes: z.array(z.string()).optional() }),
471
+ response: z.object({ ok: z.boolean(), seeded: z.number().optional() }),
472
+ effect: "ask", auth: "platform", reversible: true,
473
+ }),
474
+ "attention:follow": receiver({
475
+ receiver: "attention:follow",
476
+ summary: "Subscribe to a do-event axis; writes ws-scoped mark so fan-out stays tenant-isolated",
477
+ request: z.object({ axis: z.string().min(1) }),
478
+ response: z.object({ ok: z.boolean(), target: z.string().optional() }),
479
+ effect: "ask", auth: "session", reversible: true,
480
+ }),
388
481
  // ════════════════════════════════════════════════════════════════════════
389
482
  // C4 — remaining families (sequenced by recipe: identity → groups → BUILD
390
483
  // → TRADE → TRANSACT → reads). Request schemas mirror the exact client.ts
@@ -468,6 +561,41 @@ export const RECEIVERS = {
468
561
  response: ok,
469
562
  effect: "signal", idempotent: true,
470
563
  }),
564
+ "world:announce": receiver({
565
+ receiver: "world:announce",
566
+ summary: "Broadcast a tagged signal; the world fans it to every subscriber whose follow-tags intersect",
567
+ request: z.object({
568
+ tags: z.array(z.string()),
569
+ content: z.string().optional(),
570
+ }),
571
+ response: z.object({ ok: z.boolean(), matched: z.number().optional(), actors: z.array(z.string()).optional() }),
572
+ effect: "ask",
573
+ }),
574
+ "tasks:announce": receiver({
575
+ receiver: "tasks:announce",
576
+ summary: "Announce a task into the world by its tags — the first caller of world:announce",
577
+ request: z.object({
578
+ taskId: z.string(),
579
+ tags: z.array(z.string()),
580
+ }),
581
+ response: z.object({ ok: z.boolean(), taskId: z.string().optional(), matched: z.number().optional(), actors: z.array(z.string()).optional() }),
582
+ effect: "ask",
583
+ }),
584
+ "tasks:mine": receiver({
585
+ receiver: "tasks:mine",
586
+ summary: "My work queue: the open tasks whose words match what I subscribed to, ranked by learned weight (context-strength), not static priority",
587
+ request: z.object({ limit: z.number().optional() }),
588
+ response: z.object({
589
+ ok: z.boolean(),
590
+ tasks: z.array(z.object({
591
+ id: z.string(),
592
+ name: z.string(),
593
+ tags: z.array(z.string()),
594
+ weight: z.number(),
595
+ })),
596
+ }),
597
+ effect: "ask", idempotent: true,
598
+ }),
471
599
  // ── agents (TRADE / lifecycle) ──
472
600
  "agents:register": receiver({
473
601
  receiver: "agents:register",
@@ -519,6 +647,22 @@ export const RECEIVERS = {
519
647
  response: PayResponseSchema,
520
648
  effect: "ask", cost: "variable", settles: "onchain", reversible: false, simulatable: true,
521
649
  }),
650
+ "tasks:stake": receiver({
651
+ receiver: "tasks:stake",
652
+ summary: "Stake SUI against a task on-chain to raise its priority weight. 0.1 SUI = +1 weight unit. Irreversible — conviction signal, not a deposit.",
653
+ request: z.object({
654
+ taskObjectId: z.string().regex(/^0x[a-fA-F0-9]{64}$/, "Sui object ID"),
655
+ units: z.number().int().positive().default(1),
656
+ }),
657
+ response: z.object({
658
+ ok: z.boolean(),
659
+ digest: z.string().optional(),
660
+ weightBefore: z.number().optional(),
661
+ weightAfter: z.number().optional(),
662
+ suiSpent: z.number().optional(),
663
+ }),
664
+ effect: "ask", cost: "variable", settles: "onchain", reversible: false, simulatable: false,
665
+ }),
522
666
  // ── market (A2A negotiation, C2) ──
523
667
  "market:offer": receiver({
524
668
  receiver: "market:offer",
@@ -694,7 +838,7 @@ export const RECEIVERS = {
694
838
  summary: "Publish a capability (skill listing) to the market",
695
839
  request: z.object({
696
840
  skillId: z.string(), name: z.string(), price: z.number(),
697
- mode: z.string().optional(), visibility: z.string().optional(), scope: z.string().optional(),
841
+ mode: z.string().optional(), visibility: z.string().optional(), scope: z.string().optional(), entitlement: z.string().optional(),
698
842
  tags: z.array(z.string()).optional(),
699
843
  rubricThresholds: z.object({
700
844
  fit: z.number().optional(), form: z.number().optional(),
@@ -784,6 +928,22 @@ export const RECEIVERS = {
784
928
  }),
785
929
  effect: "ask", cost: "free", idempotent: true,
786
930
  }),
931
+ "meta:reputation": receiver({
932
+ receiver: "meta:reputation",
933
+ summary: "Read an actor's reputation score — weighted commend/flag balance from claw_paths + vote counts from reputation_votes",
934
+ request: z.object({ uid: z.string().describe("The actor's slug or aid to look up") }),
935
+ response: z.object({
936
+ uid: z.string(),
937
+ score: z.number().describe("Normalised 0–1 float: strength / (strength + resistance)"),
938
+ commend_count: z.number(),
939
+ flag_count: z.number(),
940
+ strength: z.number(),
941
+ resistance: z.number(),
942
+ why: z.array(z.string()).describe("Plain-English summary of the score"),
943
+ howToRaise: z.array(z.string()).describe("Actionable hints for improving score"),
944
+ }),
945
+ effect: "ask", cost: "free", idempotent: true,
946
+ }),
787
947
  "meta:types": receiver({
788
948
  receiver: "meta:types",
789
949
  summary: "Read the resource-type manifest for the caller's workspace, plus the built-in industry templates",
@@ -1129,6 +1289,61 @@ export const RECEIVERS = {
1129
1289
  }),
1130
1290
  effect: "ask", cost: "free", reversible: true, idempotent: false, auth: "member",
1131
1291
  }),
1292
+ // ── FUNNELS (text/funnels-plan.md) — author + run funnel definitions ──────────
1293
+ // funnel:create — create a new funnel definition (draft).
1294
+ "funnel:create": receiver({
1295
+ receiver: "funnel:create",
1296
+ summary: "Create a new funnel definition in a workspace (draft status); slug unique per workspace",
1297
+ request: z.object({
1298
+ workspaceSlug: z.string(),
1299
+ slug: z.string(),
1300
+ name: z.string(),
1301
+ playbookNode: z.string().optional(),
1302
+ }),
1303
+ response: z.object({ ok: z.boolean(), id: z.string().optional(), error: z.string().optional() }),
1304
+ effect: "ask", cost: "free", reversible: false, idempotent: false, auth: "admin",
1305
+ }),
1306
+ // funnel:update-step — replace the steps + edges graph of a funnel (bumps version).
1307
+ "funnel:update-step": receiver({
1308
+ receiver: "funnel:update-step",
1309
+ summary: "Replace a funnel's steps + edges graph; returns the new version (idempotent on identical payload)",
1310
+ request: z.object({
1311
+ workspaceSlug: z.string(),
1312
+ funnelId: z.string(),
1313
+ steps: z.array(z.unknown()),
1314
+ edges: z.array(z.unknown()),
1315
+ }),
1316
+ response: z.object({ ok: z.boolean(), version: z.number().optional(), error: z.string().optional() }),
1317
+ effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "admin",
1318
+ }),
1319
+ // funnel:publish — flip a funnel from draft to published.
1320
+ "funnel:publish": receiver({
1321
+ receiver: "funnel:publish",
1322
+ summary: "Publish a funnel (status draft → published); idempotent if already published",
1323
+ request: z.object({ workspaceSlug: z.string(), funnelId: z.string() }),
1324
+ response: z.object({ ok: z.boolean(), status: z.string().optional(), error: z.string().optional() }),
1325
+ effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "admin",
1326
+ }),
1327
+ // funnel:advance — move a visitor's session cursor; may move the visitor's lifecycle stage
1328
+ // (delegates to entity:tag — the sole stage_transition writer). Public: anonymous visitors fire this.
1329
+ "funnel:advance": receiver({
1330
+ receiver: "funnel:advance",
1331
+ summary: "Advance a visitor through a funnel step; returns next step + any lifecycle stage moved via entity:tag",
1332
+ request: z.object({
1333
+ workspaceSlug: z.string(),
1334
+ funnelSlug: z.string(),
1335
+ stepSlug: z.string(),
1336
+ visitorHash: z.string(),
1337
+ formData: z.record(z.string(), z.unknown()).optional(),
1338
+ }),
1339
+ response: z.object({
1340
+ ok: z.boolean(),
1341
+ nextStepSlug: z.string().optional(),
1342
+ lifecycleStage: z.string().optional(),
1343
+ error: z.string().optional(),
1344
+ }),
1345
+ effect: "signal", cost: "free", reversible: false, idempotent: false, auth: "public",
1346
+ }),
1132
1347
  // entity:meta — editable profile fields for an entity (website, industry, location, …).
1133
1348
  "entity:meta": receiver({
1134
1349
  receiver: "entity:meta",
@@ -1215,6 +1430,13 @@ export const RECEIVERS = {
1215
1430
  response: z.object({ products: z.array(z.record(z.string(), z.unknown())).optional(), error: z.string().optional() }),
1216
1431
  effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "public",
1217
1432
  }),
1433
+ "products:get": receiver({
1434
+ receiver: "products:get",
1435
+ summary: "Get one storefront product with its prices (public, active-only) — the single-record read a data-bound page block resolves through",
1436
+ request: z.object({ slug: z.string(), pid: z.string() }),
1437
+ response: z.object({ product: z.record(z.string(), z.unknown()).nullable().optional(), error: z.string().optional() }),
1438
+ effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "public",
1439
+ }),
1218
1440
  "products:archive": receiver({
1219
1441
  receiver: "products:archive",
1220
1442
  summary: "Archive a product (reversible via products:update)",
@@ -1240,14 +1462,14 @@ export const RECEIVERS = {
1240
1462
  "pages:create": receiver({
1241
1463
  receiver: "pages:create",
1242
1464
  summary: "Create a workspace page (draft) from a title + sections",
1243
- request: z.object({ slug: z.string(), title: z.string(), sections: z.record(z.string(), z.unknown()), pageSlug: z.string().optional() }),
1465
+ request: z.object({ slug: z.string(), title: z.string(), sections: z.array(z.object({ component: z.string(), props: z.record(z.string(), z.unknown()) })), pageSlug: z.string().optional() }),
1244
1466
  response: z.object({ ok: z.boolean(), slug: z.string().optional(), title: z.string().optional(), url: z.string().optional(), status: z.string().optional(), error: z.string().optional() }),
1245
1467
  effect: "ask", cost: "free", reversible: true, idempotent: false, auth: "member",
1246
1468
  }),
1247
1469
  "pages:edit": receiver({
1248
1470
  receiver: "pages:edit",
1249
1471
  summary: "Edit a workspace page's title or sections",
1250
- request: z.object({ slug: z.string(), page: z.string(), title: z.string().optional(), sections: z.record(z.string(), z.unknown()).optional() }),
1472
+ request: z.object({ slug: z.string(), page: z.string(), title: z.string().optional(), sections: z.array(z.object({ component: z.string(), props: z.record(z.string(), z.unknown()) })).optional() }),
1251
1473
  response: z.object({ ok: z.boolean(), slug: z.string().optional(), title: z.string().optional(), url: z.string().optional(), status: z.string().optional(), error: z.string().optional() }),
1252
1474
  effect: "ask", cost: "free", reversible: true, idempotent: false, auth: "member",
1253
1475
  }),
@@ -1265,6 +1487,20 @@ export const RECEIVERS = {
1265
1487
  response: z.object({ ok: z.boolean(), slug: z.string().optional(), title: z.string().optional(), url: z.string().optional(), status: z.string().optional(), error: z.string().optional() }),
1266
1488
  effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "member",
1267
1489
  }),
1490
+ "pages:versions": receiver({
1491
+ receiver: "pages:versions",
1492
+ summary: "List a page's saved version snapshots, newest first",
1493
+ request: z.object({ slug: z.string(), page: z.string() }),
1494
+ response: z.object({ ok: z.boolean(), slug: z.string().optional(), versions: z.array(z.object({ ts: z.number(), bytes: z.number(), key: z.string() })).optional(), error: z.string().optional() }),
1495
+ effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "member",
1496
+ }),
1497
+ "pages:restore": receiver({
1498
+ receiver: "pages:restore",
1499
+ summary: "Restore a page to a prior version snapshot (snapshots current state first)",
1500
+ request: z.object({ slug: z.string(), page: z.string(), ts: z.number() }),
1501
+ response: z.object({ ok: z.boolean(), slug: z.string().optional(), title: z.string().optional(), url: z.string().optional(), status: z.string().optional(), restoredTs: z.number().optional(), error: z.string().optional() }),
1502
+ effect: "ask", cost: "free", reversible: false, idempotent: false, auth: "member",
1503
+ }),
1268
1504
  "settings:write": receiver({
1269
1505
  receiver: "settings:write",
1270
1506
  summary: "Write a workspace setting value (caller or authorized descendant)",
@@ -1624,6 +1860,27 @@ export const RECEIVERS = {
1624
1860
  auth: "manage_workflows",
1625
1861
  examples: [{ workflowId: "wf_abc" }],
1626
1862
  }),
1863
+ "build:run": receiver({
1864
+ receiver: "build:run",
1865
+ summary: "Start a build cycle — gates on credits (funding-of), spawns the BuildRun DO, runs the stub W1 wave, returns a runId",
1866
+ request: z.object({
1867
+ goal: z.string(),
1868
+ mode: z.enum(["local", "remote"]).optional(),
1869
+ idempotencyKey: z.string().optional(),
1870
+ }),
1871
+ response: z.object({ runId: z.string(), status: z.string(), error: z.string().optional() }),
1872
+ effect: "ask", cost: "variable", reversible: false, idempotent: true, simulatable: false, settles: "none",
1873
+ auth: "manage_workflows",
1874
+ examples: [{ goal: "add a health endpoint", mode: "local" }],
1875
+ }),
1876
+ "build:resume": receiver({
1877
+ receiver: "build:resume",
1878
+ summary: "Advance a parked build run by one wave — re-validates the run against the caller's workspace",
1879
+ request: z.object({ runId: z.string() }),
1880
+ response: z.object({ ok: z.boolean(), status: z.string().optional(), error: z.string().optional() }),
1881
+ effect: "ask", cost: "free", idempotent: true, simulatable: false, auth: "manage_workflows",
1882
+ examples: [{ runId: "run_1" }],
1883
+ }),
1627
1884
  "human:resolve": receiver({
1628
1885
  receiver: "human:resolve",
1629
1886
  summary: "Resolve a suspended human step — carries { runId, stepId, decision | formPayload } to the run DO",
@@ -1737,7 +1994,7 @@ export const RECEIVERS = {
1737
1994
  summary: "List the caller's workspace skill catalog (R2) — powers the canvas SkillPicker",
1738
1995
  request: z.object({}),
1739
1996
  response: z.object({
1740
- skills: z.array(z.object({ name: z.string(), size: z.number() })),
1997
+ skills: z.array(z.object({ name: z.string(), size: z.number(), sealed: z.boolean().optional() })),
1741
1998
  }),
1742
1999
  effect: "ask", cost: "free", idempotent: true, simulatable: false, auth: "view_workflows",
1743
2000
  examples: [{}],
@@ -2134,6 +2391,114 @@ export const RECEIVERS = {
2134
2391
  response: z.object({ ok: z.boolean() }),
2135
2392
  effect: "signal", cost: "variable", reversible: false, idempotent: false, auth: "write",
2136
2393
  }),
2394
+ // ── Send Link — actor-bound tracked URL (CRM personalisation) ──────────────
2395
+ "links:create": receiver({
2396
+ receiver: "links:create",
2397
+ summary: "Create an actor-bound tracked link. On click `/go/:id` elevates the contact to rung-4 identity, pre-warms their snapshot, and personalises the page + chat. Creation is gated: the caller must hold authority over the target contact's workspace; `createdBy` is stamped from the attested session, never the body.",
2398
+ request: z.object({
2399
+ actorId: z.string().describe("Contact (actor) the link is bound to — must belong to the caller's workspace or a descendant"),
2400
+ destination: z.string().optional().describe("Path the click lands on (must start with '/'); default '/'"),
2401
+ context: z.string().optional().describe("Extra context injected into the agent's system prompt for this session"),
2402
+ greeting: z.string().optional().describe("Override the chat agent's opening line"),
2403
+ campaignId: z.string().optional().describe("Group clicks under a campaign for the learning loop"),
2404
+ expiresInDays: z.number().optional().describe("Link TTL in days; omitted = never expires"),
2405
+ }),
2406
+ response: z.object({ id: z.string(), sig: z.string(), url: z.string() }),
2407
+ effect: "ask", cost: "free", reversible: false, idempotent: false, auth: "member",
2408
+ examples: [{ actorId: "u-123", destination: "/pricing", expiresInDays: 90 }],
2409
+ }),
2410
+ "links:bulk-create": receiver({
2411
+ receiver: "links:bulk-create",
2412
+ summary: "Create one actor-bound tracked link per contact for a selected segment (the segment-campaign send). Authority is walked PER contact — any the caller can't reach is skipped (counted in `denied`), never failing the batch. Capped at 200.",
2413
+ request: z.object({
2414
+ actorIds: z.array(z.string()).min(1).max(200).describe("Contacts to mint a link for — each must belong to the caller's workspace or a descendant"),
2415
+ destination: z.string().optional().describe("Shared destination path (must start with '/'); default '/'"),
2416
+ campaignId: z.string().optional().describe("Group all clicks under one campaign for the learning loop"),
2417
+ expiresInDays: z.number().optional(),
2418
+ }),
2419
+ response: z.object({
2420
+ ok: z.boolean(),
2421
+ created: z.number().optional(),
2422
+ denied: z.number().optional(),
2423
+ links: z.array(z.object({ actorId: z.string(), url: z.string() })).optional(),
2424
+ error: z.string().optional(),
2425
+ }),
2426
+ effect: "ask", cost: "free", reversible: false, idempotent: false, auth: "member",
2427
+ examples: [{ actorIds: ["u-1", "u-2"], destination: "/launch", campaignId: "q3" }],
2428
+ }),
2429
+ // ── fn: family — typed substrate function calls (C5) ──────────────────────
2430
+ "fn:run": receiver({
2431
+ receiver: "fn:run",
2432
+ summary: "Execute an allowlisted TypeDB function by name. Returns the function's result rows. Not public — caller must be authenticated; the resolver re-walks authority before executing.",
2433
+ request: z.object({
2434
+ fn: z.string().describe("Function name from FN_MAP (e.g. 'optimal_route', 'actionable_hypotheses')"),
2435
+ args: z.record(z.string(), z.unknown()).optional().describe("Named arguments matching the function's param list"),
2436
+ workspace: z.string().optional().describe("Workspace slug for authority context"),
2437
+ }),
2438
+ response: z.object({
2439
+ ok: z.boolean(),
2440
+ fn: z.string(),
2441
+ rows: z.array(z.record(z.string(), z.unknown())),
2442
+ error: z.string().optional(),
2443
+ }),
2444
+ effect: "ask", cost: "variable", reversible: false, idempotent: true, auth: "member",
2445
+ examples: [{ fn: "optimal_route", args: { $from: "actor-123", $skill: "writing" }, workspace: "acme" }],
2446
+ }),
2447
+ // ── rag: family — OO-Brain hybrid vector+BM25 search ──────────────────────
2448
+ "rag:search": receiver({
2449
+ receiver: "rag:search",
2450
+ summary: "Search the OO-Brain knowledge corpus (Supabase pgvector). Hybrid retrieval: vector cosine + tsvector BM25 fused with RRF. Returns top-k chunks + a query_id. Always follow with rag:mark to close the quality loop.",
2451
+ request: z.object({
2452
+ query: z.string().describe("Natural-language query. Full sentence beats keywords."),
2453
+ k: z.number().int().min(1).max(20).optional().default(5).describe("Chunks to return (1–20, default 5)."),
2454
+ corpus: z.string().optional().default("@oo-brain").describe("Which imported brain (@-pointer, e.g. '@oo-brain'). Authority-walked against your workspace; omit for the platform default."),
2455
+ vault: z.enum(["oo-brain", "agency-operator", "personal-brain", "all"]).optional().default("all"),
2456
+ filter_path_prefix: z.string().optional(),
2457
+ filter_tags: z.array(z.string()).optional(),
2458
+ }),
2459
+ response: z.object({
2460
+ ok: z.boolean(),
2461
+ query_id: z.string().nullable().describe("UUID to pass to rag:mark. Null when no chunks matched."),
2462
+ chunks: z.array(z.object({
2463
+ id: z.string().optional(),
2464
+ vault_name: z.string(),
2465
+ file_path: z.string(),
2466
+ chunk_content: z.string(),
2467
+ contextual_blurb: z.string().optional(),
2468
+ rrf_score: z.number().optional(),
2469
+ frontmatter: z.record(z.string(), z.unknown()).optional(),
2470
+ })),
2471
+ query: z.string(),
2472
+ vault: z.string(),
2473
+ }),
2474
+ effect: "ask", auth: "read_corpus", cost: { fixed: 1 }, reversible: false, idempotent: true,
2475
+ }),
2476
+ "rag:list": receiver({
2477
+ receiver: "rag:list",
2478
+ summary: "List the knowledge corpora you may search (@-pointers), resolved by the workspace authority walk. The platform corpus @oo-brain is always included.",
2479
+ request: z.object({}),
2480
+ response: z.object({
2481
+ ok: z.boolean(),
2482
+ corpora: z.array(z.string()).describe("@-pointers the caller may read, e.g. ['@oo-brain']."),
2483
+ }),
2484
+ effect: "ask", auth: "read_corpus", cost: "free", reversible: false, idempotent: true,
2485
+ }),
2486
+ "rag:mark": receiver({
2487
+ receiver: "rag:mark",
2488
+ summary: "Close the quality loop on a rag:search call. Call before the turn ends. 'mark' = chunks helped; 'warn' = chunks didn't help; 'unsure' = can't assess.",
2489
+ request: z.object({
2490
+ query_id: z.string().uuid(),
2491
+ outcome: z.enum(["mark", "warn", "unsure"]),
2492
+ notes: z.string().optional(),
2493
+ corpus: z.string().optional().default("@oo-brain").describe("The corpus the query_id belongs to (@-pointer). Authority-walked; omit for the platform default."),
2494
+ }),
2495
+ response: z.object({
2496
+ ok: z.boolean(),
2497
+ query_id: z.string(),
2498
+ outcome: z.string(),
2499
+ }),
2500
+ effect: "signal", auth: "read_corpus", cost: "free", reversible: false, idempotent: false,
2501
+ }),
2137
2502
  };
2138
2503
  /**
2139
2504
  * RECIPES — the four agent journeys as typed, ordered receiver sequences (C6).
@@ -2152,5 +2517,7 @@ export const RECIPES = {
2152
2517
  transact: ["market:bounty", "pay:weight"],
2153
2518
  /** SOP: define a workflow → shape it with a diff → run it. */
2154
2519
  sop: ["workflow:create", "workflow:apply-diff", "workflow:run"],
2520
+ /** A2A: negotiate a deal → escrow → deliver → verify → settle (or dispute + refund). */
2521
+ a2a: ["market:offer", "market:counter", "market:accept", "market:escrow", "market:deliver", "market:verify", "market:settle", "market:dispute"],
2155
2522
  };
2156
2523
  //# sourceMappingURL=receivers.js.map