@finalai/agents 0.11.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.
- package/HOSTING.md +334 -245
- package/README.md +214 -29
- package/dist/modules/agent-client/agent-input.d.mts +24 -0
- package/dist/modules/agent-client/agent-input.mjs +46 -0
- package/dist/modules/agent-client/agent-input.mjs.map +7 -0
- package/dist/modules/agent-client/channels.d.mts +52 -3
- package/dist/modules/agent-client/channels.mjs +71 -10
- package/dist/modules/agent-client/channels.mjs.map +2 -2
- package/dist/modules/agent-client/client.d.mts +85 -20
- package/dist/modules/agent-client/client.mjs +74 -21
- package/dist/modules/agent-client/client.mjs.map +2 -2
- package/dist/modules/agent-client/config-options.mjs +1 -2
- package/dist/modules/agent-client/config-options.mjs.map +2 -2
- package/dist/modules/agent-client/conversation-resources.d.mts +85 -0
- package/dist/modules/agent-client/conversation-resources.mjs +150 -0
- package/dist/modules/agent-client/conversation-resources.mjs.map +7 -0
- package/dist/modules/agent-client/conversations.d.mts +116 -38
- package/dist/modules/agent-client/conversations.mjs +379 -71
- package/dist/modules/agent-client/conversations.mjs.map +2 -2
- package/dist/modules/agent-client/defaults.d.mts +8 -0
- package/dist/modules/agent-client/defaults.mjs +77 -0
- package/dist/modules/agent-client/defaults.mjs.map +7 -0
- package/dist/modules/agent-client/errors.d.mts +22 -2
- package/dist/modules/agent-client/errors.mjs +19 -0
- package/dist/modules/agent-client/errors.mjs.map +2 -2
- package/dist/modules/agent-client/events.d.mts +62 -0
- package/dist/modules/agent-client/events.mjs +107 -0
- package/dist/modules/agent-client/events.mjs.map +7 -0
- package/dist/modules/agent-client/harnesses.d.mts +66 -0
- package/dist/modules/agent-client/harnesses.mjs +156 -0
- package/dist/modules/agent-client/harnesses.mjs.map +7 -0
- package/dist/modules/agent-client/http.d.mts +2 -1
- package/dist/modules/agent-client/http.mjs +21 -2
- package/dist/modules/agent-client/http.mjs.map +2 -2
- package/dist/modules/agent-client/index.d.mts +21 -6
- package/dist/modules/agent-client/index.mjs +26 -0
- package/dist/modules/agent-client/index.mjs.map +2 -2
- package/dist/modules/agent-client/integrations.d.mts +40 -0
- package/dist/modules/agent-client/integrations.mjs +92 -0
- package/dist/modules/agent-client/integrations.mjs.map +7 -0
- package/dist/modules/agent-client/local-host-protocol.d.mts +156 -0
- package/dist/modules/agent-client/local-host-protocol.mjs +258 -0
- package/dist/modules/agent-client/local-host-protocol.mjs.map +7 -0
- package/dist/modules/agent-client/local-host.d.mts +56 -0
- package/dist/modules/agent-client/local-host.mjs +200 -0
- package/dist/modules/agent-client/local-host.mjs.map +7 -0
- package/dist/modules/agent-client/oauth-clients.d.mts +36 -0
- package/dist/modules/agent-client/oauth-clients.mjs +67 -0
- package/dist/modules/agent-client/oauth-clients.mjs.map +7 -0
- package/dist/modules/agent-client/project-agents.d.mts +54 -0
- package/dist/modules/agent-client/project-agents.mjs +111 -0
- package/dist/modules/agent-client/project-agents.mjs.map +7 -0
- package/dist/modules/agent-client/project.d.mts +43 -0
- package/dist/modules/agent-client/project.mjs +66 -0
- package/dist/modules/agent-client/project.mjs.map +7 -0
- package/dist/modules/agent-client/projects.d.mts +61 -0
- package/dist/modules/agent-client/projects.mjs +145 -0
- package/dist/modules/agent-client/projects.mjs.map +7 -0
- package/dist/modules/agent-client/provide.d.mts +41 -0
- package/dist/modules/agent-client/provide.mjs +90 -0
- package/dist/modules/agent-client/provide.mjs.map +7 -0
- package/dist/modules/agent-client/publishers.d.mts +57 -0
- package/dist/modules/agent-client/publishers.mjs +109 -0
- package/dist/modules/agent-client/publishers.mjs.map +7 -0
- package/dist/modules/agent-client/requirements.d.mts +60 -0
- package/dist/modules/agent-client/requirements.mjs +83 -0
- package/dist/modules/agent-client/requirements.mjs.map +7 -0
- package/dist/modules/agent-client/sandbox-providers.d.mts +34 -0
- package/dist/modules/agent-client/sandbox-providers.mjs +75 -0
- package/dist/modules/agent-client/sandbox-providers.mjs.map +7 -0
- package/dist/modules/agent-client/sandbox-uri.d.mts +1 -1
- package/dist/modules/agent-client/sandbox-uri.mjs +4 -4
- package/dist/modules/agent-client/sandbox-uri.mjs.map +1 -1
- package/dist/modules/agent-client/sandboxes.d.mts +65 -0
- package/dist/modules/agent-client/sandboxes.mjs +130 -0
- package/dist/modules/agent-client/sandboxes.mjs.map +7 -0
- package/dist/modules/agent-client/schedules.d.mts +24 -0
- package/dist/modules/agent-client/schedules.mjs +56 -0
- package/dist/modules/agent-client/schedules.mjs.map +7 -0
- package/dist/modules/agent-client/sessions.d.mts +46 -8
- package/dist/modules/agent-client/sessions.mjs +91 -29
- package/dist/modules/agent-client/sessions.mjs.map +2 -2
- package/dist/modules/agent-client/start.d.mts +101 -0
- package/dist/modules/agent-client/start.mjs +260 -0
- package/dist/modules/agent-client/start.mjs.map +7 -0
- package/dist/modules/agent-client/test-fakes.d.mts +1 -0
- package/dist/modules/agent-client/test-fakes.mjs +3 -1
- package/dist/modules/agent-client/test-fakes.mjs.map +2 -2
- package/dist/modules/cli/agent-module.d.mts +39 -0
- package/dist/modules/cli/agent-module.mjs +89 -0
- package/dist/modules/cli/agent-module.mjs.map +7 -0
- package/dist/modules/cli/cli.d.mts +6 -6
- package/dist/modules/cli/cli.mjs +94 -120
- package/dist/modules/cli/cli.mjs.map +2 -2
- package/dist/modules/cli/conformance.d.mts +2 -6
- package/dist/modules/cli/conformance.mjs +5 -8
- package/dist/modules/cli/conformance.mjs.map +2 -2
- package/dist/modules/cli/main.mjs.map +1 -1
- package/dist/modules/cli/output.d.mts +0 -9
- package/dist/modules/cli/output.mjs +7 -85
- package/dist/modules/cli/output.mjs.map +2 -2
- package/dist/modules/harnesses.mjs.map +2 -2
- package/dist/modules/index.d.mts +0 -2
- package/dist/modules/index.mjs +0 -4
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/integrations.d.mts +24 -0
- package/dist/modules/integrations.mjs +30 -0
- package/dist/modules/integrations.mjs.map +7 -0
- package/dist/modules/public.d.mts +10 -10
- package/dist/modules/public.mjs +29 -78
- package/dist/modules/public.mjs.map +2 -2
- package/dist/modules/sandboxes.d.mts +2 -0
- package/dist/modules/sandboxes.mjs +4 -0
- package/dist/modules/sandboxes.mjs.map +2 -2
- package/dist/modules/verify.d.mts +1 -0
- package/dist/modules/verify.mjs +2 -0
- package/dist/modules/verify.mjs.map +7 -0
- package/dist/modules/webhooks.d.mts +37 -0
- package/dist/modules/webhooks.mjs +100 -0
- package/dist/modules/webhooks.mjs.map +7 -0
- package/examples/release-scout/README.md +18 -10
- package/examples/release-scout/agent.ts +41 -0
- package/examples/release-scout/by-name.ts +43 -0
- package/examples/release-scout/db.ts +6 -0
- package/examples/release-scout/instructions.md +5 -0
- package/examples/release-scout/run-on-a-computer.ts +49 -0
- package/examples/release-scout/run.ts +38 -0
- package/package.json +42 -28
- package/dist/modules/agent-client/build.d.mts +0 -110
- package/dist/modules/agent-client/build.mjs +0 -213
- package/dist/modules/agent-client/build.mjs.map +0 -7
- package/dist/modules/authoring/index.d.mts +0 -1
- package/dist/modules/authoring/index.mjs +0 -2
- package/dist/modules/authoring/index.mjs.map +0 -7
- package/dist/modules/authoring/instructions.d.mts +0 -1
- package/dist/modules/authoring/instructions.mjs +0 -2
- package/dist/modules/authoring/instructions.mjs.map +0 -7
- package/dist/modules/authoring/providers.d.mts +0 -2
- package/dist/modules/authoring/providers.mjs +0 -1
- package/dist/modules/authoring/providers.mjs.map +0 -7
- package/dist/modules/cli/build.d.mts +0 -22
- package/dist/modules/cli/build.mjs +0 -77
- package/dist/modules/cli/build.mjs.map +0 -7
- package/dist/modules/cli/channel-install.d.mts +0 -12
- package/dist/modules/cli/channel-install.mjs +0 -25
- package/dist/modules/cli/channel-install.mjs.map +0 -7
- package/dist/modules/cli/channel-socket.d.mts +0 -9
- package/dist/modules/cli/channel-socket.mjs +0 -114
- package/dist/modules/cli/channel-socket.mjs.map +0 -7
- package/dist/modules/cli/dev.d.mts +0 -26
- package/dist/modules/cli/dev.mjs +0 -311
- package/dist/modules/cli/dev.mjs.map +0 -7
- package/dist/modules/cli/files.d.mts +0 -18
- package/dist/modules/cli/files.mjs +0 -66
- package/dist/modules/cli/files.mjs.map +0 -7
- package/dist/modules/cli/harness-descriptions.d.mts +0 -20
- package/dist/modules/cli/harness-descriptions.mjs +0 -70
- package/dist/modules/cli/harness-descriptions.mjs.map +0 -7
- package/dist/modules/cli/publish.d.mts +0 -15
- package/dist/modules/cli/publish.mjs +0 -92
- package/dist/modules/cli/publish.mjs.map +0 -7
- package/dist/modules/compile.d.mts +0 -3
- package/dist/modules/compile.mjs +0 -58
- package/dist/modules/compile.mjs.map +0 -7
- package/dist/modules/index.browser.d.mts +0 -4
- package/dist/modules/index.browser.mjs +0 -8
- package/dist/modules/index.browser.mjs.map +0 -7
- package/examples/custom-harness/README.md +0 -16
- package/examples/custom-harness/agent.ts +0 -154
- package/examples/custom-sandbox/README.md +0 -12
- package/examples/custom-sandbox/agent.ts +0 -14
- package/examples/custom-sandbox/sandbox.ts +0 -24
- package/examples/release-scout/agent/agent.ts +0 -22
- package/examples/release-scout/agent/channels/github-signature.ts +0 -27
- package/examples/release-scout/agent/channels/github.ts +0 -32
- package/examples/release-scout/agent/connections/linear.ts +0 -9
- package/examples/release-scout/agent/hooks/audit.ts +0 -24
- package/examples/release-scout/agent/instructions/org-context.ts +0 -26
- package/examples/release-scout/agent/instructions.md +0 -2
- package/examples/release-scout/agent/sandbox.ts +0 -20
- package/examples/release-scout/agent/schedules/daily-digest.md +0 -7
- package/examples/release-scout/agent/skills/triage/SKILL.md +0 -8
- package/examples/release-scout/agent/skills/triage/checklist.md +0 -3
- package/examples/release-scout/agent/tools/lookup_release_notes.ts +0 -24
- package/examples/release-scout/client.ts +0 -122
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
commitDefinitionRequestSchema,
|
|
3
|
-
commitResultSchema,
|
|
4
|
-
compatibilityReportSchema,
|
|
5
|
-
compileDefinitionRequestSchema,
|
|
6
|
-
compileResultSchema,
|
|
7
|
-
computerSetupGuideDetailSchema,
|
|
8
|
-
computerSetupGuideListSchema,
|
|
9
|
-
createDefinitionRequestSchema,
|
|
10
|
-
credentialPolicyPreviewSchema,
|
|
11
|
-
definitionChannelsResponseSchema,
|
|
12
|
-
definitionCloneUrlSchema,
|
|
13
|
-
definitionFilesSchema,
|
|
14
|
-
definitionListSchema,
|
|
15
|
-
definitionSchema,
|
|
16
|
-
previewCredentialPolicyRequestSchema,
|
|
17
|
-
providerListSchema,
|
|
18
|
-
publishComputerSetupGuideRequestSchema,
|
|
19
|
-
publishComputerSetupGuideResultSchema,
|
|
20
|
-
publishDefinitionRequestSchema,
|
|
21
|
-
publishResultSchema,
|
|
22
|
-
revisionDiffSchema,
|
|
23
|
-
revisionListSchema,
|
|
24
|
-
revisionSchema,
|
|
25
|
-
scheduleListSchema,
|
|
26
|
-
scheduleRunResultSchema,
|
|
27
|
-
scheduleSchema,
|
|
28
|
-
updateScheduleRequestSchema
|
|
29
|
-
} from "@finalai/agent-protocol/agent-platform";
|
|
30
|
-
import { encodePath } from "./context.mjs";
|
|
31
|
-
import { clientError, ClientErrorCode } from "./errors.mjs";
|
|
32
|
-
import { HttpMethod } from "./http.mjs";
|
|
33
|
-
const definitionPath = (definition, suffix = "") => `/v1/definitions/${encodePath(definition)}${suffix}`;
|
|
34
|
-
const createDefinitionsApi = ({ http }) => ({
|
|
35
|
-
testRevision: ({ definition, signal, ...value }) => http.request({
|
|
36
|
-
method: HttpMethod.Post,
|
|
37
|
-
path: definitionPath(definition, "/test-revision"),
|
|
38
|
-
body: { schema: compileDefinitionRequestSchema, value },
|
|
39
|
-
response: revisionSchema,
|
|
40
|
-
signal
|
|
41
|
-
}),
|
|
42
|
-
previewCredentialPolicy: ({ definition, signal, ...value }) => http.request({
|
|
43
|
-
method: HttpMethod.Post,
|
|
44
|
-
path: definitionPath(definition, "/credential-policy/preview"),
|
|
45
|
-
body: { schema: previewCredentialPolicyRequestSchema, value },
|
|
46
|
-
response: credentialPolicyPreviewSchema,
|
|
47
|
-
signal
|
|
48
|
-
}),
|
|
49
|
-
list: (options) => http.request({
|
|
50
|
-
method: HttpMethod.Get,
|
|
51
|
-
path: "/v1/definitions",
|
|
52
|
-
query: { cursor: options?.cursor, limit: options?.limit, projectId: options?.projectId },
|
|
53
|
-
response: definitionListSchema,
|
|
54
|
-
signal: options?.signal
|
|
55
|
-
}),
|
|
56
|
-
create: ({ signal, ...value }) => http.request({
|
|
57
|
-
method: HttpMethod.Post,
|
|
58
|
-
path: "/v1/definitions",
|
|
59
|
-
body: { schema: createDefinitionRequestSchema, value },
|
|
60
|
-
response: definitionSchema,
|
|
61
|
-
signal
|
|
62
|
-
}),
|
|
63
|
-
get: ({ definition, signal }) => http.request({
|
|
64
|
-
method: HttpMethod.Get,
|
|
65
|
-
path: definitionPath(definition),
|
|
66
|
-
response: definitionSchema,
|
|
67
|
-
signal
|
|
68
|
-
}),
|
|
69
|
-
compile: ({ definition, signal, ...value }) => http.request({
|
|
70
|
-
method: HttpMethod.Post,
|
|
71
|
-
path: definitionPath(definition, "/compile"),
|
|
72
|
-
body: { schema: compileDefinitionRequestSchema, value },
|
|
73
|
-
response: compileResultSchema,
|
|
74
|
-
signal
|
|
75
|
-
}),
|
|
76
|
-
commit: ({ definition, signal, ...value }) => http.request({
|
|
77
|
-
method: HttpMethod.Post,
|
|
78
|
-
path: definitionPath(definition, "/commit"),
|
|
79
|
-
body: { schema: commitDefinitionRequestSchema, value },
|
|
80
|
-
response: commitResultSchema,
|
|
81
|
-
signal
|
|
82
|
-
}),
|
|
83
|
-
publish: ({ definition, signal, ...value }) => http.request({
|
|
84
|
-
method: HttpMethod.Post,
|
|
85
|
-
path: definitionPath(definition, "/publish"),
|
|
86
|
-
body: { schema: publishDefinitionRequestSchema, value },
|
|
87
|
-
response: publishResultSchema,
|
|
88
|
-
signal
|
|
89
|
-
}),
|
|
90
|
-
files: ({ definition, ref, signal }) => http.request({
|
|
91
|
-
method: HttpMethod.Get,
|
|
92
|
-
path: definitionPath(definition, "/files"),
|
|
93
|
-
query: { ref },
|
|
94
|
-
response: definitionFilesSchema,
|
|
95
|
-
signal
|
|
96
|
-
}),
|
|
97
|
-
revisions: ({ definition, cursor, signal }) => http.request({
|
|
98
|
-
method: HttpMethod.Get,
|
|
99
|
-
path: definitionPath(definition, "/revisions"),
|
|
100
|
-
query: { cursor },
|
|
101
|
-
response: revisionListSchema,
|
|
102
|
-
signal
|
|
103
|
-
}),
|
|
104
|
-
revisionDiff: ({ definition, from, to, signal }) => http.request({
|
|
105
|
-
method: HttpMethod.Get,
|
|
106
|
-
path: definitionPath(definition, "/revisions/diff"),
|
|
107
|
-
query: { from, to },
|
|
108
|
-
response: revisionDiffSchema,
|
|
109
|
-
signal
|
|
110
|
-
}),
|
|
111
|
-
compatibility: ({ definition, harness, ref, signal }) => http.request({
|
|
112
|
-
method: HttpMethod.Get,
|
|
113
|
-
path: definitionPath(definition, "/compatibility"),
|
|
114
|
-
query: { harness, ref },
|
|
115
|
-
response: compatibilityReportSchema,
|
|
116
|
-
signal
|
|
117
|
-
}),
|
|
118
|
-
channels: async ({ definition, signal }) => (await http.request({
|
|
119
|
-
method: HttpMethod.Get,
|
|
120
|
-
path: definitionPath(definition, "/channels"),
|
|
121
|
-
response: definitionChannelsResponseSchema,
|
|
122
|
-
signal
|
|
123
|
-
})).channels,
|
|
124
|
-
archive: ({ definition, signal }) => http.request({
|
|
125
|
-
method: HttpMethod.Post,
|
|
126
|
-
path: definitionPath(definition, "/archive"),
|
|
127
|
-
response: definitionSchema,
|
|
128
|
-
signal
|
|
129
|
-
}),
|
|
130
|
-
cloneUrl: ({ definition, signal }) => http.request({
|
|
131
|
-
method: HttpMethod.Post,
|
|
132
|
-
path: definitionPath(definition, "/clone-url"),
|
|
133
|
-
response: definitionCloneUrlSchema,
|
|
134
|
-
signal
|
|
135
|
-
})
|
|
136
|
-
});
|
|
137
|
-
const createProvidersApi = ({ http }) => ({
|
|
138
|
-
list: async (options) => (await http.request({
|
|
139
|
-
method: HttpMethod.Get,
|
|
140
|
-
path: "/v1/providers",
|
|
141
|
-
response: providerListSchema,
|
|
142
|
-
signal: options?.signal
|
|
143
|
-
})).providers
|
|
144
|
-
});
|
|
145
|
-
const createComputerSetupGuidesApi = ({
|
|
146
|
-
http
|
|
147
|
-
}) => ({
|
|
148
|
-
list: async (options) => (await http.request({
|
|
149
|
-
method: HttpMethod.Get,
|
|
150
|
-
path: "/v1/computer-setup-guides",
|
|
151
|
-
response: computerSetupGuideListSchema,
|
|
152
|
-
signal: options?.signal
|
|
153
|
-
})).guides,
|
|
154
|
-
get: (ref, options) => http.request({
|
|
155
|
-
method: HttpMethod.Get,
|
|
156
|
-
path: `/v1/computer-setup-guides/${encodePath(ref)}`,
|
|
157
|
-
response: computerSetupGuideDetailSchema,
|
|
158
|
-
signal: options?.signal
|
|
159
|
-
}),
|
|
160
|
-
publish: ({ signal, ...value }) => http.request({
|
|
161
|
-
method: HttpMethod.Post,
|
|
162
|
-
path: "/v1/computer-setup-guides",
|
|
163
|
-
body: { schema: publishComputerSetupGuideRequestSchema, value },
|
|
164
|
-
response: publishComputerSetupGuideResultSchema,
|
|
165
|
-
signal
|
|
166
|
-
})
|
|
167
|
-
});
|
|
168
|
-
const createSchedulesApi = ({ http }) => {
|
|
169
|
-
const list = async (options) => (await http.request({
|
|
170
|
-
method: HttpMethod.Get,
|
|
171
|
-
path: "/v1/schedules",
|
|
172
|
-
query: { agent: options?.agent },
|
|
173
|
-
response: scheduleListSchema,
|
|
174
|
-
signal: options?.signal
|
|
175
|
-
})).schedules;
|
|
176
|
-
const scheduleIdOf = async (args) => {
|
|
177
|
-
if ("scheduleId" in args) return args.scheduleId;
|
|
178
|
-
const found = (await list({ agent: args.agent, signal: args.signal })).find(
|
|
179
|
-
(schedule) => schedule.key === args.key
|
|
180
|
-
);
|
|
181
|
-
if (found == null) {
|
|
182
|
-
throw clientError({
|
|
183
|
-
message: `No schedule ${args.key} on agent ${args.agent}`,
|
|
184
|
-
status: 0,
|
|
185
|
-
code: ClientErrorCode.NotFound
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
return found.id;
|
|
189
|
-
};
|
|
190
|
-
return {
|
|
191
|
-
list,
|
|
192
|
-
runNow: async (args) => http.request({
|
|
193
|
-
method: HttpMethod.Post,
|
|
194
|
-
path: `/v1/schedules/${encodePath(await scheduleIdOf(args))}/run-now`,
|
|
195
|
-
response: scheduleRunResultSchema,
|
|
196
|
-
signal: args.signal
|
|
197
|
-
}),
|
|
198
|
-
update: ({ scheduleId, signal, ...value }) => http.request({
|
|
199
|
-
method: HttpMethod.Patch,
|
|
200
|
-
path: `/v1/schedules/${encodePath(scheduleId)}`,
|
|
201
|
-
body: { schema: updateScheduleRequestSchema, value },
|
|
202
|
-
response: scheduleSchema,
|
|
203
|
-
signal
|
|
204
|
-
})
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
export {
|
|
208
|
-
createComputerSetupGuidesApi,
|
|
209
|
-
createDefinitionsApi,
|
|
210
|
-
createProvidersApi,
|
|
211
|
-
createSchedulesApi
|
|
212
|
-
};
|
|
213
|
-
//# sourceMappingURL=build.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/agent-client/build.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n commitDefinitionRequestSchema,\n commitResultSchema,\n compatibilityReportSchema,\n compileDefinitionRequestSchema,\n compileResultSchema,\n computerSetupGuideDetailSchema,\n computerSetupGuideListSchema,\n createDefinitionRequestSchema,\n credentialPolicyPreviewSchema,\n definitionChannelsResponseSchema,\n definitionCloneUrlSchema,\n definitionFilesSchema,\n definitionListSchema,\n definitionSchema,\n previewCredentialPolicyRequestSchema,\n providerListSchema,\n publishComputerSetupGuideRequestSchema,\n publishComputerSetupGuideResultSchema,\n publishDefinitionRequestSchema,\n publishResultSchema,\n revisionDiffSchema,\n revisionListSchema,\n revisionSchema,\n scheduleListSchema,\n scheduleRunResultSchema,\n scheduleSchema,\n updateScheduleRequestSchema,\n type CommitDefinitionRequestIface,\n type CommitResultIface,\n type CompatibilityReportIface,\n type CompileResultIface,\n type ComputerSetupGuideDetailIface,\n type ComputerSetupGuideIface,\n type ComputerSetupGuideVersionIface,\n type CreateDefinitionRequestIface,\n type CredentialPolicyPreviewIface,\n type DefinitionChannelIface,\n type DefinitionCloneUrlIface,\n type DefinitionFilesIface,\n type DefinitionIface,\n type PreviewCredentialPolicyRequestIface,\n type ProviderEntryIface,\n type PublishComputerSetupGuideRequestIface,\n type PublishResultIface,\n type RevisionDiffIface,\n type RevisionIface,\n type ScheduleIface,\n type ScheduleRunResultIface,\n type UpdateScheduleRequestIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\n// Definitions, providers, setup guides, schedules, credentials and budgets:\n// what Build, settings and CI use.\n\nexport interface DefinitionRefIface extends SignalOptionsIface {\n /** Definition id or slug. */\n definition: string;\n}\n\nexport interface DefinitionsApiIface {\n /** Compiles a draft into an immutable test snapshot without publishing or activating schedules/channels. */\n testRevision: (args: DefinitionRefIface & { ref: string }) => Promise<RevisionIface>;\n previewCredentialPolicy: (\n args: DefinitionRefIface & PreviewCredentialPolicyRequestIface,\n ) => Promise<CredentialPolicyPreviewIface>;\n /**\n * With `projectId`, its definitions and those inherited from its ancestors. Without it,\n * everything the caller can access (an API key: its parent project and every project it is\n * granted; a person: every project they can read).\n */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number; projectId?: string },\n ) => Promise<{ definitions: DefinitionIface[]; nextCursor: string | null }>;\n /**\n * Creates the definition in `projectId` (editors of that project); omitted, the API key's parent\n * project (a signed-in person's: My Work).\n */\n create: (args: CreateDefinitionRequestIface & SignalOptionsIface) => Promise<DefinitionIface>;\n get: (args: DefinitionRefIface) => Promise<DefinitionIface>;\n /** Compiles the directory at `ref` server-side without publishing. */\n compile: (\n args: DefinitionRefIface & { ref: string; harness?: string },\n ) => Promise<CompileResultIface>;\n commit: (args: DefinitionRefIface & CommitDefinitionRequestIface) => Promise<CommitResultIface>;\n /** Publishes an immutable revision; activate:false leaves the live agent unchanged. */\n publish: (\n args: DefinitionRefIface & { ref: string; note?: string; activate?: boolean },\n ) => Promise<PublishResultIface>;\n /** The agent directory's files at `ref` (default branch when omitted). */\n files: (args: DefinitionRefIface & { ref?: string }) => Promise<DefinitionFilesIface>;\n revisions: (\n args: DefinitionRefIface & { cursor?: string },\n ) => Promise<{ revisions: RevisionIface[]; nextCursor: string | null }>;\n /**\n * What changed in the compiled manifest between two revisions (revision ids\n * or numbers); `to` defaults to the current revision.\n */\n revisionDiff: (\n args: DefinitionRefIface & { from: string | number; to?: string | number },\n ) => Promise<RevisionDiffIface>;\n compatibility: (\n args: DefinitionRefIface & { harness: string; ref?: string },\n ) => Promise<CompatibilityReportIface>;\n /** The agent's live channel bindings and their public route URLs. */\n channels: (args: DefinitionRefIface) => Promise<DefinitionChannelIface[]>;\n /**\n * Archives the definition: it leaves listings, its schedules and channel\n * bindings stop, and new sessions are refused. Its repository is kept.\n */\n archive: (args: DefinitionRefIface) => Promise<DefinitionIface>;\n /**\n * A short-lived, read-only git remote for a Final-hosted repository, for\n * `git clone` (editors of the definition's project).\n */\n cloneUrl: (args: DefinitionRefIface) => Promise<DefinitionCloneUrlIface>;\n}\n\nexport interface ProvidersApiIface {\n list: (options?: SignalOptionsIface) => Promise<ProviderEntryIface[]>;\n}\n\nexport interface ComputerSetupGuidesApiIface {\n list: (options?: SignalOptionsIface) => Promise<ComputerSetupGuideIface[]>;\n /** Guide by slug or id, with its versions. */\n get: (ref: string, options?: SignalOptionsIface) => Promise<ComputerSetupGuideDetailIface>;\n /** Publishes a new version (creating the guide on first publish). */\n publish: (\n args: PublishComputerSetupGuideRequestIface & SignalOptionsIface,\n ) => Promise<{ guide: ComputerSetupGuideIface; version: ComputerSetupGuideVersionIface }>;\n}\n\nexport type ScheduleRef = { scheduleId: string } | { agent: string; key: string };\n\nexport interface SchedulesApiIface {\n list: (options?: SignalOptionsIface & { agent?: string }) => Promise<ScheduleIface[]>;\n runNow: (args: ScheduleRef & SignalOptionsIface) => Promise<ScheduleRunResultIface>;\n update: (\n args: { scheduleId: string } & UpdateScheduleRequestIface & SignalOptionsIface,\n ) => Promise<ScheduleIface>;\n}\n\nconst definitionPath = (definition: string, suffix = ''): string =>\n `/v1/definitions/${encodePath(definition)}${suffix}`;\n\nexport const createDefinitionsApi = ({ http }: ClientContextIface): DefinitionsApiIface => ({\n testRevision: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/test-revision'),\n body: { schema: compileDefinitionRequestSchema, value },\n response: revisionSchema,\n signal,\n }),\n previewCredentialPolicy: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/credential-policy/preview'),\n body: { schema: previewCredentialPolicyRequestSchema, value },\n response: credentialPolicyPreviewSchema,\n signal,\n }),\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/definitions',\n query: { cursor: options?.cursor, limit: options?.limit, projectId: options?.projectId },\n response: definitionListSchema,\n signal: options?.signal,\n }),\n create: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/definitions',\n body: { schema: createDefinitionRequestSchema, value },\n response: definitionSchema,\n signal,\n }),\n get: ({ definition, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition),\n response: definitionSchema,\n signal,\n }),\n compile: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/compile'),\n body: { schema: compileDefinitionRequestSchema, value },\n response: compileResultSchema,\n signal,\n }),\n commit: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/commit'),\n body: { schema: commitDefinitionRequestSchema, value },\n response: commitResultSchema,\n signal,\n }),\n publish: ({ definition, signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/publish'),\n body: { schema: publishDefinitionRequestSchema, value },\n response: publishResultSchema,\n signal,\n }),\n files: ({ definition, ref, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/files'),\n query: { ref },\n response: definitionFilesSchema,\n signal,\n }),\n revisions: ({ definition, cursor, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/revisions'),\n query: { cursor },\n response: revisionListSchema,\n signal,\n }),\n revisionDiff: ({ definition, from, to, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/revisions/diff'),\n query: { from, to },\n response: revisionDiffSchema,\n signal,\n }),\n compatibility: ({ definition, harness, ref, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/compatibility'),\n query: { harness, ref },\n response: compatibilityReportSchema,\n signal,\n }),\n channels: async ({ definition, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: definitionPath(definition, '/channels'),\n response: definitionChannelsResponseSchema,\n signal,\n })\n ).channels,\n archive: ({ definition, signal }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/archive'),\n response: definitionSchema,\n signal,\n }),\n cloneUrl: ({ definition, signal }) =>\n http.request({\n method: HttpMethod.Post,\n path: definitionPath(definition, '/clone-url'),\n response: definitionCloneUrlSchema,\n signal,\n }),\n});\n\nexport const createProvidersApi = ({ http }: ClientContextIface): ProvidersApiIface => ({\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/providers',\n response: providerListSchema,\n signal: options?.signal,\n })\n ).providers,\n});\n\nexport const createComputerSetupGuidesApi = ({\n http,\n}: ClientContextIface): ComputerSetupGuidesApiIface => ({\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/computer-setup-guides',\n response: computerSetupGuideListSchema,\n signal: options?.signal,\n })\n ).guides,\n get: (ref, options) =>\n http.request({\n method: HttpMethod.Get,\n path: `/v1/computer-setup-guides/${encodePath(ref)}`,\n response: computerSetupGuideDetailSchema,\n signal: options?.signal,\n }),\n publish: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/computer-setup-guides',\n body: { schema: publishComputerSetupGuideRequestSchema, value },\n response: publishComputerSetupGuideResultSchema,\n signal,\n }),\n});\n\nexport const createSchedulesApi = ({ http }: ClientContextIface): SchedulesApiIface => {\n const list: SchedulesApiIface['list'] = async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: '/v1/schedules',\n query: { agent: options?.agent },\n response: scheduleListSchema,\n signal: options?.signal,\n })\n ).schedules;\n\n const scheduleIdOf = async (args: ScheduleRef & SignalOptionsIface): Promise<string> => {\n if ('scheduleId' in args) return args.scheduleId;\n const found = (await list({ agent: args.agent, signal: args.signal })).find(\n (schedule) => schedule.key === args.key,\n );\n if (found == null) {\n throw clientError({\n message: `No schedule ${args.key} on agent ${args.agent}`,\n status: 0,\n code: ClientErrorCode.NotFound,\n });\n }\n return found.id;\n };\n\n return {\n list,\n runNow: async (args) =>\n http.request({\n method: HttpMethod.Post,\n path: `/v1/schedules/${encodePath(await scheduleIdOf(args))}/run-now`,\n response: scheduleRunResultSchema,\n signal: args.signal,\n }),\n update: ({ scheduleId, signal, ...value }) =>\n http.request({\n method: HttpMethod.Patch,\n path: `/v1/schedules/${encodePath(scheduleId)}`,\n body: { schema: updateScheduleRequestSchema, value },\n response: scheduleSchema,\n signal,\n }),\n };\n};\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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,WAAW;AAAA,MACnB,MAAM,iBAAiB,WAAW,MAAM,aAAa,IAAI,CAAC,CAAC;AAAA,MAC3D,UAAU;AAAA,MACV,QAAQ,KAAK;AAAA,IACf,CAAC;AAAA,IACH,QAAQ,CAAC,EAAE,YAAY,QAAQ,GAAG,MAAM,MACtC,KAAK,QAAQ;AAAA,MACX,QAAQ,WAAW;AAAA,MACnB,MAAM,iBAAiB,WAAW,UAAU,CAAC;AAAA,MAC7C,MAAM,EAAE,QAAQ,6BAA6B,MAAM;AAAA,MACnD,UAAU;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACL;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@finalai/agent-definition/authoring';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@finalai/agent-definition/instructions';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export type { HarnessBindingOutputIface, LocalStdioConfigInputIface, RemoteAcpConfigInputIface, RemoteClaudeCodeConfigInputIface, RemoteClientTlsInputIface, RemoteCodexConfigInputIface, RemotePiConfigInputIface, SecretRefIface, ServerlessFinalConfigInputIface, ServerlessNanocodeClaudeConfigInputIface, ServerlessNanocodeCodexConfigInputIface, ServerlessPiConfigInputIface, } from '@finalai/final-agent-provider/harnesses';
|
|
2
|
-
export type { ComputerInlineGuideInputIface, ComputerInputIface, ComputerParametersInputIface, ComputerRepositoryInputIface, ComputerSetupGuideInputIface, DeviceInputIface, InstalledSandboxEnvironmentIface, InstalledSandboxOpenRequestIface, SandboxOpenInputIface, } from '@finalai/final-agent-provider/sandboxes';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=providers.mjs.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { type CompileResultIface } from '@finalai/agent-definition/compiler';
|
|
2
|
-
import type { AgentClientIface } from "../agent-client/client.mjs";
|
|
3
|
-
import { type OutputIface } from "./output.mjs";
|
|
4
|
-
export declare const COMPILE_OUTPUT_DIR: string;
|
|
5
|
-
export interface CompileDirectoryArgsIface {
|
|
6
|
-
source: {
|
|
7
|
-
dir: string;
|
|
8
|
-
} | {
|
|
9
|
-
files: Record<string, string>;
|
|
10
|
-
};
|
|
11
|
-
client: AgentClientIface | null;
|
|
12
|
-
output: OutputIface;
|
|
13
|
-
}
|
|
14
|
-
export declare const compileAndPrint: (args: CompileDirectoryArgsIface) => Promise<{
|
|
15
|
-
result: CompileResultIface;
|
|
16
|
-
ok: boolean;
|
|
17
|
-
}>;
|
|
18
|
-
export declare const runBuild: (args: {
|
|
19
|
-
dir: string;
|
|
20
|
-
client: AgentClientIface | null;
|
|
21
|
-
output: OutputIface;
|
|
22
|
-
}) => Promise<number>;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DiagnosticSeverity,
|
|
3
|
-
hasErrors
|
|
4
|
-
} from "@finalai/agent-definition/compiler";
|
|
5
|
-
import { ProviderRefKind } from "@finalai/agent-provider";
|
|
6
|
-
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { compile } from "../compile.mjs";
|
|
9
|
-
import { createHarnessDescriptions } from "./harness-descriptions.mjs";
|
|
10
|
-
import {
|
|
11
|
-
diagnosticLine,
|
|
12
|
-
hookLines,
|
|
13
|
-
manifestSummaryLines,
|
|
14
|
-
reportLines
|
|
15
|
-
} from "./output.mjs";
|
|
16
|
-
const COMPILE_OUTPUT_DIR = join(".final", "compile");
|
|
17
|
-
const compileAndPrint = async (args) => {
|
|
18
|
-
const options = {
|
|
19
|
-
...args.source,
|
|
20
|
-
// Installed harnesses are described by the platform (needs a client); a
|
|
21
|
-
// bundle harness by its own describe, run locally.
|
|
22
|
-
harnessDescriptions: createHarnessDescriptions({ client: args.client, output: args.output })
|
|
23
|
-
};
|
|
24
|
-
const result = await compile(options);
|
|
25
|
-
const { stdout, stderr } = args.output;
|
|
26
|
-
if (result.manifest != null) {
|
|
27
|
-
for (const line of manifestSummaryLines(result.manifest)) stdout(line);
|
|
28
|
-
for (const line of hookLines(result.manifest)) stdout(line);
|
|
29
|
-
}
|
|
30
|
-
if (result.report != null) for (const line of reportLines(result.report)) stdout(line);
|
|
31
|
-
else if (args.client == null && result.manifest != null && result.manifest.harness.harness.kind !== ProviderRefKind.Bundle)
|
|
32
|
-
stdout("compatibility: not checked (set FINAL_API_KEY to check the installed harness)");
|
|
33
|
-
for (const item of result.diagnostics) {
|
|
34
|
-
(item.severity === DiagnosticSeverity.Error ? stderr : stdout)(diagnosticLine(item));
|
|
35
|
-
}
|
|
36
|
-
const ok = !hasErrors(result.diagnostics) && result.manifest != null && result.report?.ok !== false;
|
|
37
|
-
return { result, ok };
|
|
38
|
-
};
|
|
39
|
-
const prettyJson = (value) => `${JSON.stringify(value, null, 2)}
|
|
40
|
-
`;
|
|
41
|
-
const writeOutputs = async (dir, result) => {
|
|
42
|
-
const out = join(dir, COMPILE_OUTPUT_DIR);
|
|
43
|
-
await rm(out, { recursive: true, force: true });
|
|
44
|
-
await mkdir(out, { recursive: true });
|
|
45
|
-
await writeFile(join(out, "diagnostics.json"), prettyJson(result.diagnostics));
|
|
46
|
-
if (result.manifest != null)
|
|
47
|
-
await writeFile(join(out, "manifest.json"), prettyJson(result.manifest));
|
|
48
|
-
if (result.report != null) await writeFile(join(out, "report.json"), prettyJson(result.report));
|
|
49
|
-
if (result.bundle != null) {
|
|
50
|
-
await writeFile(join(out, "bundle.mjs"), result.bundle.code);
|
|
51
|
-
await writeFile(
|
|
52
|
-
join(out, "modules.json"),
|
|
53
|
-
prettyJson({
|
|
54
|
-
hash: result.bundle.hash,
|
|
55
|
-
modules: result.bundle.modules,
|
|
56
|
-
sandboxOpeners: result.bundle.sandboxOpeners
|
|
57
|
-
})
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
return out;
|
|
61
|
-
};
|
|
62
|
-
const runBuild = async (args) => {
|
|
63
|
-
const { result, ok } = await compileAndPrint({
|
|
64
|
-
source: { dir: args.dir },
|
|
65
|
-
client: args.client,
|
|
66
|
-
output: args.output
|
|
67
|
-
});
|
|
68
|
-
const out = await writeOutputs(args.dir, result);
|
|
69
|
-
args.output.stdout(`wrote ${out}`);
|
|
70
|
-
return ok ? 0 : 1;
|
|
71
|
-
};
|
|
72
|
-
export {
|
|
73
|
-
COMPILE_OUTPUT_DIR,
|
|
74
|
-
compileAndPrint,
|
|
75
|
-
runBuild
|
|
76
|
-
};
|
|
77
|
-
//# sourceMappingURL=build.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/cli/build.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DiagnosticSeverity,\n hasErrors,\n type CompileOptionsIface,\n type CompileResultIface,\n} from '@finalai/agent-definition/compiler';\nimport { ProviderRefKind } from '@finalai/agent-provider';\nimport { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { AgentClientIface } from \"../agent-client/client.mjs\";\nimport { compile } from \"../compile.mjs\";\nimport { createHarnessDescriptions } from \"./harness-descriptions.mjs\";\nimport {\n diagnosticLine,\n hookLines,\n manifestSummaryLines,\n reportLines,\n type OutputIface,\n} from \"./output.mjs\";\n\n// `final agents build`: compiles the agent directory, prints the\n// manifest summary, the compatibility report for the chosen harness, the\n// diagnostics and the hooks, and writes the outputs under `.final/compile/`.\n\nexport const COMPILE_OUTPUT_DIR = join('.final', 'compile');\n\nexport interface CompileDirectoryArgsIface {\n // The directory on disk, or the files that will be committed.\n source: { dir: string } | { files: Record<string, string> };\n // Null compiles without a compatibility report (no API key).\n client: AgentClientIface | null;\n output: OutputIface;\n}\n\nexport const compileAndPrint = async (\n args: CompileDirectoryArgsIface,\n): Promise<{ result: CompileResultIface; ok: boolean }> => {\n const options: CompileOptionsIface = {\n ...args.source,\n // Installed harnesses are described by the platform (needs a client); a\n // bundle harness by its own describe, run locally.\n harnessDescriptions: createHarnessDescriptions({ client: args.client, output: args.output }),\n };\n const result = await compile(options);\n const { stdout, stderr } = args.output;\n if (result.manifest != null) {\n for (const line of manifestSummaryLines(result.manifest)) stdout(line);\n for (const line of hookLines(result.manifest)) stdout(line);\n }\n if (result.report != null) for (const line of reportLines(result.report)) stdout(line);\n else if (\n args.client == null &&\n result.manifest != null &&\n result.manifest.harness.harness.kind !== ProviderRefKind.Bundle\n )\n stdout('compatibility: not checked (set FINAL_API_KEY to check the installed harness)');\n for (const item of result.diagnostics) {\n (item.severity === DiagnosticSeverity.Error ? stderr : stdout)(diagnosticLine(item));\n }\n const ok =\n !hasErrors(result.diagnostics) && result.manifest != null && result.report?.ok !== false;\n return { result, ok };\n};\n\nconst prettyJson = (value: CompileOutputJson): string => `${JSON.stringify(value, null, 2)}\\n`;\n\ntype CompileOutputJson =\n | CompileResultIface['diagnostics']\n | NonNullable<CompileResultIface['manifest']>\n | NonNullable<CompileResultIface['report']>\n | { hash: string; modules: Record<string, string>; sandboxOpeners: Record<string, string> };\n\nconst writeOutputs = async (dir: string, result: CompileResultIface): Promise<string> => {\n const out = join(dir, COMPILE_OUTPUT_DIR);\n await rm(out, { recursive: true, force: true });\n await mkdir(out, { recursive: true });\n await writeFile(join(out, 'diagnostics.json'), prettyJson(result.diagnostics));\n if (result.manifest != null)\n await writeFile(join(out, 'manifest.json'), prettyJson(result.manifest));\n if (result.report != null) await writeFile(join(out, 'report.json'), prettyJson(result.report));\n if (result.bundle != null) {\n await writeFile(join(out, 'bundle.mjs'), result.bundle.code);\n await writeFile(\n join(out, 'modules.json'),\n prettyJson({\n hash: result.bundle.hash,\n modules: result.bundle.modules,\n sandboxOpeners: result.bundle.sandboxOpeners,\n }),\n );\n }\n return out;\n};\n\nexport const runBuild = async (args: {\n dir: string;\n client: AgentClientIface | null;\n output: OutputIface;\n}): Promise<number> => {\n const { result, ok } = await compileAndPrint({\n source: { dir: args.dir },\n client: args.client,\n output: args.output,\n });\n const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3
|
-
export interface ChannelInstallArgsIface {
|
|
4
|
-
channelKey: string;
|
|
5
|
-
revisionId: string;
|
|
6
|
-
projectId: string;
|
|
7
|
-
replace?: boolean;
|
|
8
|
-
connectorInstallId: string;
|
|
9
|
-
client: AgentClientIface;
|
|
10
|
-
output: OutputIface;
|
|
11
|
-
}
|
|
12
|
-
export declare const runChannelInstall: (args: ChannelInstallArgsIface) => Promise<number>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { errorLines } from "./output.mjs";
|
|
2
|
-
const runChannelInstall = async (args) => {
|
|
3
|
-
try {
|
|
4
|
-
const result = await args.client.channelBindings.create({
|
|
5
|
-
projectId: args.projectId,
|
|
6
|
-
connectorInstallId: args.connectorInstallId,
|
|
7
|
-
revisionId: args.revisionId,
|
|
8
|
-
channelKey: args.channelKey,
|
|
9
|
-
...args.replace == null ? {} : { replace: args.replace }
|
|
10
|
-
});
|
|
11
|
-
args.output.stdout(`installed ${args.channelKey}: ${result.bindingId}`);
|
|
12
|
-
for (const route of result.routes) {
|
|
13
|
-
const url = route.url ?? route.aliasUrl;
|
|
14
|
-
if (url != null) args.output.stdout(` ${route.method} ${url}`);
|
|
15
|
-
}
|
|
16
|
-
return 0;
|
|
17
|
-
} catch (error) {
|
|
18
|
-
for (const line of errorLines(error)) args.output.stderr(line);
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
runChannelInstall
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=channel-install.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/cli/channel-install.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AgentClientIface } from \"../agent-client/client.mjs\";\nimport { errorLines, type OutputIface } from \"./output.mjs\";\nexport interface ChannelInstallArgsIface {\n channelKey: string;\n revisionId: string;\n projectId: string;\n replace?: boolean;\n connectorInstallId: string;\n client: AgentClientIface;\n output: OutputIface;\n}\nexport const runChannelInstall = async (args: ChannelInstallArgsIface): Promise<number> => {\n try {\n const result = await args.client.channelBindings.create({\n projectId: args.projectId,\n connectorInstallId: args.connectorInstallId,\n revisionId: args.revisionId,\n channelKey: args.channelKey,\n ...(args.replace == null ? {} : { replace: args.replace }),\n });\n args.output.stdout(`installed ${args.channelKey}: ${result.bindingId}`);\n for (const route of result.routes) {\n const url = route.url ?? route.aliasUrl;\n if (url != null) args.output.stdout(` ${route.method} ${url}`);\n }\n return 0;\n } catch (error) {\n for (const line of errorLines(error)) args.output.stderr(line);\n return 1;\n }\n};\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,kBAAoC;AAUtC,MAAM,oBAAoB,OAAO,SAAmD;AACzF,MAAI;AACF,UAAM,SAAS,MAAM,KAAK,OAAO,gBAAgB,OAAO;AAAA,MACtD,WAAW,KAAK;AAAA,MAChB,oBAAoB,KAAK;AAAA,MACzB,YAAY,KAAK;AAAA,MACjB,YAAY,KAAK;AAAA,MACjB,GAAI,KAAK,WAAW,OAAO,CAAC,IAAI,EAAE,SAAS,KAAK,QAAQ;AAAA,IAC1D,CAAC;AACD,SAAK,OAAO,OAAO,aAAa,KAAK,UAAU,KAAK,OAAO,SAAS,EAAE;AACtE,eAAW,SAAS,OAAO,QAAQ;AACjC,YAAM,MAAM,MAAM,OAAO,MAAM;AAC/B,UAAI,OAAO,KAAM,MAAK,OAAO,OAAO,KAAK,MAAM,MAAM,IAAI,GAAG,EAAE;AAAA,IAChE;AACA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,eAAW,QAAQ,WAAW,KAAK,EAAG,MAAK,OAAO,OAAO,IAAI;AAC7D,WAAO;AAAA,EACT;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, Server } from 'node:http';
|
|
2
|
-
export declare const attachDevChannelSockets: (args: {
|
|
3
|
-
server: Server;
|
|
4
|
-
open: (incoming: IncomingMessage, signal: AbortSignal) => Promise<ChannelSocketOpenResult>;
|
|
5
|
-
log: (message: string) => void;
|
|
6
|
-
}) => {
|
|
7
|
-
close: () => Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
import type { ChannelSocketOpenResult } from '@finalai/agent-provider/local-channel-socket';
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CHANNEL_SOCKET_MAX_MESSAGE_BYTES,
|
|
3
|
-
ChannelSocketActionKind,
|
|
4
|
-
channelSocketData
|
|
5
|
-
} from "@finalai/agent-provider/channel-socket";
|
|
6
|
-
import { WebSocketServer } from "ws";
|
|
7
|
-
const attachDevChannelSockets = (args) => {
|
|
8
|
-
const protocols = /* @__PURE__ */ new WeakMap();
|
|
9
|
-
const sockets = new WebSocketServer({
|
|
10
|
-
noServer: true,
|
|
11
|
-
perMessageDeflate: false,
|
|
12
|
-
maxPayload: CHANNEL_SOCKET_MAX_MESSAGE_BYTES,
|
|
13
|
-
handleProtocols: (_offered, request) => protocols.get(request) ?? false
|
|
14
|
-
});
|
|
15
|
-
const controllers = /* @__PURE__ */ new Set();
|
|
16
|
-
let stopped = false;
|
|
17
|
-
const reject = async (socket, response) => {
|
|
18
|
-
const body = Buffer.from(await response.arrayBuffer());
|
|
19
|
-
const headers = new Headers(response.headers);
|
|
20
|
-
headers.set("connection", "close");
|
|
21
|
-
headers.set("content-length", String(body.byteLength));
|
|
22
|
-
socket.write(
|
|
23
|
-
`HTTP/1.1 ${response.status} ${response.statusText}\r
|
|
24
|
-
${[...headers].map(([name, value]) => `${name}: ${value}`).join("\r\n")}\r
|
|
25
|
-
\r
|
|
26
|
-
`
|
|
27
|
-
);
|
|
28
|
-
socket.end(body);
|
|
29
|
-
};
|
|
30
|
-
args.server.on("upgrade", (incoming, socket, head) => {
|
|
31
|
-
const controller = new AbortController();
|
|
32
|
-
controllers.add(controller);
|
|
33
|
-
socket.once("close", () => controller.abort());
|
|
34
|
-
socket.once("error", () => controller.abort());
|
|
35
|
-
let upgraded = false;
|
|
36
|
-
void (async () => {
|
|
37
|
-
if (stopped) {
|
|
38
|
-
await reject(socket, new Response("Dev server stopping", { status: 503 }));
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const opened = await args.open(incoming, controller.signal);
|
|
42
|
-
if (!opened.ok) {
|
|
43
|
-
await reject(socket, opened.response);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (controller.signal.aborted) {
|
|
47
|
-
opened.connection.close();
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
protocols.set(incoming, opened.protocol);
|
|
51
|
-
sockets.handleUpgrade(incoming, socket, head, (peer) => {
|
|
52
|
-
upgraded = true;
|
|
53
|
-
const cleanup = () => {
|
|
54
|
-
opened.connection.close();
|
|
55
|
-
controller.abort();
|
|
56
|
-
controllers.delete(controller);
|
|
57
|
-
};
|
|
58
|
-
peer.once("close", cleanup);
|
|
59
|
-
peer.once("error", cleanup);
|
|
60
|
-
peer.on("message", (raw, binary) => {
|
|
61
|
-
try {
|
|
62
|
-
const bytes = Array.isArray(raw) ? Buffer.concat(raw) : Buffer.isBuffer(raw) ? raw : Buffer.from(raw);
|
|
63
|
-
opened.connection.send(binary ? bytes : bytes.toString("utf8"));
|
|
64
|
-
} catch {
|
|
65
|
-
peer.close(1013, "Channel input unavailable");
|
|
66
|
-
cleanup();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
void (async () => {
|
|
70
|
-
for await (const action of opened.connection.actions) {
|
|
71
|
-
if (peer.readyState !== peer.OPEN) break;
|
|
72
|
-
if (action.kind === ChannelSocketActionKind.Message) {
|
|
73
|
-
if (peer.bufferedAmount > 8 * 1024 * 1024) {
|
|
74
|
-
peer.close(1013, "Channel output fell behind");
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
peer.send(channelSocketData(action));
|
|
78
|
-
} else if (action.kind === ChannelSocketActionKind.Close) {
|
|
79
|
-
peer.close(action.code ?? 1e3, action.reason ?? "");
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (peer.readyState === peer.OPEN) peer.close(1e3);
|
|
84
|
-
})().catch((cause) => {
|
|
85
|
-
args.log(
|
|
86
|
-
`socket route failed: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
87
|
-
);
|
|
88
|
-
if (peer.readyState === peer.OPEN) peer.close(1011, "Channel route failed");
|
|
89
|
-
}).finally(cleanup);
|
|
90
|
-
});
|
|
91
|
-
})().catch(async (cause) => {
|
|
92
|
-
args.log(`socket route failed: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
93
|
-
if (!socket.destroyed)
|
|
94
|
-
await reject(socket, new Response("Channel route failed", { status: 500 }));
|
|
95
|
-
}).finally(() => {
|
|
96
|
-
if (!upgraded) {
|
|
97
|
-
controller.abort();
|
|
98
|
-
controllers.delete(controller);
|
|
99
|
-
}
|
|
100
|
-
}).catch(() => socket.destroy());
|
|
101
|
-
});
|
|
102
|
-
return {
|
|
103
|
-
close: async () => {
|
|
104
|
-
stopped = true;
|
|
105
|
-
for (const controller of controllers) controller.abort();
|
|
106
|
-
for (const peer of sockets.clients) peer.terminate();
|
|
107
|
-
await new Promise((resolve) => sockets.close(() => resolve()));
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
export {
|
|
112
|
-
attachDevChannelSockets
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=channel-socket.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/cli/channel-socket.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n CHANNEL_SOCKET_MAX_MESSAGE_BYTES,\n ChannelSocketActionKind,\n channelSocketData,\n} from '@finalai/agent-provider/channel-socket';\nimport type { IncomingMessage, Server } from 'node:http';\nimport type { Duplex } from 'node:stream';\nimport { WebSocketServer } from 'ws';\n\n// Keeps an accepted local route on its original compiled bundle until disconnect.\nexport const attachDevChannelSockets = (args: {\n server: Server;\n open: (incoming: IncomingMessage, signal: AbortSignal) => Promise<ChannelSocketOpenResult>;\n log: (message: string) => void;\n}) => {\n const protocols = new WeakMap<IncomingMessage, string | null>();\n const sockets = new WebSocketServer({\n noServer: true,\n perMessageDeflate: false,\n maxPayload: CHANNEL_SOCKET_MAX_MESSAGE_BYTES,\n handleProtocols: (_offered, request) => protocols.get(request) ?? false,\n });\n const controllers = new Set<AbortController>();\n let stopped = false;\n const reject = async (socket: Duplex, response: Response): Promise<void> => {\n const body = Buffer.from(await response.arrayBuffer());\n const headers = new Headers(response.headers);\n headers.set('connection', 'close');\n headers.set('content-length', String(body.byteLength));\n socket.write(\n `HTTP/1.1 ${response.status} ${response.statusText}\\r\\n${[...headers].map(([name, value]) => `${name}: ${value}`).join('\\r\\n')}\\r\\n\\r\\n`,\n );\n socket.end(body);\n };\n args.server.on('upgrade', (incoming, socket, head) => {\n const controller = new AbortController();\n controllers.add(controller);\n socket.once('close', () => controller.abort());\n socket.once('error', () => controller.abort());\n let upgraded = false;\n void (async () => {\n if (stopped) {\n await reject(socket, new Response('Dev server stopping', { status: 503 }));\n return;\n }\n const opened = await args.open(incoming, controller.signal);\n if (!opened.ok) {\n await reject(socket, opened.response);\n return;\n }\n if (controller.signal.aborted) {\n opened.connection.close();\n return;\n }\n protocols.set(incoming, opened.protocol);\n sockets.handleUpgrade(incoming, socket, head, (peer) => {\n upgraded = true;\n const cleanup = (): void => {\n opened.connection.close();\n controller.abort();\n controllers.delete(controller);\n };\n peer.once('close', cleanup);\n peer.once('error', cleanup);\n peer.on('message', (raw, binary) => {\n try {\n const bytes = Array.isArray(raw)\n ? Buffer.concat(raw)\n : Buffer.isBuffer(raw)\n ? raw\n : Buffer.from(raw);\n opened.connection.send(binary ? bytes : bytes.toString('utf8'));\n } catch {\n peer.close(1013, 'Channel input unavailable');\n cleanup();\n }\n });\n void (async () => {\n for await (const action of opened.connection.actions) {\n if (peer.readyState !== peer.OPEN) break;\n if (action.kind === ChannelSocketActionKind.Message) {\n if (peer.bufferedAmount > 8 * 1024 * 1024) {\n peer.close(1013, 'Channel output fell behind');\n break;\n }\n peer.send(channelSocketData(action));\n } else if (action.kind === ChannelSocketActionKind.Close) {\n peer.close(action.code ?? 1000, action.reason ?? '');\n break;\n }\n }\n if (peer.readyState === peer.OPEN) peer.close(1000);\n })()\n .catch((cause: unknown) => {\n args.log(\n `socket route failed: ${cause instanceof Error ? cause.message : String(cause)}`,\n );\n if (peer.readyState === peer.OPEN) peer.close(1011, 'Channel route failed');\n })\n .finally(cleanup);\n });\n })()\n .catch(async (cause: unknown) => {\n args.log(`socket route failed: ${cause instanceof Error ? cause.message : String(cause)}`);\n if (!socket.destroyed)\n await reject(socket, new Response('Channel route failed', { status: 500 }));\n })\n .finally(() => {\n if (!upgraded) {\n controller.abort();\n controllers.delete(controller);\n }\n })\n .catch(() => socket.destroy());\n });\n return {\n close: async (): Promise<void> => {\n stopped = true;\n for (const controller of controllers) controller.abort();\n for (const peer of sockets.clients) peer.terminate();\n await new Promise<void>((resolve) => sockets.close(() => resolve()));\n },\n };\n};\n\nimport type { ChannelSocketOpenResult } from '@finalai/agent-provider/local-channel-socket';\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,uBAAuB;AAGzB,MAAM,0BAA0B,CAAC,SAIlC;AACJ,QAAM,YAAY,oBAAI,QAAwC;AAC9D,QAAM,UAAU,IAAI,gBAAgB;AAAA,IAClC,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,iBAAiB,CAAC,UAAU,YAAY,UAAU,IAAI,OAAO,KAAK;AAAA,EACpE,CAAC;AACD,QAAM,cAAc,oBAAI,IAAqB;AAC7C,MAAI,UAAU;AACd,QAAM,SAAS,OAAO,QAAgB,aAAsC;AAC1E,UAAM,OAAO,OAAO,KAAK,MAA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