@nodetool-ai/websocket 0.7.0-rc.11
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/dist/agent/agent-runtime.d.ts +47 -0
- package/dist/agent/agent-runtime.d.ts.map +1 -0
- package/dist/agent/agent-runtime.js +577 -0
- package/dist/agent/agent-runtime.js.map +1 -0
- package/dist/agent/codex-agent.d.ts +41 -0
- package/dist/agent/codex-agent.d.ts.map +1 -0
- package/dist/agent/codex-agent.js +334 -0
- package/dist/agent/codex-agent.js.map +1 -0
- package/dist/agent/index.d.ts +6 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +4 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/llm-agent.d.ts +51 -0
- package/dist/agent/llm-agent.d.ts.map +1 -0
- package/dist/agent/llm-agent.js +526 -0
- package/dist/agent/llm-agent.js.map +1 -0
- package/dist/agent/mcp-tool-server.d.ts +33 -0
- package/dist/agent/mcp-tool-server.d.ts.map +1 -0
- package/dist/agent/mcp-tool-server.js +292 -0
- package/dist/agent/mcp-tool-server.js.map +1 -0
- package/dist/agent/opencode-agent.d.ts +32 -0
- package/dist/agent/opencode-agent.d.ts.map +1 -0
- package/dist/agent/opencode-agent.js +332 -0
- package/dist/agent/opencode-agent.js.map +1 -0
- package/dist/agent/pi-agent.d.ts +42 -0
- package/dist/agent/pi-agent.d.ts.map +1 -0
- package/dist/agent/pi-agent.js +429 -0
- package/dist/agent/pi-agent.js.map +1 -0
- package/dist/agent/sdk-provider.d.ts +46 -0
- package/dist/agent/sdk-provider.d.ts.map +1 -0
- package/dist/agent/sdk-provider.js +50 -0
- package/dist/agent/sdk-provider.js.map +1 -0
- package/dist/agent/socket-route.d.ts +11 -0
- package/dist/agent/socket-route.d.ts.map +1 -0
- package/dist/agent/socket-route.js +262 -0
- package/dist/agent/socket-route.js.map +1 -0
- package/dist/agent/transport.d.ts +39 -0
- package/dist/agent/transport.d.ts.map +1 -0
- package/dist/agent/transport.js +17 -0
- package/dist/agent/transport.js.map +1 -0
- package/dist/agent/types.d.ts +11 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +10 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/collection-api.d.ts +14 -0
- package/dist/collection-api.d.ts.map +1 -0
- package/dist/collection-api.js +75 -0
- package/dist/collection-api.js.map +1 -0
- package/dist/error-codes.d.ts +3 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +2 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/file-api.d.ts +12 -0
- package/dist/file-api.d.ts.map +1 -0
- package/dist/file-api.js +76 -0
- package/dist/file-api.js.map +1 -0
- package/dist/http-api.d.ts +94 -0
- package/dist/http-api.d.ts.map +1 -0
- package/dist/http-api.js +1472 -0
- package/dist/http-api.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/asset-paths.d.ts +10 -0
- package/dist/lib/asset-paths.d.ts.map +1 -0
- package/dist/lib/asset-paths.js +45 -0
- package/dist/lib/asset-paths.js.map +1 -0
- package/dist/lib/bridge.d.ts +8 -0
- package/dist/lib/bridge.d.ts.map +1 -0
- package/dist/lib/bridge.js +70 -0
- package/dist/lib/bridge.js.map +1 -0
- package/dist/mcp-server.d.ts +32 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +842 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/models-api.d.ts +12 -0
- package/dist/models-api.d.ts.map +1 -0
- package/dist/models-api.js +730 -0
- package/dist/models-api.js.map +1 -0
- package/dist/oauth-api.d.ts +28 -0
- package/dist/oauth-api.d.ts.map +1 -0
- package/dist/oauth-api.js +681 -0
- package/dist/oauth-api.js.map +1 -0
- package/dist/openai-api.d.ts +63 -0
- package/dist/openai-api.d.ts.map +1 -0
- package/dist/openai-api.js +359 -0
- package/dist/openai-api.js.map +1 -0
- package/dist/plugins/websocket.d.ts +14 -0
- package/dist/plugins/websocket.d.ts.map +1 -0
- package/dist/plugins/websocket.js +431 -0
- package/dist/plugins/websocket.js.map +1 -0
- package/dist/resolve-media-urls.d.ts +19 -0
- package/dist/resolve-media-urls.d.ts.map +1 -0
- package/dist/resolve-media-urls.js +109 -0
- package/dist/resolve-media-urls.js.map +1 -0
- package/dist/routes/assets.d.ts +22 -0
- package/dist/routes/assets.d.ts.map +1 -0
- package/dist/routes/assets.js +168 -0
- package/dist/routes/assets.js.map +1 -0
- package/dist/routes/collections.d.ts +16 -0
- package/dist/routes/collections.d.ts.map +1 -0
- package/dist/routes/collections.js +32 -0
- package/dist/routes/collections.js.map +1 -0
- package/dist/routes/files.d.ts +12 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +11 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/health.d.ts +4 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +41 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/jobs.d.ts +16 -0
- package/dist/routes/jobs.d.ts.map +1 -0
- package/dist/routes/jobs.js +25 -0
- package/dist/routes/jobs.js.map +1 -0
- package/dist/routes/nodes.d.ts +8 -0
- package/dist/routes/nodes.d.ts.map +1 -0
- package/dist/routes/nodes.js +124 -0
- package/dist/routes/nodes.js.map +1 -0
- package/dist/routes/oauth.d.ts +8 -0
- package/dist/routes/oauth.d.ts.map +1 -0
- package/dist/routes/oauth.js +19 -0
- package/dist/routes/oauth.js.map +1 -0
- package/dist/routes/openai.d.ts +8 -0
- package/dist/routes/openai.d.ts.map +1 -0
- package/dist/routes/openai.js +20 -0
- package/dist/routes/openai.js.map +1 -0
- package/dist/routes/storage.d.ts +12 -0
- package/dist/routes/storage.d.ts.map +1 -0
- package/dist/routes/storage.js +13 -0
- package/dist/routes/storage.js.map +1 -0
- package/dist/routes/workflows.d.ts +18 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +25 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/routes/workspace.d.ts +15 -0
- package/dist/routes/workspace.d.ts.map +1 -0
- package/dist/routes/workspace.js +24 -0
- package/dist/routes/workspace.js.map +1 -0
- package/dist/screenshot-server.d.ts +21 -0
- package/dist/screenshot-server.d.ts.map +1 -0
- package/dist/screenshot-server.js +222 -0
- package/dist/screenshot-server.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +783 -0
- package/dist/server.js.map +1 -0
- package/dist/settings-registry.d.ts +29 -0
- package/dist/settings-registry.d.ts.map +1 -0
- package/dist/settings-registry.js +117 -0
- package/dist/settings-registry.js.map +1 -0
- package/dist/storage-api.d.ts +5 -0
- package/dist/storage-api.d.ts.map +1 -0
- package/dist/storage-api.js +221 -0
- package/dist/storage-api.js.map +1 -0
- package/dist/test-ui-server.d.ts +19 -0
- package/dist/test-ui-server.d.ts.map +1 -0
- package/dist/test-ui-server.js +1256 -0
- package/dist/test-ui-server.js.map +1 -0
- package/dist/trpc/context.d.ts +21 -0
- package/dist/trpc/context.d.ts.map +1 -0
- package/dist/trpc/context.js +10 -0
- package/dist/trpc/context.js.map +1 -0
- package/dist/trpc/error-formatter.d.ts +18 -0
- package/dist/trpc/error-formatter.d.ts.map +1 -0
- package/dist/trpc/error-formatter.js +41 -0
- package/dist/trpc/error-formatter.js.map +1 -0
- package/dist/trpc/index.d.ts +18 -0
- package/dist/trpc/index.d.ts.map +1 -0
- package/dist/trpc/index.js +13 -0
- package/dist/trpc/index.js.map +1 -0
- package/dist/trpc/middleware.d.ts +8 -0
- package/dist/trpc/middleware.d.ts.map +1 -0
- package/dist/trpc/middleware.js +12 -0
- package/dist/trpc/middleware.js.map +1 -0
- package/dist/trpc/router.d.ts +2543 -0
- package/dist/trpc/router.d.ts.map +1 -0
- package/dist/trpc/router.js +43 -0
- package/dist/trpc/router.js.map +1 -0
- package/dist/trpc/routers/assets.d.ts +229 -0
- package/dist/trpc/routers/assets.d.ts.map +1 -0
- package/dist/trpc/routers/assets.js +263 -0
- package/dist/trpc/routers/assets.js.map +1 -0
- package/dist/trpc/routers/collections.d.ts +88 -0
- package/dist/trpc/routers/collections.d.ts.map +1 -0
- package/dist/trpc/routers/collections.js +166 -0
- package/dist/trpc/routers/collections.js.map +1 -0
- package/dist/trpc/routers/costs.d.ts +129 -0
- package/dist/trpc/routers/costs.d.ts.map +1 -0
- package/dist/trpc/routers/costs.js +95 -0
- package/dist/trpc/routers/costs.js.map +1 -0
- package/dist/trpc/routers/files.d.ts +34 -0
- package/dist/trpc/routers/files.d.ts.map +1 -0
- package/dist/trpc/routers/files.js +92 -0
- package/dist/trpc/routers/files.js.map +1 -0
- package/dist/trpc/routers/jobs.d.ts +92 -0
- package/dist/trpc/routers/jobs.d.ts.map +1 -0
- package/dist/trpc/routers/jobs.js +100 -0
- package/dist/trpc/routers/jobs.js.map +1 -0
- package/dist/trpc/routers/mcp-config.d.ts +69 -0
- package/dist/trpc/routers/mcp-config.d.ts.map +1 -0
- package/dist/trpc/routers/mcp-config.js +290 -0
- package/dist/trpc/routers/mcp-config.js.map +1 -0
- package/dist/trpc/routers/messages.d.ts +121 -0
- package/dist/trpc/routers/messages.d.ts.map +1 -0
- package/dist/trpc/routers/messages.js +113 -0
- package/dist/trpc/routers/messages.js.map +1 -0
- package/dist/trpc/routers/models.d.ts +748 -0
- package/dist/trpc/routers/models.d.ts.map +1 -0
- package/dist/trpc/routers/models.js +1107 -0
- package/dist/trpc/routers/models.js.map +1 -0
- package/dist/trpc/routers/nodes.d.ts +48 -0
- package/dist/trpc/routers/nodes.d.ts.map +1 -0
- package/dist/trpc/routers/nodes.js +57 -0
- package/dist/trpc/routers/nodes.js.map +1 -0
- package/dist/trpc/routers/sandboxes.d.ts +64 -0
- package/dist/trpc/routers/sandboxes.d.ts.map +1 -0
- package/dist/trpc/routers/sandboxes.js +327 -0
- package/dist/trpc/routers/sandboxes.js.map +1 -0
- package/dist/trpc/routers/settings.d.ts +113 -0
- package/dist/trpc/routers/settings.d.ts.map +1 -0
- package/dist/trpc/routers/settings.js +193 -0
- package/dist/trpc/routers/settings.js.map +1 -0
- package/dist/trpc/routers/skills.d.ts +41 -0
- package/dist/trpc/routers/skills.d.ts.map +1 -0
- package/dist/trpc/routers/skills.js +194 -0
- package/dist/trpc/routers/skills.js.map +1 -0
- package/dist/trpc/routers/storage.d.ts +44 -0
- package/dist/trpc/routers/storage.d.ts.map +1 -0
- package/dist/trpc/routers/storage.js +153 -0
- package/dist/trpc/routers/storage.js.map +1 -0
- package/dist/trpc/routers/threads.d.ts +95 -0
- package/dist/trpc/routers/threads.d.ts.map +1 -0
- package/dist/trpc/routers/threads.js +150 -0
- package/dist/trpc/routers/threads.js.map +1 -0
- package/dist/trpc/routers/users.d.ts +79 -0
- package/dist/trpc/routers/users.d.ts.map +1 -0
- package/dist/trpc/routers/users.js +125 -0
- package/dist/trpc/routers/users.js.map +1 -0
- package/dist/trpc/routers/workflows.d.ts +681 -0
- package/dist/trpc/routers/workflows.d.ts.map +1 -0
- package/dist/trpc/routers/workflows.js +725 -0
- package/dist/trpc/routers/workflows.js.map +1 -0
- package/dist/trpc/routers/workspace.d.ts +127 -0
- package/dist/trpc/routers/workspace.d.ts.map +1 -0
- package/dist/trpc/routers/workspace.js +203 -0
- package/dist/trpc/routers/workspace.js.map +1 -0
- package/dist/unified-websocket-runner.d.ts +280 -0
- package/dist/unified-websocket-runner.d.ts.map +1 -0
- package/dist/unified-websocket-runner.js +3840 -0
- package/dist/unified-websocket-runner.js.map +1 -0
- package/dist/workspace-api.d.ts +14 -0
- package/dist/workspace-api.d.ts.map +1 -0
- package/dist/workspace-api.js +104 -0
- package/dist/workspace-api.js.map +1 -0
- package/dist/ws-adapter.d.ts +25 -0
- package/dist/ws-adapter.d.ts.map +1 -0
- package/dist/ws-adapter.js +63 -0
- package/dist/ws-adapter.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collections router — migrated from REST `/api/collections*`.
|
|
3
|
+
*
|
|
4
|
+
* NOTE: the file-upload endpoint `POST /api/collections/:name/index` remains
|
|
5
|
+
* on REST because its multipart/form-data body is not a natural fit for tRPC's
|
|
6
|
+
* JSON link. The other CRUD + query endpoints move here.
|
|
7
|
+
*/
|
|
8
|
+
import { Workflow } from "@nodetool-ai/models";
|
|
9
|
+
import { getVecStore, VecNotFoundError } from "@nodetool-ai/vectorstore";
|
|
10
|
+
import { ApiErrorCode } from "../../error-codes.js";
|
|
11
|
+
import { router } from "../index.js";
|
|
12
|
+
import { protectedProcedure } from "../middleware.js";
|
|
13
|
+
import { throwApiError } from "../error-formatter.js";
|
|
14
|
+
import { listOutput, getInput, collectionResponse, createInput, updateInput, deleteInput, deleteOutput, queryInput, queryOutput } from "@nodetool-ai/protocol/api-schemas/collections.js";
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a CollectionMetadata (may contain `undefined` values per the
|
|
17
|
+
* vectorstore type) to the wire schema (string | number | boolean only).
|
|
18
|
+
*/
|
|
19
|
+
function normalizeMetadata(metadata) {
|
|
20
|
+
const result = {};
|
|
21
|
+
if (!metadata)
|
|
22
|
+
return result;
|
|
23
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
24
|
+
if (value !== undefined)
|
|
25
|
+
result[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Helper: resolve a workflow's name from an id. Returns `null` on any
|
|
31
|
+
* lookup failure. Mirrors the REST handler's forgiving behaviour.
|
|
32
|
+
*/
|
|
33
|
+
async function resolveWorkflowName(workflowId) {
|
|
34
|
+
if (!workflowId)
|
|
35
|
+
return null;
|
|
36
|
+
try {
|
|
37
|
+
const workflow = (await Workflow.get(workflowId));
|
|
38
|
+
return workflow?.name ?? null;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Map VecNotFoundError → tRPC NOT_FOUND. Re-throws anything else. */
|
|
45
|
+
function rethrowAsTrpc(err) {
|
|
46
|
+
if (err instanceof VecNotFoundError) {
|
|
47
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Collection not found");
|
|
48
|
+
}
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
export const collectionsRouter = router({
|
|
52
|
+
list: protectedProcedure.output(listOutput).query(async () => {
|
|
53
|
+
const store = await getVecStore();
|
|
54
|
+
const collections = await store.listCollections();
|
|
55
|
+
const results = await Promise.all(collections.map(async (col) => {
|
|
56
|
+
const count = await col.count();
|
|
57
|
+
const metadata = normalizeMetadata(col.metadata);
|
|
58
|
+
const workflowName = await resolveWorkflowName(typeof metadata.workflow === "string" ? metadata.workflow : undefined);
|
|
59
|
+
return {
|
|
60
|
+
name: col.name,
|
|
61
|
+
count,
|
|
62
|
+
metadata,
|
|
63
|
+
workflow_name: workflowName
|
|
64
|
+
};
|
|
65
|
+
}));
|
|
66
|
+
return { collections: results, count: results.length };
|
|
67
|
+
}),
|
|
68
|
+
get: protectedProcedure
|
|
69
|
+
.input(getInput)
|
|
70
|
+
.output(collectionResponse)
|
|
71
|
+
.query(async ({ input }) => {
|
|
72
|
+
const store = await getVecStore();
|
|
73
|
+
try {
|
|
74
|
+
const collection = await store.getCollection({ name: input.name });
|
|
75
|
+
const count = await collection.count();
|
|
76
|
+
return {
|
|
77
|
+
name: collection.name,
|
|
78
|
+
metadata: normalizeMetadata(collection.metadata),
|
|
79
|
+
count
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
rethrowAsTrpc(err);
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
create: protectedProcedure
|
|
87
|
+
.input(createInput)
|
|
88
|
+
.output(collectionResponse)
|
|
89
|
+
.mutation(async ({ input }) => {
|
|
90
|
+
const store = await getVecStore();
|
|
91
|
+
const metadata = {};
|
|
92
|
+
if (input.embedding_model) {
|
|
93
|
+
metadata.embedding_model = input.embedding_model;
|
|
94
|
+
}
|
|
95
|
+
if (input.embedding_provider) {
|
|
96
|
+
metadata.embedding_provider = input.embedding_provider;
|
|
97
|
+
}
|
|
98
|
+
const collection = await store.createCollection({
|
|
99
|
+
name: input.name,
|
|
100
|
+
metadata
|
|
101
|
+
});
|
|
102
|
+
return {
|
|
103
|
+
name: collection.name,
|
|
104
|
+
metadata: normalizeMetadata(collection.metadata),
|
|
105
|
+
count: 0
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
update: protectedProcedure
|
|
109
|
+
.input(updateInput)
|
|
110
|
+
.output(collectionResponse)
|
|
111
|
+
.mutation(async ({ input }) => {
|
|
112
|
+
const store = await getVecStore();
|
|
113
|
+
let collection;
|
|
114
|
+
try {
|
|
115
|
+
collection = await store.getCollection({ name: input.name });
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
rethrowAsTrpc(err);
|
|
119
|
+
}
|
|
120
|
+
const existing = normalizeMetadata(collection.metadata);
|
|
121
|
+
const merged = { ...existing };
|
|
122
|
+
if (input.metadata) {
|
|
123
|
+
Object.assign(merged, input.metadata);
|
|
124
|
+
}
|
|
125
|
+
const newName = input.rename ?? collection.name;
|
|
126
|
+
await collection.modify({ name: newName, metadata: merged });
|
|
127
|
+
const count = await collection.count();
|
|
128
|
+
return {
|
|
129
|
+
name: newName,
|
|
130
|
+
metadata: merged,
|
|
131
|
+
count
|
|
132
|
+
};
|
|
133
|
+
}),
|
|
134
|
+
delete: protectedProcedure
|
|
135
|
+
.input(deleteInput)
|
|
136
|
+
.output(deleteOutput)
|
|
137
|
+
.mutation(async ({ input }) => {
|
|
138
|
+
const store = await getVecStore();
|
|
139
|
+
try {
|
|
140
|
+
await store.deleteCollection({ name: input.name });
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
rethrowAsTrpc(err);
|
|
144
|
+
}
|
|
145
|
+
return { message: `Collection ${input.name} deleted successfully` };
|
|
146
|
+
}),
|
|
147
|
+
query: protectedProcedure
|
|
148
|
+
.input(queryInput)
|
|
149
|
+
.output(queryOutput)
|
|
150
|
+
.query(async ({ input }) => {
|
|
151
|
+
const store = await getVecStore();
|
|
152
|
+
let collection;
|
|
153
|
+
try {
|
|
154
|
+
collection = await store.getCollection({ name: input.name });
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
rethrowAsTrpc(err);
|
|
158
|
+
}
|
|
159
|
+
const results = await collection.query({
|
|
160
|
+
queryTexts: input.query_texts,
|
|
161
|
+
nResults: input.n_results
|
|
162
|
+
});
|
|
163
|
+
return results;
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../../src/trpc/routers/collections.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,WAAW,EACX,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,UAAU,EACV,QAAQ,EACR,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACZ,MAAM,kDAAkD,CAAC;AAE1D;;;GAGG;AACH,SAAS,iBAAiB,CACxB,QAAwC;IAExC,MAAM,MAAM,GAA8C,EAAE,CAAC;IAC7D,IAAI,CAAC,QAAQ;QAAE,OAAO,MAAM,CAAC;IAC7B,KAAK,M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AAC,CAAC;QACrB,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC;YACrC,UAAU,EAAE,KAAK,CAAC,WAAW;YAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS;SAC1B,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export declare const costsRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
2
|
+
ctx: import("../context.js").Context;
|
|
3
|
+
meta: object;
|
|
4
|
+
errorShape: import("../error-formatter.js").ApiErrorShape;
|
|
5
|
+
transformer: true;
|
|
6
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
7
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
8
|
+
input: {
|
|
9
|
+
provider?: string | undefined;
|
|
10
|
+
model?: string | undefined;
|
|
11
|
+
limit?: number | undefined;
|
|
12
|
+
startKey?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
output: {
|
|
15
|
+
calls: {
|
|
16
|
+
id: string;
|
|
17
|
+
user_id: string;
|
|
18
|
+
node_id: string;
|
|
19
|
+
provider: string;
|
|
20
|
+
model: string;
|
|
21
|
+
workflow_id: string | null;
|
|
22
|
+
cost: number | null;
|
|
23
|
+
input_tokens: number | null;
|
|
24
|
+
output_tokens: number | null;
|
|
25
|
+
total_tokens: number | null;
|
|
26
|
+
cached_tokens: number | null;
|
|
27
|
+
reasoning_tokens: number | null;
|
|
28
|
+
created_at: string | null;
|
|
29
|
+
metadata: Record<string, unknown> | null;
|
|
30
|
+
}[];
|
|
31
|
+
next_start_key: string | null;
|
|
32
|
+
};
|
|
33
|
+
meta: object;
|
|
34
|
+
}>;
|
|
35
|
+
aggregate: import("@trpc/server").TRPCQueryProcedure<{
|
|
36
|
+
input: {
|
|
37
|
+
provider?: string | undefined;
|
|
38
|
+
model?: string | undefined;
|
|
39
|
+
};
|
|
40
|
+
output: {
|
|
41
|
+
user_id: string;
|
|
42
|
+
provider: string | null;
|
|
43
|
+
model: string | null;
|
|
44
|
+
total_cost: number;
|
|
45
|
+
total_input_tokens: number;
|
|
46
|
+
total_output_tokens: number;
|
|
47
|
+
total_tokens: number;
|
|
48
|
+
call_count: number;
|
|
49
|
+
};
|
|
50
|
+
meta: object;
|
|
51
|
+
}>;
|
|
52
|
+
aggregateByProvider: import("@trpc/server").TRPCQueryProcedure<{
|
|
53
|
+
input: void;
|
|
54
|
+
output: {
|
|
55
|
+
provider: string;
|
|
56
|
+
total_cost: number;
|
|
57
|
+
total_input_tokens: number;
|
|
58
|
+
total_output_tokens: number;
|
|
59
|
+
total_tokens: number;
|
|
60
|
+
call_count: number;
|
|
61
|
+
}[];
|
|
62
|
+
meta: object;
|
|
63
|
+
}>;
|
|
64
|
+
aggregateByModel: import("@trpc/server").TRPCQueryProcedure<{
|
|
65
|
+
input: {
|
|
66
|
+
provider?: string | undefined;
|
|
67
|
+
};
|
|
68
|
+
output: {
|
|
69
|
+
provider: string;
|
|
70
|
+
model: string;
|
|
71
|
+
total_cost: number;
|
|
72
|
+
total_input_tokens: number;
|
|
73
|
+
total_output_tokens: number;
|
|
74
|
+
total_tokens: number;
|
|
75
|
+
call_count: number;
|
|
76
|
+
}[];
|
|
77
|
+
meta: object;
|
|
78
|
+
}>;
|
|
79
|
+
summary: import("@trpc/server").TRPCQueryProcedure<{
|
|
80
|
+
input: void;
|
|
81
|
+
output: {
|
|
82
|
+
overall: {
|
|
83
|
+
user_id: string;
|
|
84
|
+
provider: string | null;
|
|
85
|
+
model: string | null;
|
|
86
|
+
total_cost: number;
|
|
87
|
+
total_input_tokens: number;
|
|
88
|
+
total_output_tokens: number;
|
|
89
|
+
total_tokens: number;
|
|
90
|
+
call_count: number;
|
|
91
|
+
};
|
|
92
|
+
by_provider: {
|
|
93
|
+
provider: string;
|
|
94
|
+
total_cost: number;
|
|
95
|
+
total_input_tokens: number;
|
|
96
|
+
total_output_tokens: number;
|
|
97
|
+
total_tokens: number;
|
|
98
|
+
call_count: number;
|
|
99
|
+
}[];
|
|
100
|
+
by_model: {
|
|
101
|
+
provider: string;
|
|
102
|
+
model: string;
|
|
103
|
+
total_cost: number;
|
|
104
|
+
total_input_tokens: number;
|
|
105
|
+
total_output_tokens: number;
|
|
106
|
+
total_tokens: number;
|
|
107
|
+
call_count: number;
|
|
108
|
+
}[];
|
|
109
|
+
recent_calls: {
|
|
110
|
+
id: string;
|
|
111
|
+
user_id: string;
|
|
112
|
+
node_id: string;
|
|
113
|
+
provider: string;
|
|
114
|
+
model: string;
|
|
115
|
+
workflow_id: string | null;
|
|
116
|
+
cost: number | null;
|
|
117
|
+
input_tokens: number | null;
|
|
118
|
+
output_tokens: number | null;
|
|
119
|
+
total_tokens: number | null;
|
|
120
|
+
cached_tokens: number | null;
|
|
121
|
+
reasoning_tokens: number | null;
|
|
122
|
+
created_at: string | null;
|
|
123
|
+
metadata: Record<string, unknown> | null;
|
|
124
|
+
}[];
|
|
125
|
+
};
|
|
126
|
+
meta: object;
|
|
127
|
+
}>;
|
|
128
|
+
}>>;
|
|
129
|
+
//# sourceMappingURL=costs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"costs.d.ts","sourceRoot":"","sources":["../../../src/trpc/routers/costs.ts"],"names":[],"mappings":"AAqDA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DtB,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Prediction } from "@nodetool-ai/models";
|
|
2
|
+
import { router } from "../index.js";
|
|
3
|
+
import { protectedProcedure } from "../middleware.js";
|
|
4
|
+
import { listPredictionsInput, listPredictionsOutput, aggregateInput, aggregateByUserOutput, aggregateByProviderOutput, aggregateByModelInput, aggregateByModelOutput, summaryOutput } from "@nodetool-ai/protocol/api-schemas/costs.js";
|
|
5
|
+
function toPredictionResponse(pred) {
|
|
6
|
+
return {
|
|
7
|
+
id: pred.id,
|
|
8
|
+
user_id: pred.user_id,
|
|
9
|
+
node_id: pred.node_id ?? "",
|
|
10
|
+
provider: pred.provider,
|
|
11
|
+
model: pred.model,
|
|
12
|
+
workflow_id: pred.workflow_id ?? null,
|
|
13
|
+
cost: pred.cost ?? null,
|
|
14
|
+
input_tokens: pred.input_tokens ?? null,
|
|
15
|
+
output_tokens: pred.output_tokens ?? null,
|
|
16
|
+
total_tokens: pred.total_tokens ?? null,
|
|
17
|
+
cached_tokens: pred.cached_tokens ?? null,
|
|
18
|
+
reasoning_tokens: pred.reasoning_tokens ?? null,
|
|
19
|
+
created_at: pred.created_at,
|
|
20
|
+
metadata: pred.metadata ?? null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Normalize `AggregateResult` → `AggregateByUserOutput` by coercing optional
|
|
25
|
+
* `provider`/`model` (which can be `undefined`) to `null` so the shape matches
|
|
26
|
+
* the zod schema. Mocks in tests may return either shape.
|
|
27
|
+
*/
|
|
28
|
+
function normalizeAggregate(agg) {
|
|
29
|
+
return {
|
|
30
|
+
user_id: agg.user_id,
|
|
31
|
+
provider: agg.provider ?? null,
|
|
32
|
+
model: agg.model ?? null,
|
|
33
|
+
total_cost: agg.total_cost,
|
|
34
|
+
total_input_tokens: agg.total_input_tokens,
|
|
35
|
+
total_output_tokens: agg.total_output_tokens,
|
|
36
|
+
total_tokens: agg.total_tokens,
|
|
37
|
+
call_count: agg.call_count
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export const costsRouter = router({
|
|
41
|
+
list: protectedProcedure
|
|
42
|
+
.input(listPredictionsInput)
|
|
43
|
+
.output(listPredictionsOutput)
|
|
44
|
+
.query(async ({ ctx, input }) => {
|
|
45
|
+
const [calls, nextKey] = await Prediction.paginate(ctx.userId, {
|
|
46
|
+
provider: input.provider,
|
|
47
|
+
model: input.model,
|
|
48
|
+
limit: input.limit,
|
|
49
|
+
startKey: input.startKey
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
calls: calls.map(toPredictionResponse),
|
|
53
|
+
next_start_key: nextKey || null
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
56
|
+
aggregate: protectedProcedure
|
|
57
|
+
.input(aggregateInput)
|
|
58
|
+
.output(aggregateByUserOutput)
|
|
59
|
+
.query(async ({ ctx, input }) => {
|
|
60
|
+
const result = await Prediction.aggregateByUser(ctx.userId, {
|
|
61
|
+
provider: input.provider,
|
|
62
|
+
model: input.model
|
|
63
|
+
});
|
|
64
|
+
return normalizeAggregate(result);
|
|
65
|
+
}),
|
|
66
|
+
aggregateByProvider: protectedProcedure
|
|
67
|
+
.output(aggregateByProviderOutput)
|
|
68
|
+
.query(async ({ ctx }) => {
|
|
69
|
+
return Prediction.aggregateByProvider(ctx.userId);
|
|
70
|
+
}),
|
|
71
|
+
aggregateByModel: protectedProcedure
|
|
72
|
+
.input(aggregateByModelInput)
|
|
73
|
+
.output(aggregateByModelOutput)
|
|
74
|
+
.query(async ({ ctx, input }) => {
|
|
75
|
+
return Prediction.aggregateByModel(ctx.userId, {
|
|
76
|
+
provider: input.provider
|
|
77
|
+
});
|
|
78
|
+
}),
|
|
79
|
+
summary: protectedProcedure.output(summaryOutput).query(async ({ ctx }) => {
|
|
80
|
+
const [overall, byProvider, byModel, paginated] = await Promise.all([
|
|
81
|
+
Prediction.aggregateByUser(ctx.userId),
|
|
82
|
+
Prediction.aggregateByProvider(ctx.userId),
|
|
83
|
+
Prediction.aggregateByModel(ctx.userId),
|
|
84
|
+
Prediction.paginate(ctx.userId, { limit: 10 })
|
|
85
|
+
]);
|
|
86
|
+
const [recentCalls] = paginated;
|
|
87
|
+
return {
|
|
88
|
+
overall: normalizeAggregate(overall),
|
|
89
|
+
by_provider: byProvider,
|
|
90
|
+
by_model: byModel,
|
|
91
|
+
recent_calls: recentCalls.map(toPredictionResponse)
|
|
92
|
+
};
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=costs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"costs.js","sourceRoot":"","sources":["../../../src/trpc/routers/costs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAwB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EAGd,MAAM,4CAA4C,CAAC;AAEpD,SAAS,oBAAoB,CAAC,IAAgB;IAC5C,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;QACrC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI;QACvB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI;QACvC,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;QACzC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI;QACvC,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;QACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,IAAI;QAC/C,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI;KAChC,CAAC;AACJ,CAA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AAC,WAAW,CAAC,GAAG,SAAS,CAAC;QAChC,OAAO;YACL,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;YACpC,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,OAAO;YACjB,YAAY,EAAE,WAAW,CAAC,GAAG,CAAC,oBAAoB,CAAC;SACpD,CAAC;IACJ,CAAC,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const filesRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
2
|
+
ctx: import("../context.js").Context;
|
|
3
|
+
meta: object;
|
|
4
|
+
errorShape: import("../error-formatter.js").ApiErrorShape;
|
|
5
|
+
transformer: true;
|
|
6
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
7
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
8
|
+
input: {
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
output: {
|
|
12
|
+
name: string;
|
|
13
|
+
path: string;
|
|
14
|
+
size: number;
|
|
15
|
+
is_dir: boolean;
|
|
16
|
+
modified_at: string;
|
|
17
|
+
}[];
|
|
18
|
+
meta: object;
|
|
19
|
+
}>;
|
|
20
|
+
info: import("@trpc/server").TRPCQueryProcedure<{
|
|
21
|
+
input: {
|
|
22
|
+
path: string;
|
|
23
|
+
};
|
|
24
|
+
output: {
|
|
25
|
+
name: string;
|
|
26
|
+
path: string;
|
|
27
|
+
size: number;
|
|
28
|
+
is_dir: boolean;
|
|
29
|
+
modified_at: string;
|
|
30
|
+
};
|
|
31
|
+
meta: object;
|
|
32
|
+
}>;
|
|
33
|
+
}>>;
|
|
34
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/trpc/routers/files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEtB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tRPC router for the files domain — local filesystem browser (JSON ops).
|
|
3
|
+
* Binary download (/api/files/download) stays as REST.
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from "node:fs/promises";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import * as os from "node:os";
|
|
8
|
+
import { router } from "../index.js";
|
|
9
|
+
import { protectedProcedure } from "../middleware.js";
|
|
10
|
+
import { throwApiError } from "../error-formatter.js";
|
|
11
|
+
import { listFilesInput, listFilesOutput, fileInfoInput, fileInfoOutput } from "@nodetool-ai/protocol/api-schemas/files.js";
|
|
12
|
+
import { ApiErrorCode } from "@nodetool-ai/protocol/api-schemas/api-error-code.js";
|
|
13
|
+
// ── Sandbox helpers ─────────────────────────────────────────────────────────
|
|
14
|
+
function getRootDir() {
|
|
15
|
+
return os.homedir();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a user-provided path within the sandbox root.
|
|
19
|
+
* Returns the resolved absolute path, or throws FORBIDDEN if path escapes.
|
|
20
|
+
*/
|
|
21
|
+
function resolveSandboxed(rootDir, userPath) {
|
|
22
|
+
const resolved = path.resolve(rootDir, userPath.startsWith("/") ? "." + userPath : userPath);
|
|
23
|
+
const normalizedRoot = path.resolve(rootDir);
|
|
24
|
+
if (!resolved.startsWith(normalizedRoot + path.sep) &&
|
|
25
|
+
resolved !== normalizedRoot) {
|
|
26
|
+
throwApiError(ApiErrorCode.FORBIDDEN, "Path traversal not allowed");
|
|
27
|
+
}
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
|
30
|
+
// ── Router ──────────────────────────────────────────────────────────────────
|
|
31
|
+
export const filesRouter = router({
|
|
32
|
+
list: protectedProcedure
|
|
33
|
+
.input(listFilesInput)
|
|
34
|
+
.output(listFilesOutput)
|
|
35
|
+
.query(async ({ input }) => {
|
|
36
|
+
if (process.env["NODETOOL_ENV"] === "production") {
|
|
37
|
+
throwApiError(ApiErrorCode.FORBIDDEN, "File browser is disabled in production");
|
|
38
|
+
}
|
|
39
|
+
const rootDir = getRootDir();
|
|
40
|
+
const resolved = resolveSandboxed(rootDir, input.path);
|
|
41
|
+
try {
|
|
42
|
+
const entries = await fs.readdir(resolved, { withFileTypes: true });
|
|
43
|
+
return Promise.all(entries.map(async (entry) => {
|
|
44
|
+
const fullPath = path.join(resolved, entry.name);
|
|
45
|
+
let size = 0;
|
|
46
|
+
let modifiedAt = "";
|
|
47
|
+
try {
|
|
48
|
+
const stat = await fs.stat(fullPath);
|
|
49
|
+
size = stat.size;
|
|
50
|
+
modifiedAt = stat.mtime.toISOString();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// stat may fail for broken symlinks — return defaults
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
name: entry.name,
|
|
57
|
+
path: fullPath,
|
|
58
|
+
size,
|
|
59
|
+
is_dir: entry.isDirectory(),
|
|
60
|
+
modified_at: modifiedAt
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Directory not found");
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
info: protectedProcedure
|
|
69
|
+
.input(fileInfoInput)
|
|
70
|
+
.output(fileInfoOutput)
|
|
71
|
+
.query(async ({ input }) => {
|
|
72
|
+
if (process.env["NODETOOL_ENV"] === "production") {
|
|
73
|
+
throwApiError(ApiErrorCode.FORBIDDEN, "File browser is disabled in production");
|
|
74
|
+
}
|
|
75
|
+
const rootDir = getRootDir();
|
|
76
|
+
const resolved = resolveSandboxed(rootDir, input.path);
|
|
77
|
+
try {
|
|
78
|
+
const stat = await fs.stat(resolved);
|
|
79
|
+
return {
|
|
80
|
+
name: path.basename(resolved),
|
|
81
|
+
path: resolved,
|
|
82
|
+
size: stat.size,
|
|
83
|
+
is_dir: stat.isDirectory(),
|
|
84
|
+
modified_at: stat.mtime.toISOString()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "File not found");
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/trpc/routers/files.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACf,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AAEnF,+EAA+E;AAE/E,SAAS,UAAU;IACjB,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,OAAe,EAAE,QAAgB;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAC3B,OAAO,EACP,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CACrD,CAAC;IACF,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,IACE,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC;QAC/C,QAAQ,KAAK,cAAc,EAC3B,CAAC;QACD,aAA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
|
1
|
+
/**
|
|
2
|
+
* Jobs router — migrated from REST `/api/jobs*`.
|
|
3
|
+
*
|
|
4
|
+
* Ported verbatim from the legacy http-api.ts handlers (`handleJobsRoot`,
|
|
5
|
+
* `handleJobById`, `handleJobCancel`, and the inline `/running/all` handler).
|
|
6
|
+
* User ownership is enforced on every procedure — a job whose `user_id`
|
|
7
|
+
* doesn't match `ctx.userId` is indistinguishable from a missing one.
|
|
8
|
+
*
|
|
9
|
+
* The trigger stubs (`/api/jobs/triggers/*`) stay on REST — they're
|
|
10
|
+
* 501-placeholders for a feature that isn't available in standalone mode.
|
|
11
|
+
*/
|
|
12
|
+
export declare const jobsRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
13
|
+
ctx: import("../context.js").Context;
|
|
14
|
+
meta: object;
|
|
15
|
+
errorShape: import("../error-formatter.js").ApiErrorShape;
|
|
16
|
+
transformer: true;
|
|
17
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
18
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
19
|
+
input: {
|
|
20
|
+
limit?: number | undefined;
|
|
21
|
+
workflow_id?: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
output: {
|
|
24
|
+
jobs: {
|
|
25
|
+
id: string;
|
|
26
|
+
user_id: string;
|
|
27
|
+
job_type: "workflow";
|
|
28
|
+
status: string;
|
|
29
|
+
workflow_id: string;
|
|
30
|
+
started_at: string | null;
|
|
31
|
+
finished_at: string | null;
|
|
32
|
+
error: string | null;
|
|
33
|
+
cost: number | null;
|
|
34
|
+
}[];
|
|
35
|
+
next_start_key: string | null;
|
|
36
|
+
};
|
|
37
|
+
meta: object;
|
|
38
|
+
}>;
|
|
39
|
+
runningAll: import("@trpc/server").TRPCQueryProcedure<{
|
|
40
|
+
input: void;
|
|
41
|
+
output: {
|
|
42
|
+
job_id: string;
|
|
43
|
+
status: string;
|
|
44
|
+
workflow_id: string;
|
|
45
|
+
created_at: string | null;
|
|
46
|
+
is_running: boolean;
|
|
47
|
+
is_completed: boolean;
|
|
48
|
+
}[];
|
|
49
|
+
meta: object;
|
|
50
|
+
}>;
|
|
51
|
+
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
52
|
+
input: {
|
|
53
|
+
id: string;
|
|
54
|
+
};
|
|
55
|
+
output: {
|
|
56
|
+
id: string;
|
|
57
|
+
user_id: string;
|
|
58
|
+
job_type: "workflow";
|
|
59
|
+
status: string;
|
|
60
|
+
workflow_id: string;
|
|
61
|
+
started_at: string | null;
|
|
62
|
+
finished_at: string | null;
|
|
63
|
+
error: string | null;
|
|
64
|
+
cost: number | null;
|
|
65
|
+
};
|
|
66
|
+
meta: object;
|
|
67
|
+
}>;
|
|
68
|
+
delete: import("@trpc/server").TRPCMutationProcedure<{
|
|
69
|
+
input: {
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
output: {
|
|
73
|
+
ok: true;
|
|
74
|
+
};
|
|
75
|
+
meta: object;
|
|
76
|
+
}>;
|
|
77
|
+
cancel: import("@trpc/server").TRPCMutationProcedure<{
|
|
78
|
+
input: {
|
|
79
|
+
id: string;
|
|
80
|
+
};
|
|
81
|
+
output: {
|
|
82
|
+
job_id: string;
|
|
83
|
+
status: string;
|
|
84
|
+
workflow_id: string;
|
|
85
|
+
created_at: string | null;
|
|
86
|
+
is_running: boolean;
|
|
87
|
+
is_completed: boolean;
|
|
88
|
+
};
|
|
89
|
+
meta: object;
|
|
90
|
+
}>;
|
|
91
|
+
}>>;
|
|
92
|
+
//# sourceMappingURL=jobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.d.ts","sourceRoot":"","sources":["../../../src/trpc/routers/jobs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkDH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DrB,CAAC"}
|