@finalai/agents 0.10.0 → 0.12.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 (185) hide show
  1. package/HOSTING.md +334 -245
  2. package/README.md +214 -29
  3. package/dist/modules/agent-client/agent-input.d.mts +24 -0
  4. package/dist/modules/agent-client/agent-input.mjs +46 -0
  5. package/dist/modules/agent-client/agent-input.mjs.map +7 -0
  6. package/dist/modules/agent-client/channels.d.mts +52 -3
  7. package/dist/modules/agent-client/channels.mjs +71 -10
  8. package/dist/modules/agent-client/channels.mjs.map +2 -2
  9. package/dist/modules/agent-client/client.d.mts +85 -20
  10. package/dist/modules/agent-client/client.mjs +74 -21
  11. package/dist/modules/agent-client/client.mjs.map +2 -2
  12. package/dist/modules/agent-client/config-options.mjs +1 -2
  13. package/dist/modules/agent-client/config-options.mjs.map +2 -2
  14. package/dist/modules/agent-client/conversation-resources.d.mts +85 -0
  15. package/dist/modules/agent-client/conversation-resources.mjs +150 -0
  16. package/dist/modules/agent-client/conversation-resources.mjs.map +7 -0
  17. package/dist/modules/agent-client/conversations.d.mts +116 -38
  18. package/dist/modules/agent-client/conversations.mjs +379 -71
  19. package/dist/modules/agent-client/conversations.mjs.map +2 -2
  20. package/dist/modules/agent-client/defaults.d.mts +8 -0
  21. package/dist/modules/agent-client/defaults.mjs +77 -0
  22. package/dist/modules/agent-client/defaults.mjs.map +7 -0
  23. package/dist/modules/agent-client/errors.d.mts +22 -2
  24. package/dist/modules/agent-client/errors.mjs +19 -0
  25. package/dist/modules/agent-client/errors.mjs.map +2 -2
  26. package/dist/modules/agent-client/events.d.mts +62 -0
  27. package/dist/modules/agent-client/events.mjs +107 -0
  28. package/dist/modules/agent-client/events.mjs.map +7 -0
  29. package/dist/modules/agent-client/harnesses.d.mts +66 -0
  30. package/dist/modules/agent-client/harnesses.mjs +156 -0
  31. package/dist/modules/agent-client/harnesses.mjs.map +7 -0
  32. package/dist/modules/agent-client/http.d.mts +2 -1
  33. package/dist/modules/agent-client/http.mjs +21 -2
  34. package/dist/modules/agent-client/http.mjs.map +2 -2
  35. package/dist/modules/agent-client/index.d.mts +21 -6
  36. package/dist/modules/agent-client/index.mjs +26 -0
  37. package/dist/modules/agent-client/index.mjs.map +2 -2
  38. package/dist/modules/agent-client/integrations.d.mts +40 -0
  39. package/dist/modules/agent-client/integrations.mjs +92 -0
  40. package/dist/modules/agent-client/integrations.mjs.map +7 -0
  41. package/dist/modules/agent-client/local-host-protocol.d.mts +156 -0
  42. package/dist/modules/agent-client/local-host-protocol.mjs +258 -0
  43. package/dist/modules/agent-client/local-host-protocol.mjs.map +7 -0
  44. package/dist/modules/agent-client/local-host.d.mts +56 -0
  45. package/dist/modules/agent-client/local-host.mjs +200 -0
  46. package/dist/modules/agent-client/local-host.mjs.map +7 -0
  47. package/dist/modules/agent-client/oauth-clients.d.mts +36 -0
  48. package/dist/modules/agent-client/oauth-clients.mjs +67 -0
  49. package/dist/modules/agent-client/oauth-clients.mjs.map +7 -0
  50. package/dist/modules/agent-client/project-agents.d.mts +54 -0
  51. package/dist/modules/agent-client/project-agents.mjs +111 -0
  52. package/dist/modules/agent-client/project-agents.mjs.map +7 -0
  53. package/dist/modules/agent-client/project.d.mts +43 -0
  54. package/dist/modules/agent-client/project.mjs +66 -0
  55. package/dist/modules/agent-client/project.mjs.map +7 -0
  56. package/dist/modules/agent-client/projects.d.mts +61 -0
  57. package/dist/modules/agent-client/projects.mjs +145 -0
  58. package/dist/modules/agent-client/projects.mjs.map +7 -0
  59. package/dist/modules/agent-client/provide.d.mts +41 -0
  60. package/dist/modules/agent-client/provide.mjs +90 -0
  61. package/dist/modules/agent-client/provide.mjs.map +7 -0
  62. package/dist/modules/agent-client/publishers.d.mts +57 -0
  63. package/dist/modules/agent-client/publishers.mjs +109 -0
  64. package/dist/modules/agent-client/publishers.mjs.map +7 -0
  65. package/dist/modules/agent-client/requirements.d.mts +60 -0
  66. package/dist/modules/agent-client/requirements.mjs +83 -0
  67. package/dist/modules/agent-client/requirements.mjs.map +7 -0
  68. package/dist/modules/agent-client/sandbox-providers.d.mts +34 -0
  69. package/dist/modules/agent-client/sandbox-providers.mjs +75 -0
  70. package/dist/modules/agent-client/sandbox-providers.mjs.map +7 -0
  71. package/dist/modules/agent-client/sandbox-uri.d.mts +1 -1
  72. package/dist/modules/agent-client/sandbox-uri.mjs +4 -4
  73. package/dist/modules/agent-client/sandbox-uri.mjs.map +1 -1
  74. package/dist/modules/agent-client/sandboxes.d.mts +65 -0
  75. package/dist/modules/agent-client/sandboxes.mjs +130 -0
  76. package/dist/modules/agent-client/sandboxes.mjs.map +7 -0
  77. package/dist/modules/agent-client/schedules.d.mts +24 -0
  78. package/dist/modules/agent-client/schedules.mjs +56 -0
  79. package/dist/modules/agent-client/schedules.mjs.map +7 -0
  80. package/dist/modules/agent-client/sessions.d.mts +46 -8
  81. package/dist/modules/agent-client/sessions.mjs +91 -29
  82. package/dist/modules/agent-client/sessions.mjs.map +2 -2
  83. package/dist/modules/agent-client/start.d.mts +101 -0
  84. package/dist/modules/agent-client/start.mjs +260 -0
  85. package/dist/modules/agent-client/start.mjs.map +7 -0
  86. package/dist/modules/agent-client/test-fakes.d.mts +1 -0
  87. package/dist/modules/agent-client/test-fakes.mjs +3 -1
  88. package/dist/modules/agent-client/test-fakes.mjs.map +2 -2
  89. package/dist/modules/cli/agent-module.d.mts +39 -0
  90. package/dist/modules/cli/agent-module.mjs +89 -0
  91. package/dist/modules/cli/agent-module.mjs.map +7 -0
  92. package/dist/modules/cli/cli.d.mts +6 -6
  93. package/dist/modules/cli/cli.mjs +94 -120
  94. package/dist/modules/cli/cli.mjs.map +2 -2
  95. package/dist/modules/cli/conformance.d.mts +2 -6
  96. package/dist/modules/cli/conformance.mjs +5 -8
  97. package/dist/modules/cli/conformance.mjs.map +2 -2
  98. package/dist/modules/cli/main.mjs.map +1 -1
  99. package/dist/modules/cli/output.d.mts +0 -9
  100. package/dist/modules/cli/output.mjs +7 -85
  101. package/dist/modules/cli/output.mjs.map +2 -2
  102. package/dist/modules/harnesses.mjs.map +2 -2
  103. package/dist/modules/index.d.mts +0 -2
  104. package/dist/modules/index.mjs +0 -4
  105. package/dist/modules/index.mjs.map +2 -2
  106. package/dist/modules/integrations.d.mts +24 -0
  107. package/dist/modules/integrations.mjs +30 -0
  108. package/dist/modules/integrations.mjs.map +7 -0
  109. package/dist/modules/public.d.mts +10 -10
  110. package/dist/modules/public.mjs +29 -78
  111. package/dist/modules/public.mjs.map +2 -2
  112. package/dist/modules/sandboxes.d.mts +2 -0
  113. package/dist/modules/sandboxes.mjs +4 -0
  114. package/dist/modules/sandboxes.mjs.map +2 -2
  115. package/dist/modules/verify.d.mts +1 -0
  116. package/dist/modules/verify.mjs +2 -0
  117. package/dist/modules/verify.mjs.map +7 -0
  118. package/dist/modules/webhooks.d.mts +37 -0
  119. package/dist/modules/webhooks.mjs +100 -0
  120. package/dist/modules/webhooks.mjs.map +7 -0
  121. package/examples/release-scout/README.md +18 -10
  122. package/examples/release-scout/agent.ts +41 -0
  123. package/examples/release-scout/by-name.ts +43 -0
  124. package/examples/release-scout/db.ts +6 -0
  125. package/examples/release-scout/instructions.md +5 -0
  126. package/examples/release-scout/run-on-a-computer.ts +49 -0
  127. package/examples/release-scout/run.ts +38 -0
  128. package/package.json +42 -28
  129. package/dist/modules/agent-client/build.d.mts +0 -110
  130. package/dist/modules/agent-client/build.mjs +0 -213
  131. package/dist/modules/agent-client/build.mjs.map +0 -7
  132. package/dist/modules/authoring/index.d.mts +0 -1
  133. package/dist/modules/authoring/index.mjs +0 -2
  134. package/dist/modules/authoring/index.mjs.map +0 -7
  135. package/dist/modules/authoring/instructions.d.mts +0 -1
  136. package/dist/modules/authoring/instructions.mjs +0 -2
  137. package/dist/modules/authoring/instructions.mjs.map +0 -7
  138. package/dist/modules/authoring/providers.d.mts +0 -2
  139. package/dist/modules/authoring/providers.mjs +0 -1
  140. package/dist/modules/authoring/providers.mjs.map +0 -7
  141. package/dist/modules/cli/build.d.mts +0 -22
  142. package/dist/modules/cli/build.mjs +0 -77
  143. package/dist/modules/cli/build.mjs.map +0 -7
  144. package/dist/modules/cli/channel-install.d.mts +0 -12
  145. package/dist/modules/cli/channel-install.mjs +0 -25
  146. package/dist/modules/cli/channel-install.mjs.map +0 -7
  147. package/dist/modules/cli/channel-socket.d.mts +0 -9
  148. package/dist/modules/cli/channel-socket.mjs +0 -114
  149. package/dist/modules/cli/channel-socket.mjs.map +0 -7
  150. package/dist/modules/cli/dev.d.mts +0 -26
  151. package/dist/modules/cli/dev.mjs +0 -311
  152. package/dist/modules/cli/dev.mjs.map +0 -7
  153. package/dist/modules/cli/files.d.mts +0 -18
  154. package/dist/modules/cli/files.mjs +0 -66
  155. package/dist/modules/cli/files.mjs.map +0 -7
  156. package/dist/modules/cli/harness-descriptions.d.mts +0 -20
  157. package/dist/modules/cli/harness-descriptions.mjs +0 -70
  158. package/dist/modules/cli/harness-descriptions.mjs.map +0 -7
  159. package/dist/modules/cli/publish.d.mts +0 -15
  160. package/dist/modules/cli/publish.mjs +0 -92
  161. package/dist/modules/cli/publish.mjs.map +0 -7
  162. package/dist/modules/compile.d.mts +0 -3
  163. package/dist/modules/compile.mjs +0 -58
  164. package/dist/modules/compile.mjs.map +0 -7
  165. package/dist/modules/index.browser.d.mts +0 -4
  166. package/dist/modules/index.browser.mjs +0 -8
  167. package/dist/modules/index.browser.mjs.map +0 -7
  168. package/examples/custom-harness/README.md +0 -16
  169. package/examples/custom-harness/agent.ts +0 -154
  170. package/examples/custom-sandbox/README.md +0 -12
  171. package/examples/custom-sandbox/agent.ts +0 -14
  172. package/examples/custom-sandbox/sandbox.ts +0 -24
  173. package/examples/release-scout/agent/agent.ts +0 -22
  174. package/examples/release-scout/agent/channels/github-signature.ts +0 -27
  175. package/examples/release-scout/agent/channels/github.ts +0 -32
  176. package/examples/release-scout/agent/connections/linear.ts +0 -9
  177. package/examples/release-scout/agent/hooks/audit.ts +0 -24
  178. package/examples/release-scout/agent/instructions/org-context.ts +0 -26
  179. package/examples/release-scout/agent/instructions.md +0 -2
  180. package/examples/release-scout/agent/sandbox.ts +0 -20
  181. package/examples/release-scout/agent/schedules/daily-digest.md +0 -7
  182. package/examples/release-scout/agent/skills/triage/SKILL.md +0 -8
  183. package/examples/release-scout/agent/skills/triage/checklist.md +0 -3
  184. package/examples/release-scout/agent/tools/lookup_release_notes.ts +0 -24
  185. package/examples/release-scout/client.ts +0 -122
@@ -1,24 +0,0 @@
1
- import { defineTool } from '@finalai/agents';
2
- import { never } from '@finalai/agents/approval';
3
- import * as z from 'zod';
4
-
5
- const releaseSchema = z.object({ body: z.string().nullable(), published_at: z.string() });
6
-
7
- export default defineTool({
8
- description: 'Fetch the release notes for a version tag.',
9
- inputSchema: z.object({ tag: z.string().regex(/^\d+\.\d+\.\d+$/) }),
10
- approval: never(),
11
- async execute({ tag }, ctx) {
12
- const token = await ctx.secrets.get('github-token');
13
- if (token == null) throw new Error('Missing secret github-token');
14
- const res = await fetch(`https://api.github.com/repos/final/app/releases/tags/v${tag}`, {
15
- headers: { authorization: `Bearer ${token}` },
16
- signal: ctx.abortSignal,
17
- });
18
- const text = await res.text();
19
- if (res.status === 404) return { found: false };
20
- if (!res.ok) throw new Error(`Release notes request failed (${res.status})`);
21
- const { body, published_at } = releaseSchema.parse(JSON.parse(text));
22
- return { found: true, publishedAt: published_at, notes: body ?? '' };
23
- },
24
- });
@@ -1,122 +0,0 @@
1
- import {
2
- createClient,
3
- sessionUpdateOf,
4
- textOf,
5
- type AgentClientIface,
6
- } from '@finalai/agents/client';
7
- import 'zod/compile';
8
-
9
- export const directSession = async (client: AgentClientIface, signal?: AbortSignal) => {
10
- const { handle, response } = await client.sessions.create({
11
- agent: 'release-scout',
12
- message: 'Did 2.4.1 ship?',
13
- signal,
14
- });
15
- try {
16
- if (response == null) throw new Error('The initial message must create a response');
17
- for await (const event of response.stream({ signal })) {
18
- const update = sessionUpdateOf(event);
19
- if (update?.sessionUpdate === 'agent_message_chunk') process.stdout.write(textOf(update));
20
- if (event.decisionId != null) console.log('Awaiting a decision:', event.decisionId);
21
- }
22
- console.log((await response.result({ signal })).stopReason);
23
- await handle.observe('The release was moved to Friday.', { signal });
24
- return await handle.manifest({ signal });
25
- } finally {
26
- // Close cleanup has its own lifetime, even when the prompt was aborted.
27
- await handle.close();
28
- }
29
- };
30
-
31
- // The source must be idle on a harness with native forks, such as remote Claude Code.
32
- export const forkNativeSession = (
33
- client: AgentClientIface,
34
- args: {
35
- sourceSessionId: string;
36
- idempotencyKey: string;
37
- signal?: AbortSignal;
38
- },
39
- ) =>
40
- client.sessions.attach(args.sourceSessionId).fork({
41
- idempotencyKey: args.idempotencyKey,
42
- title: 'Alternative investigation',
43
- signal: args.signal,
44
- });
45
-
46
- export const directConversation = async (client: AgentClientIface, signal?: AbortSignal) => {
47
- const direct = await client.conversations.direct({ agent: 'release-scout', signal });
48
- const sent = await direct.send('Did 2.4.1 ship?', { signal });
49
- // Durable delivery receipts also cover blank replies and a turn completed before subscribe.
50
- for (const delivery of sent.deliveries) {
51
- if (delivery.sessionId == null || delivery.turnId == null) continue;
52
- const session = client.sessions.attach(delivery.sessionId);
53
- const response = await session.response(delivery.turnId, { signal });
54
- for await (const event of response.stream({ signal })) {
55
- const update = sessionUpdateOf(event);
56
- if (update?.sessionUpdate === 'agent_message_chunk') process.stdout.write(textOf(update));
57
- if (event.decisionId != null) console.log('Decision required:', event.decisionId);
58
- }
59
- console.log((await response.result({ signal })).stopReason);
60
- }
61
- const page = await direct.messages({ limit: 50, signal });
62
- const last = page.messages.at(-1);
63
- if (last != null) await direct.markRead({ throughSeq: last.seq }, { signal });
64
- return direct;
65
- };
66
-
67
- export const groupConversation = async (
68
- client: AgentClientIface,
69
- userId: string,
70
- signal?: AbortSignal,
71
- ) => {
72
- const group = await client.conversations.create({
73
- kind: 'group',
74
- title: '#releases',
75
- signal,
76
- participants: [{ user: userId }, { agent: 'release-scout', routingMode: 'default' }],
77
- });
78
- const bot = await group.addParticipant(
79
- { agent: 'deploy-bot', routingMode: 'mention' },
80
- { signal },
81
- );
82
- await group.send('Go ahead with the release.', { mentions: [bot.id], signal });
83
- return group;
84
- };
85
-
86
- export const publish = async (client: AgentClientIface, signal?: AbortSignal) => {
87
- const report = await client.definitions.compatibility({
88
- definition: 'release-scout',
89
- harness: '@finalai/final-agent-provider/harnesses/serverless-pi',
90
- signal,
91
- });
92
- const revision = await client.definitions.publish({
93
- definition: 'release-scout',
94
- ref: 'main',
95
- signal,
96
- });
97
- return { report, revision, guides: await client.computerSetupGuides.list({ signal }) };
98
- };
99
-
100
- export const connect = (args: { host: string; apiKey: string }) =>
101
- createClient({
102
- host: args.host,
103
- auth: { apiKey: args.apiKey },
104
- headers: () => ({ 'x-request-source': 'release-scout-example' }),
105
- });
106
-
107
- // Called by an external job after its work finishes; repeat the same event id on retry.
108
- export const postBuildResult = async (args: {
109
- client: AgentClientIface;
110
- conversationId: string;
111
- runId: string;
112
- text: string;
113
- signal?: AbortSignal;
114
- }) =>
115
- args.client.conversations.get(args.conversationId).postEvent(
116
- {
117
- source: { id: 'release-build', name: 'Release build' },
118
- eventId: `${args.runId}:completed`,
119
- text: args.text,
120
- },
121
- { signal: args.signal },
122
- );