@finalai/final-agent-provider 0.7.0 → 0.9.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 (76) hide show
  1. package/HOSTING.md +3 -3
  2. package/README.md +26 -91
  3. package/dist/modules/channel-factories.d.mts +5 -6
  4. package/dist/modules/channel-factories.mjs +7 -11
  5. package/dist/modules/channel-factories.mjs.map +3 -3
  6. package/dist/modules/channels/inbound.mjs +2 -2
  7. package/dist/modules/channels/inbound.mjs.map +2 -2
  8. package/dist/modules/channels/index.d.mts +0 -7
  9. package/dist/modules/channels/index.mjs +0 -7
  10. package/dist/modules/channels/index.mjs.map +2 -2
  11. package/dist/modules/channels/prompt.d.mts +2 -2
  12. package/dist/modules/channels/prompt.mjs +3 -3
  13. package/dist/modules/channels/prompt.mjs.map +2 -2
  14. package/dist/modules/channels/routing.d.mts +1 -1
  15. package/dist/modules/channels/routing.mjs +1 -1
  16. package/dist/modules/channels/routing.mjs.map +1 -1
  17. package/dist/modules/sandboxes/bytes.d.mts +1 -0
  18. package/dist/modules/sandboxes/bytes.mjs +7 -1
  19. package/dist/modules/sandboxes/bytes.mjs.map +2 -2
  20. package/dist/modules/sandboxes/computer-processes.mjs +5 -3
  21. package/dist/modules/sandboxes/computer-processes.mjs.map +2 -2
  22. package/dist/modules/sandboxes/computer.mjs +5 -1
  23. package/dist/modules/sandboxes/computer.mjs.map +2 -2
  24. package/dist/modules/sandboxes/computers-api-transport.d.mts +1 -1
  25. package/dist/modules/sandboxes/computers-api-transport.mjs +8 -0
  26. package/dist/modules/sandboxes/computers-api-transport.mjs.map +2 -2
  27. package/dist/modules/sandboxes/device-api.mjs +8 -0
  28. package/dist/modules/sandboxes/device-api.mjs.map +2 -2
  29. package/dist/modules/sandboxes/device.mjs +6 -0
  30. package/dist/modules/sandboxes/device.mjs.map +2 -2
  31. package/dist/modules/sandboxes/session.d.mts +1 -0
  32. package/dist/modules/sandboxes/session.mjs +106 -36
  33. package/dist/modules/sandboxes/session.mjs.map +3 -3
  34. package/dist/modules/sandboxes/testing/conformance.mjs +3 -0
  35. package/dist/modules/sandboxes/testing/conformance.mjs.map +2 -2
  36. package/dist/modules/sandboxes/testing/fake-machine.mjs +11 -0
  37. package/dist/modules/sandboxes/testing/fake-machine.mjs.map +2 -2
  38. package/dist/modules/sandboxes/transport.d.mts +1 -0
  39. package/dist/modules/sandboxes/transport.mjs.map +2 -2
  40. package/package.json +4 -40
  41. package/dist/modules/channels/channel-utils.d.mts +0 -132
  42. package/dist/modules/channels/channel-utils.mjs +0 -445
  43. package/dist/modules/channels/channel-utils.mjs.map +0 -7
  44. package/dist/modules/channels/discord-dispatch.d.mts +0 -17
  45. package/dist/modules/channels/discord-dispatch.mjs +0 -139
  46. package/dist/modules/channels/discord-dispatch.mjs.map +0 -7
  47. package/dist/modules/channels/discord-gateway.d.mts +0 -19
  48. package/dist/modules/channels/discord-gateway.mjs +0 -233
  49. package/dist/modules/channels/discord-gateway.mjs.map +0 -7
  50. package/dist/modules/channels/discord.d.mts +0 -9
  51. package/dist/modules/channels/discord.mjs +0 -904
  52. package/dist/modules/channels/discord.mjs.map +0 -7
  53. package/dist/modules/channels/github.d.mts +0 -5
  54. package/dist/modules/channels/github.mjs +0 -720
  55. package/dist/modules/channels/github.mjs.map +0 -7
  56. package/dist/modules/channels/linear.d.mts +0 -4
  57. package/dist/modules/channels/linear.mjs +0 -621
  58. package/dist/modules/channels/linear.mjs.map +0 -7
  59. package/dist/modules/channels/phone.d.mts +0 -8
  60. package/dist/modules/channels/phone.mjs +0 -382
  61. package/dist/modules/channels/phone.mjs.map +0 -7
  62. package/dist/modules/channels/reply-receipts.d.mts +0 -31
  63. package/dist/modules/channels/reply-receipts.mjs +0 -63
  64. package/dist/modules/channels/reply-receipts.mjs.map +0 -7
  65. package/dist/modules/channels/slack.d.mts +0 -7
  66. package/dist/modules/channels/slack.mjs +0 -1134
  67. package/dist/modules/channels/slack.mjs.map +0 -7
  68. package/dist/modules/channels/voice-recording.d.mts +0 -7
  69. package/dist/modules/channels/voice-recording.mjs +0 -49
  70. package/dist/modules/channels/voice-recording.mjs.map +0 -7
  71. package/dist/modules/channels/voice.d.mts +0 -33
  72. package/dist/modules/channels/voice.mjs +0 -851
  73. package/dist/modules/channels/voice.mjs.map +0 -7
  74. package/dist/modules/channels/webhook.d.mts +0 -5
  75. package/dist/modules/channels/webhook.mjs +0 -76
  76. package/dist/modules/channels/webhook.mjs.map +0 -7
@@ -1,63 +0,0 @@
1
- import * as z from "zod";
2
- import { deliveryRetention, providerPlaceKey, stateKey } from "./channel-utils.mjs";
3
- const mirrorReceiptKey = (args) => {
4
- if (!args.externalKey.startsWith("final:")) return null;
5
- const id = args.externalKey.slice(6);
6
- if (id.length === 0 || id.length > 256 || args.messageId != null && args.messageId !== id)
7
- return null;
8
- return stateKey(`${args.provider}-mirror`, providerPlaceKey(args.place), id);
9
- };
10
- const deletedMirrorReceiptSchema = z.object({ deleted: z.literal(true) });
11
- const settleMirrorReaction = async (args) => {
12
- try {
13
- await args.work();
14
- } catch (cause) {
15
- if (args.key == null) throw cause;
16
- const result = await args.classify(cause);
17
- if (result === "retry") throw cause;
18
- if (result === "missing")
19
- await args.ctx.store.set(args.key, { deleted: true }, deliveryRetention);
20
- else args.ctx.log("Mirrored reaction unavailable.");
21
- }
22
- };
23
- const activeReplies = /* @__PURE__ */ new Map();
24
- const shareReplyReceipt = async (args) => {
25
- const lockKey = stateKey(args.bindingId, args.destination);
26
- const preceding = activeReplies.get(lockKey);
27
- const settled = Promise.withResolvers();
28
- activeReplies.set(lockKey, settled.promise);
29
- await preceding;
30
- try {
31
- let canonical = args.originKey;
32
- for (const messageId of args.messageIds) {
33
- const saved = z.string().safeParse(await args.store.get(stateKey("reply-message", args.destination, messageId)));
34
- if (saved.success && await args.store.get(saved.data) != null) {
35
- canonical = saved.data;
36
- break;
37
- }
38
- }
39
- const duplicate = canonical === args.originKey ? null : await args.store.get(args.originKey);
40
- await args.send(canonical);
41
- const receipt = await args.store.get(canonical);
42
- if (receipt == null) return;
43
- if (duplicate != null) await args.removeDuplicate?.(duplicate, receipt);
44
- if (canonical !== args.originKey)
45
- await args.store.set(args.originKey, receipt, deliveryRetention);
46
- for (const messageId of args.messageIds)
47
- await args.store.set(
48
- stateKey("reply-message", args.destination, messageId),
49
- canonical,
50
- deliveryRetention
51
- );
52
- } finally {
53
- settled.resolve();
54
- if (activeReplies.get(lockKey) === settled.promise) activeReplies.delete(lockKey);
55
- }
56
- };
57
- export {
58
- deletedMirrorReceiptSchema,
59
- mirrorReceiptKey,
60
- settleMirrorReaction,
61
- shareReplyReceipt
62
- };
63
- //# sourceMappingURL=reply-receipts.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/channels/reply-receipts.ts"],
4
- "sourcesContent": ["import type { ChannelReceiveContextIface, JsonValue, PlaceRef } from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { deliveryRetention, providerPlaceKey, stateKey } from \"./channel-utils.mjs\";\n\ninterface MirrorReceiptKeyArgsIface {\n provider: string;\n place: PlaceRef;\n externalKey: string;\n messageId?: string;\n}\nexport const mirrorReceiptKey = (args: MirrorReceiptKeyArgsIface): string | null => {\n if (!args.externalKey.startsWith('final:')) return null;\n const id = args.externalKey.slice(6);\n if (id.length === 0 || id.length > 256 || (args.messageId != null && args.messageId !== id))\n return null;\n return stateKey(`${args.provider}-mirror`, providerPlaceKey(args.place), id);\n};\nexport const deletedMirrorReceiptSchema = z.object({ deleted: z.literal(true) });\nexport type MirrorReactionResult = 'missing' | 'unavailable' | 'retry';\ninterface MirrorReactionArgsIface {\n ctx: Pick<ChannelReceiveContextIface, 'store' | 'log'>;\n key: string | null;\n work(): Promise<void>;\n classify(cause: unknown): Promise<MirrorReactionResult>;\n}\nexport const settleMirrorReaction = async (args: MirrorReactionArgsIface): Promise<void> => {\n try {\n await args.work();\n } catch (cause) {\n if (args.key == null) throw cause;\n const result = await args.classify(cause);\n if (result === 'retry') throw cause;\n if (result === 'missing')\n await args.ctx.store.set(args.key, { deleted: true }, deliveryRetention);\n else args.ctx.log('Mirrored reaction unavailable.');\n }\n};\n\nconst activeReplies = new Map<string, Promise<void>>();\ninterface ReplyReceiptArgsIface {\n bindingId: string;\n store: ChannelReceiveContextIface['store'];\n destination: string;\n messageIds: readonly string[];\n originKey: string;\n send(key: string): Promise<void>;\n removeDuplicate?(receipt: JsonValue, canonical: JsonValue): Promise<void>;\n}\n// Several accepted prompts can share one reply. Keep each origin's mutation receipt.\nexport const shareReplyReceipt = async (args: ReplyReceiptArgsIface): Promise<void> => {\n const lockKey = stateKey(args.bindingId, args.destination);\n const preceding = activeReplies.get(lockKey);\n const settled = Promise.withResolvers<void>();\n activeReplies.set(lockKey, settled.promise);\n await preceding;\n try {\n let canonical = args.originKey;\n for (const messageId of args.messageIds) {\n const saved = z\n .string()\n .safeParse(await args.store.get(stateKey('reply-message', args.destination, messageId)));\n if (saved.success && (await args.store.get(saved.data)) != null) {\n canonical = saved.data;\n break;\n }\n }\n const duplicate = canonical === args.originKey ? null : await args.store.get(args.originKey);\n await args.send(canonical);\n const receipt = await args.store.get(canonical);\n if (receipt == null) return;\n if (duplicate != null) await args.removeDuplicate?.(duplicate, receipt);\n if (canonical !== args.originKey)\n await args.store.set(args.originKey, receipt, deliveryRetention);\n for (const messageId of args.messageIds)\n await args.store.set(\n stateKey('reply-message', args.destination, messageId),\n canonical,\n deliveryRetention,\n );\n } finally {\n settled.resolve();\n if (activeReplies.get(lockKey) === settled.promise) activeReplies.delete(lockKey);\n }\n};\n"],
5
- "mappings": "AACA,YAAY,OAAO;AACnB,SAAS,mBAAmB,kBAAkB,gBAAgB;AAQvD,MAAM,mBAAmB,CAAC,SAAmD;AAClF,MAAI,CAAC,KAAK,YAAY,WAAW,QAAQ,EAAG,QAAO;AACnD,QAAM,KAAK,KAAK,YAAY,MAAM,CAAC;AACnC,MAAI,GAAG,WAAW,KAAK,GAAG,SAAS,OAAQ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AAM,IAAI,SAAS;AAC9C,QAAI,WAAW,KAAM;AACrB,QAAI,aAAa,KAAM,OAAM,KAAK,kBAAkB,WAAW,OAAO;AACtE,QAAI,cAAc,KAAK;AACrB,YAAM,KAAK,MAAM,IAAI,KAAK,WAAW,SAAS,iBAAiB;AACjE,eAAW,aAAa,KAAK;AAC3B,YAAM,KAAK,MAAM;AAAA,QACf,SAAS,iBAAiB,KAAK,aAAa,SAAS;AAAA,QACrD;AAAA,QACA;AAAA,MACF;AAAA,EACJ,UAAE;AACA,YAAQ,QAAQ;AAChB,QAAI,cAAc,IAAI,OAAO,MAAM,QAAQ,QAAS,eAAc,OAAO,OAAO;AAAA,EAClF;AACF;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- import { type JsonObject, type JsonValue } from '@finalai/agent-provider';
2
- export declare const slackChannel: (options?: JsonObject) => import("@finalai/agent-provider").ChannelDefinitionIface<{
3
- history: "none" | "linked-members";
4
- baseUrl?: string | undefined;
5
- }, JsonValue, {
6
- text: string;
7
- }>;