digital-tools 2.1.3 → 2.4.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 (294) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +2 -0
  4. package/dist/client.d.ts +109 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +69 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/define.d.ts +2 -2
  9. package/dist/define.d.ts.map +1 -1
  10. package/dist/define.js +21 -11
  11. package/dist/define.js.map +1 -1
  12. package/dist/function-ref.d.ts +229 -0
  13. package/dist/function-ref.d.ts.map +1 -0
  14. package/dist/function-ref.js +28 -0
  15. package/dist/function-ref.js.map +1 -0
  16. package/dist/function-sugar.d.ts +57 -0
  17. package/dist/function-sugar.d.ts.map +1 -0
  18. package/dist/function-sugar.js +79 -0
  19. package/dist/function-sugar.js.map +1 -0
  20. package/dist/index.d.ts +10 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +24 -4
  23. package/dist/index.js.map +1 -1
  24. package/dist/providers/analytics/mixpanel.d.ts.map +1 -1
  25. package/dist/providers/analytics/mixpanel.js +21 -18
  26. package/dist/providers/analytics/mixpanel.js.map +1 -1
  27. package/dist/providers/calendar/cal-com.d.ts.map +1 -1
  28. package/dist/providers/calendar/cal-com.js +10 -10
  29. package/dist/providers/calendar/cal-com.js.map +1 -1
  30. package/dist/providers/calendar/google-calendar.d.ts.map +1 -1
  31. package/dist/providers/calendar/google-calendar.js +4 -4
  32. package/dist/providers/calendar/google-calendar.js.map +1 -1
  33. package/dist/providers/crm/hubspot.d.ts.map +1 -1
  34. package/dist/providers/crm/hubspot.js +107 -85
  35. package/dist/providers/crm/hubspot.js.map +1 -1
  36. package/dist/providers/development/github.d.ts.map +1 -1
  37. package/dist/providers/development/github.js +40 -43
  38. package/dist/providers/development/github.js.map +1 -1
  39. package/dist/providers/ecommerce/shopify.d.ts.map +1 -1
  40. package/dist/providers/ecommerce/shopify.js +79 -62
  41. package/dist/providers/ecommerce/shopify.js.map +1 -1
  42. package/dist/providers/email/resend.d.ts.map +1 -1
  43. package/dist/providers/email/resend.js +20 -16
  44. package/dist/providers/email/resend.js.map +1 -1
  45. package/dist/providers/email/sendgrid.d.ts.map +1 -1
  46. package/dist/providers/email/sendgrid.js +12 -9
  47. package/dist/providers/email/sendgrid.js.map +1 -1
  48. package/dist/providers/finance/stripe.d.ts.map +1 -1
  49. package/dist/providers/finance/stripe.js +44 -42
  50. package/dist/providers/finance/stripe.js.map +1 -1
  51. package/dist/providers/forms/typeform.d.ts.map +1 -1
  52. package/dist/providers/forms/typeform.js +68 -58
  53. package/dist/providers/forms/typeform.js.map +1 -1
  54. package/dist/providers/knowledge/notion.d.ts.map +1 -1
  55. package/dist/providers/knowledge/notion.js +75 -41
  56. package/dist/providers/knowledge/notion.js.map +1 -1
  57. package/dist/providers/marketing/mailchimp.d.ts.map +1 -1
  58. package/dist/providers/marketing/mailchimp.js +74 -61
  59. package/dist/providers/marketing/mailchimp.js.map +1 -1
  60. package/dist/providers/media/cloudinary.d.ts.map +1 -1
  61. package/dist/providers/media/cloudinary.js +30 -28
  62. package/dist/providers/media/cloudinary.js.map +1 -1
  63. package/dist/providers/messaging/slack.d.ts.map +1 -1
  64. package/dist/providers/messaging/slack.js +75 -58
  65. package/dist/providers/messaging/slack.js.map +1 -1
  66. package/dist/providers/messaging/twilio-sms.d.ts.map +1 -1
  67. package/dist/providers/messaging/twilio-sms.js +33 -15
  68. package/dist/providers/messaging/twilio-sms.js.map +1 -1
  69. package/dist/providers/project-management/linear.d.ts.map +1 -1
  70. package/dist/providers/project-management/linear.js +31 -27
  71. package/dist/providers/project-management/linear.js.map +1 -1
  72. package/dist/providers/spreadsheet/google-sheets.d.ts.map +1 -1
  73. package/dist/providers/spreadsheet/google-sheets.js +21 -18
  74. package/dist/providers/spreadsheet/google-sheets.js.map +1 -1
  75. package/dist/providers/spreadsheet/xlsx.d.ts.map +1 -1
  76. package/dist/providers/spreadsheet/xlsx.js +4 -4
  77. package/dist/providers/spreadsheet/xlsx.js.map +1 -1
  78. package/dist/providers/storage/index.js +1 -0
  79. package/dist/providers/storage/index.js.map +1 -1
  80. package/dist/providers/storage/s3.d.ts.map +1 -1
  81. package/dist/providers/storage/s3.js +36 -27
  82. package/dist/providers/storage/s3.js.map +1 -1
  83. package/dist/providers/support/zendesk.d.ts.map +1 -1
  84. package/dist/providers/support/zendesk.js +24 -25
  85. package/dist/providers/support/zendesk.js.map +1 -1
  86. package/dist/providers/tasks/todoist.d.ts.map +1 -1
  87. package/dist/providers/tasks/todoist.js +18 -18
  88. package/dist/providers/tasks/todoist.js.map +1 -1
  89. package/dist/providers/video-conferencing/google-meet.d.ts.map +1 -1
  90. package/dist/providers/video-conferencing/google-meet.js +11 -11
  91. package/dist/providers/video-conferencing/google-meet.js.map +1 -1
  92. package/dist/providers/video-conferencing/jitsi.js +14 -14
  93. package/dist/providers/video-conferencing/jitsi.js.map +1 -1
  94. package/dist/providers/video-conferencing/teams.d.ts.map +1 -1
  95. package/dist/providers/video-conferencing/teams.js +9 -7
  96. package/dist/providers/video-conferencing/teams.js.map +1 -1
  97. package/dist/providers/video-conferencing/zoom.d.ts.map +1 -1
  98. package/dist/providers/video-conferencing/zoom.js +26 -24
  99. package/dist/providers/video-conferencing/zoom.js.map +1 -1
  100. package/dist/tools/data.d.ts.map +1 -1
  101. package/dist/tools/data.js +5 -12
  102. package/dist/tools/data.js.map +1 -1
  103. package/dist/tools/index.d.ts +1 -0
  104. package/dist/tools/index.d.ts.map +1 -1
  105. package/dist/tools/index.js +1 -0
  106. package/dist/tools/index.js.map +1 -1
  107. package/dist/tools/system.d.ts +289 -0
  108. package/dist/tools/system.d.ts.map +1 -0
  109. package/dist/tools/system.js +752 -0
  110. package/dist/tools/system.js.map +1 -0
  111. package/dist/tools/web.d.ts.map +1 -1
  112. package/dist/tools/web.js +22 -10
  113. package/dist/tools/web.js.map +1 -1
  114. package/dist/track-record.d.ts +101 -0
  115. package/dist/track-record.d.ts.map +1 -0
  116. package/dist/track-record.js +17 -0
  117. package/dist/track-record.js.map +1 -0
  118. package/dist/types.d.ts +210 -9
  119. package/dist/types.d.ts.map +1 -1
  120. package/dist/verb-registration.d.ts +122 -0
  121. package/dist/verb-registration.d.ts.map +1 -0
  122. package/dist/verb-registration.js +176 -0
  123. package/dist/verb-registration.js.map +1 -0
  124. package/dist/worker.d.ts +93 -0
  125. package/dist/worker.d.ts.map +1 -0
  126. package/dist/worker.js +315 -0
  127. package/dist/worker.js.map +1 -0
  128. package/dist/wrap.d.ts +89 -0
  129. package/dist/wrap.d.ts.map +1 -0
  130. package/dist/wrap.js +225 -0
  131. package/dist/wrap.js.map +1 -0
  132. package/package.json +31 -14
  133. package/src/client.ts +136 -0
  134. package/src/define.ts +30 -24
  135. package/src/function-ref.ts +264 -0
  136. package/src/function-sugar.ts +134 -0
  137. package/src/index.ts +132 -10
  138. package/src/providers/analytics/mixpanel.ts +19 -18
  139. package/src/providers/calendar/cal-com.ts +29 -18
  140. package/src/providers/calendar/google-calendar.ts +20 -14
  141. package/src/providers/crm/hubspot.ts +225 -99
  142. package/src/providers/development/github.ts +206 -135
  143. package/src/providers/ecommerce/shopify.ts +250 -89
  144. package/src/providers/email/resend.ts +101 -28
  145. package/src/providers/email/sendgrid.ts +12 -9
  146. package/src/providers/finance/stripe.ts +128 -49
  147. package/src/providers/forms/typeform.ts +74 -58
  148. package/src/providers/knowledge/notion.ts +340 -88
  149. package/src/providers/marketing/mailchimp.ts +86 -70
  150. package/src/providers/media/cloudinary.ts +99 -41
  151. package/src/providers/messaging/slack.ts +283 -85
  152. package/src/providers/messaging/twilio-sms.ts +35 -15
  153. package/src/providers/project-management/linear.ts +143 -55
  154. package/src/providers/spreadsheet/google-sheets.ts +222 -56
  155. package/src/providers/spreadsheet/xlsx.ts +47 -16
  156. package/src/providers/storage/s3.ts +119 -47
  157. package/src/providers/support/zendesk.ts +196 -46
  158. package/src/providers/tasks/todoist.ts +20 -26
  159. package/src/providers/video-conferencing/google-meet.ts +17 -20
  160. package/src/providers/video-conferencing/jitsi.ts +14 -14
  161. package/src/providers/video-conferencing/teams.ts +14 -13
  162. package/src/providers/video-conferencing/zoom.ts +54 -49
  163. package/src/tools/data.ts +6 -16
  164. package/src/tools/index.ts +1 -0
  165. package/src/tools/system.ts +887 -0
  166. package/src/tools/web.ts +22 -10
  167. package/src/track-record.ts +106 -0
  168. package/src/types.ts +241 -13
  169. package/src/verb-registration.ts +197 -0
  170. package/src/worker.ts +370 -0
  171. package/src/wrap.ts +260 -0
  172. package/test/client.test.ts +146 -0
  173. package/test/communication-tools-extended.test.ts +734 -0
  174. package/test/data-tools-extended.test.ts +743 -0
  175. package/test/define-extended.test.ts +819 -0
  176. package/test/define.test.ts +150 -41
  177. package/test/entities.test.ts +623 -0
  178. package/test/extended-entities.test.ts +1228 -0
  179. package/test/provider-implementations.test.ts +725 -0
  180. package/test/provider-registry-extended.test.ts +583 -0
  181. package/test/providers/google-sheets.test.ts +851 -0
  182. package/test/providers/helpers.ts +554 -0
  183. package/test/providers/hubspot.test.ts +576 -0
  184. package/test/providers/slack.test.ts +932 -0
  185. package/test/providers/stripe.test.ts +701 -0
  186. package/test/providers.test.ts +578 -0
  187. package/test/system-tools-extended.test.ts +632 -0
  188. package/test/system.test.ts +673 -0
  189. package/test/tools.test.ts +15 -11
  190. package/test/types.test.ts +402 -0
  191. package/test/verb-registration.test.ts +395 -0
  192. package/test/web-tools.test.ts +553 -0
  193. package/test/worker-extended.test.ts +699 -0
  194. package/test/worker.test.ts +576 -0
  195. package/test/wrap.test.ts +366 -0
  196. package/tsconfig.json +3 -13
  197. package/vitest.config.ts +37 -0
  198. package/wrangler.jsonc +9 -0
  199. package/LICENSE +0 -21
  200. package/dist/providers/voice/vapi.d.ts +0 -27
  201. package/dist/providers/voice/vapi.d.ts.map +0 -1
  202. package/dist/providers/voice/vapi.js +0 -440
  203. package/dist/providers/voice/vapi.js.map +0 -1
  204. package/src/define.js +0 -259
  205. package/src/entities/advertising.js +0 -999
  206. package/src/entities/ai.js +0 -756
  207. package/src/entities/analytics.js +0 -1588
  208. package/src/entities/automation.js +0 -601
  209. package/src/entities/communication.js +0 -1150
  210. package/src/entities/crm.js +0 -1386
  211. package/src/entities/design.js +0 -546
  212. package/src/entities/development.js +0 -2212
  213. package/src/entities/document.js +0 -874
  214. package/src/entities/ecommerce.js +0 -1429
  215. package/src/entities/experiment.js +0 -1039
  216. package/src/entities/finance.js +0 -3478
  217. package/src/entities/forms.js +0 -1892
  218. package/src/entities/hr.js +0 -661
  219. package/src/entities/identity.js +0 -997
  220. package/src/entities/index.js +0 -282
  221. package/src/entities/infrastructure.js +0 -1153
  222. package/src/entities/knowledge.js +0 -1438
  223. package/src/entities/marketing.js +0 -1610
  224. package/src/entities/media.js +0 -1634
  225. package/src/entities/notification.js +0 -1199
  226. package/src/entities/presentation.js +0 -1274
  227. package/src/entities/productivity.js +0 -1317
  228. package/src/entities/project-management.js +0 -1136
  229. package/src/entities/recruiting.js +0 -736
  230. package/src/entities/shipping.js +0 -509
  231. package/src/entities/signature.js +0 -1102
  232. package/src/entities/site.js +0 -222
  233. package/src/entities/spreadsheet.js +0 -1341
  234. package/src/entities/storage.js +0 -1198
  235. package/src/entities/support.js +0 -1166
  236. package/src/entities/video-conferencing.js +0 -1750
  237. package/src/entities/video.js +0 -950
  238. package/src/entities.js +0 -1663
  239. package/src/index.js +0 -74
  240. package/src/providers/analytics/index.js +0 -17
  241. package/src/providers/analytics/mixpanel.js +0 -255
  242. package/src/providers/calendar/cal-com.js +0 -303
  243. package/src/providers/calendar/google-calendar.js +0 -335
  244. package/src/providers/calendar/index.js +0 -20
  245. package/src/providers/crm/hubspot.js +0 -566
  246. package/src/providers/crm/index.js +0 -17
  247. package/src/providers/development/github.js +0 -472
  248. package/src/providers/development/index.js +0 -17
  249. package/src/providers/ecommerce/index.js +0 -17
  250. package/src/providers/ecommerce/shopify.js +0 -378
  251. package/src/providers/email/index.js +0 -20
  252. package/src/providers/email/resend.js +0 -258
  253. package/src/providers/email/sendgrid.js +0 -161
  254. package/src/providers/finance/index.js +0 -17
  255. package/src/providers/finance/stripe.js +0 -549
  256. package/src/providers/forms/index.js +0 -17
  257. package/src/providers/forms/typeform.js +0 -500
  258. package/src/providers/index.js +0 -123
  259. package/src/providers/knowledge/index.js +0 -17
  260. package/src/providers/knowledge/notion.js +0 -389
  261. package/src/providers/marketing/index.js +0 -17
  262. package/src/providers/marketing/mailchimp.js +0 -443
  263. package/src/providers/media/cloudinary.js +0 -318
  264. package/src/providers/media/index.js +0 -17
  265. package/src/providers/messaging/index.js +0 -20
  266. package/src/providers/messaging/slack.js +0 -393
  267. package/src/providers/messaging/twilio-sms.js +0 -249
  268. package/src/providers/project-management/index.js +0 -17
  269. package/src/providers/project-management/linear.js +0 -575
  270. package/src/providers/registry.js +0 -86
  271. package/src/providers/spreadsheet/google-sheets.js +0 -375
  272. package/src/providers/spreadsheet/index.js +0 -20
  273. package/src/providers/spreadsheet/xlsx.js +0 -423
  274. package/src/providers/storage/index.js +0 -24
  275. package/src/providers/storage/s3.js +0 -419
  276. package/src/providers/support/index.js +0 -17
  277. package/src/providers/support/zendesk.js +0 -373
  278. package/src/providers/tasks/index.js +0 -17
  279. package/src/providers/tasks/todoist.js +0 -286
  280. package/src/providers/types.js +0 -9
  281. package/src/providers/video-conferencing/google-meet.js +0 -286
  282. package/src/providers/video-conferencing/index.js +0 -31
  283. package/src/providers/video-conferencing/jitsi.js +0 -254
  284. package/src/providers/video-conferencing/teams.js +0 -270
  285. package/src/providers/video-conferencing/zoom.js +0 -332
  286. package/src/registry.js +0 -128
  287. package/src/tools/communication.js +0 -184
  288. package/src/tools/data.js +0 -205
  289. package/src/tools/index.js +0 -11
  290. package/src/tools/web.js +0 -137
  291. package/src/types.js +0 -10
  292. package/test/define.test.js +0 -306
  293. package/test/registry.test.js +0 -357
  294. package/test/tools.test.js +0 -363
@@ -1,4 +1,4 @@
1
1
 
2
- > digital-tools@2.1.3 build /Users/nathanclevenger/projects/primitives.org.ai/packages/digital-tools
2
+ > digital-tools@2.3.0 build /Users/nathanclevenger/projects/primitives.org.ai/packages/digital-tools
3
3
  > tsc
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # digital-tools
2
2
 
3
+ ## 2.4.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4d58f5f]
8
+ - Updated dependencies [d30c2e8]
9
+ - ai-functions@2.4.0
10
+ - business-as-code@2.4.0
11
+ - ai-database@2.4.0
12
+
13
+ ## 2.3.0
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [9e2779a]
18
+ - Updated dependencies [b7c7c57]
19
+ - ai-functions@2.3.0
20
+ - ai-database@2.3.0
21
+
3
22
  ## 2.1.3
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Digital Tools
2
2
 
3
+ ![Stability: Experimental](https://img.shields.io/badge/stability-experimental-red)
4
+
3
5
  Entity types (Nouns) and providers for digital tools usable by both humans and AI agents.
4
6
 
5
7
  ## Categories
@@ -0,0 +1,109 @@
1
+ /**
2
+ * RPC Client for digital-tools worker
3
+ *
4
+ * Connects to a deployed digital-tools worker using rpc.do,
5
+ * providing a fully typed client for tool discovery, execution,
6
+ * and MCP conversion.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { createToolClient } from 'digital-tools/client'
11
+ *
12
+ * const client = createToolClient('https://digital-tools.workers.dev')
13
+ * const tools = await client.list()
14
+ * const result = await client.executeTool('data.json.parse', { text: '{}' })
15
+ * ```
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import type { AnyTool, ToolCategory, ToolQuery, MCPTool, ToolSubcategory } from './types.js';
20
+ /**
21
+ * Client options for connecting to a digital-tools worker
22
+ */
23
+ export interface ToolClientOptions {
24
+ /** Authentication token */
25
+ token?: string;
26
+ /** Custom headers */
27
+ headers?: Record<string, string>;
28
+ }
29
+ /**
30
+ * API type matching ToolServiceCore's public RPC methods
31
+ *
32
+ * This interface mirrors the public methods of ToolServiceCore
33
+ * from the worker, providing a typed contract for the RPC client.
34
+ */
35
+ export interface ToolServiceAPI {
36
+ /** Register a tool in the service registry */
37
+ register(tool: AnyTool): void;
38
+ /** Unregister a tool */
39
+ unregister(id: string): boolean;
40
+ /** Get a tool by ID */
41
+ get(id: string): AnyTool | undefined;
42
+ /** Check if a tool exists */
43
+ has(id: string): boolean;
44
+ /** List all tool IDs */
45
+ list(): string[];
46
+ /** Query tools with filtering */
47
+ query(options: ToolQuery): AnyTool[];
48
+ /** Get tools by category */
49
+ byCategory(category: ToolCategory): AnyTool[];
50
+ /** Execute a tool by ID */
51
+ executeTool<TInput = unknown, TOutput = unknown>(id: string, input: TInput): Promise<TOutput>;
52
+ /** Convert a tool to MCP format */
53
+ toMCP(tool: AnyTool): MCPTool;
54
+ /** Convert all registered tools to MCP format */
55
+ listMCPTools(): MCPTool[];
56
+ /** Import a tool from MCP format */
57
+ fromMCP(mcpTool: MCPTool, handler: (input: unknown) => unknown | Promise<unknown>, options?: {
58
+ category?: ToolCategory;
59
+ subcategory?: ToolSubcategory;
60
+ tags?: string[];
61
+ }): AnyTool;
62
+ /** Clear all tools */
63
+ clear(keepBuiltins?: boolean): void;
64
+ }
65
+ /**
66
+ * Create an RPC client that connects to a deployed digital-tools worker
67
+ *
68
+ * @param url - The URL of the deployed digital-tools worker
69
+ * @param options - Optional client configuration
70
+ * @returns A typed RPC client for the tool service
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { createToolClient } from 'digital-tools/client'
75
+ *
76
+ * // Connect to default worker
77
+ * const client = createToolClient()
78
+ *
79
+ * // Connect to custom deployment
80
+ * const client = createToolClient('https://my-tools.example.com')
81
+ *
82
+ * // List available tools
83
+ * const toolIds = await client.list()
84
+ *
85
+ * // Execute a tool
86
+ * const result = await client.executeTool('data.json.parse', { text: '{"key": "value"}' })
87
+ *
88
+ * // Query tools by category
89
+ * const dataTools = await client.query({ category: 'data' })
90
+ *
91
+ * // Get MCP-compatible tool definitions
92
+ * const mcpTools = await client.listMCPTools()
93
+ * ```
94
+ */
95
+ export declare function createToolClient(url?: string, options?: ToolClientOptions): import("rpc.do").RPCProxy<ToolServiceAPI>;
96
+ /**
97
+ * Default RPC client connected to the standard digital-tools worker deployment
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import client from 'digital-tools/client'
102
+ *
103
+ * const tools = await client.list()
104
+ * const result = await client.executeTool('data.json.parse', { text: '{}' })
105
+ * ```
106
+ */
107
+ declare const client: import("rpc.do").RPCProxy<ToolServiceAPI>;
108
+ export default client;
109
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5F;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IAE7B,wBAAwB;IACxB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;IAE/B,uBAAuB;IACvB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;IAEpC,6BAA6B;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAA;IAExB,wBAAwB;IACxB,IAAI,IAAI,MAAM,EAAE,CAAA;IAEhB,iCAAiC;IACjC,KAAK,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,EAAE,CAAA;IAEpC,4BAA4B;IAC5B,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,EAAE,CAAA;IAE7C,2BAA2B;IAC3B,WAAW,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE7F,mCAAmC;IACnC,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAA;IAE7B,iDAAiD;IACjD,YAAY,IAAI,OAAO,EAAE,CAAA;IAEzB,oCAAoC;IACpC,OAAO,CACL,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,EACvD,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,YAAY,CAAA;QACvB,WAAW,CAAC,EAAE,eAAe,CAAA;QAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAChB,GACA,OAAO,CAAA;IAEV,sBAAsB;IACtB,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CACpC;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAoB,EAAE,OAAO,CAAC,EAAE,iBAAiB,6CAGtF;AAED;;;;;;;;;;GAUG;AACH,QAAA,MAAM,MAAM,2CAAqB,CAAA;AAEjC,eAAe,MAAM,CAAA"}
package/dist/client.js ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * RPC Client for digital-tools worker
3
+ *
4
+ * Connects to a deployed digital-tools worker using rpc.do,
5
+ * providing a fully typed client for tool discovery, execution,
6
+ * and MCP conversion.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { createToolClient } from 'digital-tools/client'
11
+ *
12
+ * const client = createToolClient('https://digital-tools.workers.dev')
13
+ * const tools = await client.list()
14
+ * const result = await client.executeTool('data.json.parse', { text: '{}' })
15
+ * ```
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import { RPC, http } from 'rpc.do';
20
+ /** Default worker URL for digital-tools */
21
+ const DEFAULT_URL = 'https://digital-tools.workers.dev';
22
+ /**
23
+ * Create an RPC client that connects to a deployed digital-tools worker
24
+ *
25
+ * @param url - The URL of the deployed digital-tools worker
26
+ * @param options - Optional client configuration
27
+ * @returns A typed RPC client for the tool service
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { createToolClient } from 'digital-tools/client'
32
+ *
33
+ * // Connect to default worker
34
+ * const client = createToolClient()
35
+ *
36
+ * // Connect to custom deployment
37
+ * const client = createToolClient('https://my-tools.example.com')
38
+ *
39
+ * // List available tools
40
+ * const toolIds = await client.list()
41
+ *
42
+ * // Execute a tool
43
+ * const result = await client.executeTool('data.json.parse', { text: '{"key": "value"}' })
44
+ *
45
+ * // Query tools by category
46
+ * const dataTools = await client.query({ category: 'data' })
47
+ *
48
+ * // Get MCP-compatible tool definitions
49
+ * const mcpTools = await client.listMCPTools()
50
+ * ```
51
+ */
52
+ export function createToolClient(url = DEFAULT_URL, options) {
53
+ const token = options?.token;
54
+ return RPC(http(url, token));
55
+ }
56
+ /**
57
+ * Default RPC client connected to the standard digital-tools worker deployment
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import client from 'digital-tools/client'
62
+ *
63
+ * const tools = await client.list()
64
+ * const result = await client.executeTool('data.json.parse', { text: '{}' })
65
+ * ```
66
+ */
67
+ const client = createToolClient();
68
+ export default client;
69
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAiElC,2CAA2C;AAC3C,MAAM,WAAW,GAAG,mCAAmC,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAc,WAAW,EAAE,OAA2B;IACrF,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,CAAA;IAC5B,OAAO,GAAG,CAAiB,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;AAEjC,eAAe,MAAM,CAAA"}
package/dist/define.d.ts CHANGED
@@ -94,7 +94,7 @@ export declare function toolBuilder(id: string): {
94
94
  name(name: string): /*elided*/ any;
95
95
  description(description: string): /*elided*/ any;
96
96
  category(category: DefineToolOptions<unknown, unknown>["category"]): /*elided*/ any;
97
- subcategory(subcategory: DefineToolOptions<unknown, unknown>["subcategory"]): /*elided*/ any;
97
+ subcategory(subcategory: NonNullable<DefineToolOptions<unknown, unknown>["subcategory"]>): /*elided*/ any;
98
98
  input(schema: Schema): /*elided*/ any;
99
99
  output(schema: Schema): /*elided*/ any;
100
100
  handler<TInput, TOutput>(fn: (input: TInput) => TOutput | Promise<TOutput>): {
@@ -102,7 +102,7 @@ export declare function toolBuilder(id: string): {
102
102
  register(): Tool<TInput, TOutput>;
103
103
  options(opts: Partial<AnyTool>): ReturnType<typeof toolBuilder>;
104
104
  };
105
- options(opts: Partial<AnyTool>): /*elided*/ any;
105
+ options(opts: NonNullable<DefineToolOptions<unknown, unknown>["options"]>): /*elided*/ any;
106
106
  build<TInput, TOutput>(): Tool<TInput, TOutput>;
107
107
  register<TInput, TOutput>(): Tool<TInput, TOutput>;
108
108
  };
@@ -1 +1 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV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AAC,CAAC,aAAa,CAAC,CAAC;kBAK1E,MAAM;mBAKL,MAAM;YAKb,MAAM,EAAE,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAE9C;QACxB,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC9B,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACjC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAA;KAChE;kBAGW,WAAW,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;UAKnE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;aAatC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC;EAMrD"}
package/dist/define.js CHANGED
@@ -80,14 +80,22 @@ export function defineTool(options) {
80
80
  name: options.name,
81
81
  description: options.description,
82
82
  category: options.category,
83
- subcategory: options.subcategory,
83
+ ...(options.subcategory !== undefined && { subcategory: options.subcategory }),
84
+ // SVO co-design (aip-oejp) — all optional. Verb auto-registration in
85
+ // digital-objects is intentionally deferred (see bead aip-oejp follow-up):
86
+ // we store the metadata here so dispatchers can resolve it, but we don't
87
+ // mutate the cross-package Verb registry from a `defineTool()` side-effect.
88
+ ...(options.verb !== undefined && { verb: options.verb }),
89
+ ...(options.frame !== undefined && { frame: options.frame }),
90
+ ...(options.auth !== undefined && { auth: options.auth }),
91
+ ...(options.pricing !== undefined && { pricing: options.pricing }),
84
92
  parameters: schemaToParameters(options.input),
85
- output: options.output
86
- ? {
93
+ ...(options.output && {
94
+ output: {
87
95
  description: 'Tool output',
88
96
  schema: options.output,
89
- }
90
- : undefined,
97
+ },
98
+ }),
91
99
  handler: options.handler,
92
100
  ...options.options,
93
101
  };
@@ -135,9 +143,7 @@ export function createToolExecutor(context) {
135
143
  };
136
144
  }
137
145
  // Check audience restrictions
138
- if (tool.audience &&
139
- tool.audience !== 'both' &&
140
- tool.audience !== context.executor.type) {
146
+ if (tool.audience && tool.audience !== 'both' && tool.audience !== context.executor.type) {
141
147
  return {
142
148
  success: false,
143
149
  error: {
@@ -155,7 +161,7 @@ export function createToolExecutor(context) {
155
161
  data,
156
162
  metadata: {
157
163
  duration,
158
- requestId: context.requestId,
164
+ ...(context.requestId !== undefined && { requestId: context.requestId }),
159
165
  },
160
166
  };
161
167
  }
@@ -170,7 +176,7 @@ export function createToolExecutor(context) {
170
176
  },
171
177
  metadata: {
172
178
  duration,
173
- requestId: context.requestId,
179
+ ...(context.requestId !== undefined && { requestId: context.requestId }),
174
180
  },
175
181
  };
176
182
  }
@@ -245,7 +251,11 @@ export function toolBuilder(id) {
245
251
  return this;
246
252
  },
247
253
  build() {
248
- if (!config.name || !config.description || !config.category || !config.input || !config.handler) {
254
+ if (!config.name ||
255
+ !config.description ||
256
+ !config.category ||
257
+ !config.input ||
258
+ !config.handler) {
249
259
  throw new Error('Tool requires id, name, description, category, input, and handler');
250
260
  }
251
261
  return defineTool(config);
@@ -1 +1 @@
1
- {"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAA;AAU3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;GAEG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,6DAA6D;QAC7D,yCAAyC;QACzC,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,8CAA8C;SAC5D,CAAA;IACH,CAAC;IACD,OAAO,MAAoB,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAAc;IACxC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CAAC,OAAO,GAAG,EAAoD,CAAA;YACrE,OAAO,IAIN,CAAA;QACH,CAAC;QAED,OAAO,CAAC,IAAiE;YACvE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;YACrB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,KAAK;YACH,IACE,CAAC,MAAM,CAAC,IAAI;gBACZ,CAAC,MAAM,CAAC,WAAW;gBACnB,CAAC,MAAM,CAAC,QAAQ;gBAChB,CAAC,MAAM,CAAC,KAAK;gBACb,CAAC,MAAM,CAAC,OAAO,EACf,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;YACtF,CAAC;YACD,OAAO,UAAU,CAAC,MAA4C,CAAC,CAAA;QACjE,CAAC;QAED,QAAQ;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAmB,CAAA;YAC1C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * FunctionRef — discriminated union of the Four Functions (v3 §6).
3
+ *
4
+ * The Services-as-Software book decomposes any cascade step into one of four
5
+ * Function kinds:
6
+ *
7
+ * - `code` — deterministic, programmable. A pure function or a
8
+ * reference to a code Action.
9
+ * - `generative` — single-shot LLM call (no tool use, no agentic loop).
10
+ * - `agentic` — looping, tool-using AI worker with a persona.
11
+ * - `human` — work that *must* be performed by a person, with a
12
+ * declared rationale + expiration policy describing the
13
+ * conditions under which the Function may be migrated to
14
+ * a non-human kind.
15
+ *
16
+ * Each kind carries the same per-Function knobs the v3 design pins:
17
+ * a {@link RewardSignal} reference, a {@link CostModel}, an
18
+ * {@link OversightPolicy}, and a {@link TrackRecord}. The agentic and human
19
+ * variants additionally carry kind-specific shape (mode/persona vs.
20
+ * rationale/expiration).
21
+ *
22
+ * This type is *additive* alongside the legacy {@link Tool} interface.
23
+ * Existing tools are not migrated; new SaS cascades use `FunctionRef` directly.
24
+ *
25
+ * @packageDocumentation
26
+ */
27
+ import type { ActionRef } from 'digital-objects';
28
+ import type { CostModel } from 'business-as-code/finance';
29
+ import type { AgentMode, PromotionPolicy, TrackRecord } from './track-record.js';
30
+ /**
31
+ * Placeholder reward signal — the canonical type ships in `business-as-code`
32
+ * once the OKR / KeyResult primitives land. Until then, a Function declares
33
+ * the KeyResult it should be rewarded against by reference.
34
+ *
35
+ * The string form is an MDXLD `$id` that resolves to a KeyResult node in the
36
+ * BaC graph (e.g. `'kr:revenue.q3.signups'`).
37
+ */
38
+ export interface RewardSignal {
39
+ /** `$id` of the KeyResult the Function moves the needle on. */
40
+ keyResultRef: string;
41
+ }
42
+ /**
43
+ * Reusable persona reference for an agentic Function — typically a string
44
+ * `$id` into the persona library shipped by `ai-evaluate`. Kept opaque here
45
+ * to avoid a layer-up dependency on `ai-evaluate`.
46
+ */
47
+ export type PersonaRef = string;
48
+ /**
49
+ * Sign-off policy on the output of an agentic Function before it is released
50
+ * downstream. `none` means no per-invocation sign-off (autonomous);
51
+ * `self` means the Function reviews its own output against its persona;
52
+ * `peer` requires another agentic Function to approve; `human` requires a
53
+ * human reviewer; `panel` defers to an EvaluatorPanel reference.
54
+ */
55
+ export type SignOffMode = 'none' | 'self' | 'peer' | 'human' | 'panel';
56
+ /**
57
+ * Declarative oversight gate applied per-invocation to a Function.
58
+ *
59
+ * `mode` selects the {@link AgentMode} the Function is currently operating in;
60
+ * `promotion` (when present) is the {@link PromotionPolicy} that may move the
61
+ * Function up or down the ladder based on its {@link TrackRecord}.
62
+ */
63
+ export interface OversightPolicy {
64
+ mode: AgentMode;
65
+ promotion?: PromotionPolicy;
66
+ }
67
+ /**
68
+ * Fields common to every Function kind. The discriminator (`kind`) is added
69
+ * by each variant so consumers can narrow with a single switch.
70
+ */
71
+ export interface BaseFunctionRef {
72
+ /** MDXLD `$id` (e.g. `'fn:code:summarize'`). */
73
+ $id: string;
74
+ /** Human-readable name used by the registry / UI. */
75
+ name: string;
76
+ /** Optional one-line description rendered by catalog UIs. */
77
+ description?: string;
78
+ /** Reward this Function is optimised against, when known. */
79
+ reward?: RewardSignal;
80
+ /** Declared cost model — used for budgeting and price quoting. */
81
+ costModel?: CostModel;
82
+ /** Per-Function oversight + autonomy policy. */
83
+ oversight?: OversightPolicy;
84
+ /**
85
+ * Accumulated quality / cost / override signal. Present on materialised
86
+ * (registered) Functions; omitted on the spec passed to a sugar factory.
87
+ */
88
+ track?: TrackRecord;
89
+ }
90
+ /**
91
+ * Code Function — deterministic, programmable.
92
+ *
93
+ * `handler` may be either an inline function (preferred for in-process
94
+ * Services) or an {@link ActionRef} string pointing at a registered Action
95
+ * in `digital-objects` (preferred for cross-process / serialisable cascades).
96
+ */
97
+ export interface CodeFunctionRef<TInput = unknown, TOutput = unknown> extends BaseFunctionRef {
98
+ kind: 'code';
99
+ handler: ((input: TInput) => TOutput | Promise<TOutput>) | ActionRef;
100
+ }
101
+ /**
102
+ * Generative Function — single-shot LLM call. No tool use, no loop.
103
+ *
104
+ * `modelHint` is an optional preferred model spec (e.g. `'claude-opus-4'`);
105
+ * the runtime is free to substitute based on cost/availability policy.
106
+ *
107
+ * `outputSchema` (round-13) is an optional per-step output contract used by
108
+ * the cascade walker to constrain mid-cascade Generative output. When
109
+ * present, the walker passes it to `ai-functions.generateObject` for that
110
+ * step; when absent, the walker falls back to the Service's
111
+ * `schema.output` for the LAST Generative step and `z.string()` for earlier
112
+ * ones. Typed as `unknown` because the canonical Standard Schema type lives
113
+ * in `services-as-software` and `digital-tools` shouldn't pull that
114
+ * dependency — call sites cast to their concrete schema type.
115
+ */
116
+ export interface GenerativeFunctionRef extends BaseFunctionRef {
117
+ kind: 'generative';
118
+ modelHint?: string;
119
+ outputSchema?: unknown;
120
+ }
121
+ /**
122
+ * Agentic Function — looping, tool-using AI worker with a persona and a
123
+ * sign-off rule.
124
+ */
125
+ export interface AgenticFunctionRef extends BaseFunctionRef {
126
+ kind: 'agentic';
127
+ /**
128
+ * Operating mode for this Function specifically. Mirrors
129
+ * {@link OversightPolicy.mode}; declared inline because the agentic kind is
130
+ * the primary consumer of the autonomy ladder.
131
+ */
132
+ mode: AgentMode;
133
+ /**
134
+ * Optional preferred model spec (e.g. `'claude-opus-4'`, `'sonnet'`).
135
+ * Mirrors {@link GenerativeFunctionRef.modelHint}; the runtime is free to
136
+ * substitute based on cost/availability/track-record policy. The
137
+ * `services-as-software` cascade walker forwards this to
138
+ * `ai-functions.generateText` for the agentic tool-use loop.
139
+ */
140
+ modelHint?: string;
141
+ /**
142
+ * Tool ids registered with `digital-tools.defineTool`. Each id resolves to
143
+ * exactly one {@link Tool} via the global registry. Scope-style strings
144
+ * (e.g. `'github.repos'`) are accepted but treated as literal tool ids,
145
+ * not permission scopes — the runtime does not expand `'github.repos'`
146
+ * into the set of github repo tools. True scope→tools resolution
147
+ * (capability-based permission expansion) is round-9+ work; until then,
148
+ * list each concrete tool id explicitly.
149
+ */
150
+ toolPermissions?: string[];
151
+ /**
152
+ * Concurrency policy for this Function:
153
+ *
154
+ * - `number` — hard cap on concurrent invocations (caller picks N).
155
+ * - `'serial'` — one invocation at a time (semantic alias for `1`).
156
+ * - `'fan-out'` — semantic "fan out as wide as upstream emits"; the
157
+ * cascade compiler chooses N at runtime based on the
158
+ * upstream step's emitted batch size and ambient
159
+ * cost-budget policy.
160
+ *
161
+ * Used by the runtime to bound cost on bursty workloads.
162
+ */
163
+ concurrency?: number | 'serial' | 'fan-out';
164
+ /** Persona reference (typically into the `ai-evaluate` persona library). */
165
+ persona?: PersonaRef;
166
+ /**
167
+ * Sign-off requirement before the Function's output is released downstream.
168
+ * Defaults to `'none'` for `mode === 'autonomous'`, `'human'` for
169
+ * `mode === 'supervised'`, and `'human'` for `mode === 'manual'`.
170
+ */
171
+ signOff?: SignOffMode;
172
+ }
173
+ /**
174
+ * Reasons a step in the cascade *must* be performed by a human. Drives both
175
+ * UX copy ("why is a human reviewing this?") and the migration policy
176
+ * ({@link HumanFunctionRef.expirationPolicy} declares when the human step
177
+ * may be replaced by a non-human Function).
178
+ */
179
+ export type HumanRationale = 'approval' | 'physical' | 'regulatory' | 'trust' | 'premium';
180
+ /**
181
+ * Conditions under which a {@link HumanFunctionRef} may be migrated to a
182
+ * non-human Function (typically an {@link AgenticFunctionRef}).
183
+ *
184
+ * The expiration is *declarative*: the policy is checked against the
185
+ * Function's accumulated {@link TrackRecord} (and any sibling-Function
186
+ * record indicated by `migrateTo`). When the predicate holds, the cascade
187
+ * compiler may swap the Human Function for the named target Function with
188
+ * the catalog operator's confirmation.
189
+ */
190
+ export interface HumanExpirationPolicy {
191
+ /** `$id` of the Function the human step should migrate to once eligible. */
192
+ migrateTo?: string;
193
+ /**
194
+ * Migrate when the cascade-without-the-human's accuracy exceeds this
195
+ * threshold (0–1). The bookkeeper case ("could AI have decided this
196
+ * correctly?") is the canonical example — see v3 §14 open decision.
197
+ */
198
+ whenAccuracyExceeds?: number;
199
+ /** Migrate when total samples exceed this count. */
200
+ whenSamplesExceed?: number;
201
+ }
202
+ /**
203
+ * Channel used to dispatch work to a human. Opaque string so concrete
204
+ * channels (Slack DM, email, in-app inbox, paging system, …) can be wired
205
+ * by the runtime without a type change here.
206
+ */
207
+ export type HumanChannel = string;
208
+ /**
209
+ * Human Function — work that must be performed by a person.
210
+ *
211
+ * Carries a declared {@link HumanRationale} (so UX can explain *why* a human
212
+ * is in the loop) and an {@link HumanExpirationPolicy} (so the cascade can
213
+ * eventually be migrated to a non-human Function once track-record allows).
214
+ */
215
+ export interface HumanFunctionRef extends BaseFunctionRef {
216
+ kind: 'human';
217
+ rationale: HumanRationale;
218
+ expirationPolicy: HumanExpirationPolicy;
219
+ channel?: HumanChannel;
220
+ }
221
+ /**
222
+ * Discriminated union of the Four Functions. Narrow with `switch (fn.kind)`.
223
+ */
224
+ export type FunctionRef = CodeFunctionRef | GenerativeFunctionRef | AgenticFunctionRef | HumanFunctionRef;
225
+ /**
226
+ * Discriminator string union — convenient for table-driven dispatchers.
227
+ */
228
+ export type FunctionKind = FunctionRef['kind'];
229
+ //# sourceMappingURL=function-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-ref.d.ts","sourceRoot":"","sources":["../src/function-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAMhF;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAA;CACrB;AAMD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAE/B;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;AAEtE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAA;IACf,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAMD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAA;IACX,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,gDAAgD;IAChD,SAAS,CAAC,EAAE,eAAe,CAAA;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,OAAO,EAAE,OA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EAAE,OAAO,CAAA;IACb,SAAS,EAAE,cAAc,CAAA;IACzB,gBAAgB,EAAE,qBAAqB,CAAA;IACvC,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,eAAe,GACf,qBAAqB,GACrB,kBAAkB,GAClB,gBAAgB,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * FunctionRef — discriminated union of the Four Functions (v3 §6).
3
+ *
4
+ * The Services-as-Software book decomposes any cascade step into one of four
5
+ * Function kinds:
6
+ *
7
+ * - `code` — deterministic, programmable. A pure function or a
8
+ * reference to a code Action.
9
+ * - `generative` — single-shot LLM call (no tool use, no agentic loop).
10
+ * - `agentic` — looping, tool-using AI worker with a persona.
11
+ * - `human` — work that *must* be performed by a person, with a
12
+ * declared rationale + expiration policy describing the
13
+ * conditions under which the Function may be migrated to
14
+ * a non-human kind.
15
+ *
16
+ * Each kind carries the same per-Function knobs the v3 design pins:
17
+ * a {@link RewardSignal} reference, a {@link CostModel}, an
18
+ * {@link OversightPolicy}, and a {@link TrackRecord}. The agentic and human
19
+ * variants additionally carry kind-specific shape (mode/persona vs.
20
+ * rationale/expiration).
21
+ *
22
+ * This type is *additive* alongside the legacy {@link Tool} interface.
23
+ * Existing tools are not migrated; new SaS cascades use `FunctionRef` directly.
24
+ *
25
+ * @packageDocumentation
26
+ */
27
+ export {};
28
+ //# sourceMappingURL=function-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-ref.js","sourceRoot":"","sources":["../src/function-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}