@nodetool-ai/protocol 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.
Files changed (117) hide show
  1. package/dist/agent-protocol.d.ts +217 -0
  2. package/dist/agent-protocol.d.ts.map +1 -0
  3. package/dist/agent-protocol.js +85 -0
  4. package/dist/agent-protocol.js.map +1 -0
  5. package/dist/api-schemas/api-error-code.d.ts +21 -0
  6. package/dist/api-schemas/api-error-code.d.ts.map +1 -0
  7. package/dist/api-schemas/api-error-code.js +20 -0
  8. package/dist/api-schemas/api-error-code.js.map +1 -0
  9. package/dist/api-schemas/assets.d.ts +162 -0
  10. package/dist/api-schemas/assets.d.ts.map +1 -0
  11. package/dist/api-schemas/assets.js +119 -0
  12. package/dist/api-schemas/assets.js.map +1 -0
  13. package/dist/api-schemas/collections.d.ts +64 -0
  14. package/dist/api-schemas/collections.d.ts.map +1 -0
  15. package/dist/api-schemas/collections.js +67 -0
  16. package/dist/api-schemas/collections.js.map +1 -0
  17. package/dist/api-schemas/costs.d.ts +168 -0
  18. package/dist/api-schemas/costs.d.ts.map +1 -0
  19. package/dist/api-schemas/costs.js +90 -0
  20. package/dist/api-schemas/costs.js.map +1 -0
  21. package/dist/api-schemas/error-helpers.d.ts +19 -0
  22. package/dist/api-schemas/error-helpers.d.ts.map +1 -0
  23. package/dist/api-schemas/error-helpers.js +7 -0
  24. package/dist/api-schemas/error-helpers.js.map +1 -0
  25. package/dist/api-schemas/files.d.ts +38 -0
  26. package/dist/api-schemas/files.d.ts.map +1 -0
  27. package/dist/api-schemas/files.js +25 -0
  28. package/dist/api-schemas/files.js.map +1 -0
  29. package/dist/api-schemas/fonts.d.ts +6 -0
  30. package/dist/api-schemas/fonts.d.ts.map +1 -0
  31. package/dist/api-schemas/fonts.js +8 -0
  32. package/dist/api-schemas/fonts.js.map +1 -0
  33. package/dist/api-schemas/index.d.ts +20 -0
  34. package/dist/api-schemas/index.d.ts.map +1 -0
  35. package/dist/api-schemas/index.js +20 -0
  36. package/dist/api-schemas/index.js.map +1 -0
  37. package/dist/api-schemas/jobs.d.ts +77 -0
  38. package/dist/api-schemas/jobs.d.ts.map +1 -0
  39. package/dist/api-schemas/jobs.js +60 -0
  40. package/dist/api-schemas/jobs.js.map +1 -0
  41. package/dist/api-schemas/mcp-config.d.ts +119 -0
  42. package/dist/api-schemas/mcp-config.d.ts.map +1 -0
  43. package/dist/api-schemas/mcp-config.js +59 -0
  44. package/dist/api-schemas/mcp-config.js.map +1 -0
  45. package/dist/api-schemas/messages.d.ts +77 -0
  46. package/dist/api-schemas/messages.d.ts.map +1 -0
  47. package/dist/api-schemas/messages.js +81 -0
  48. package/dist/api-schemas/messages.js.map +1 -0
  49. package/dist/api-schemas/models.d.ts +202 -0
  50. package/dist/api-schemas/models.d.ts.map +1 -0
  51. package/dist/api-schemas/models.js +135 -0
  52. package/dist/api-schemas/models.js.map +1 -0
  53. package/dist/api-schemas/nodes.d.ts +23 -0
  54. package/dist/api-schemas/nodes.d.ts.map +1 -0
  55. package/dist/api-schemas/nodes.js +20 -0
  56. package/dist/api-schemas/nodes.js.map +1 -0
  57. package/dist/api-schemas/settings.d.ts +75 -0
  58. package/dist/api-schemas/settings.d.ts.map +1 -0
  59. package/dist/api-schemas/settings.js +66 -0
  60. package/dist/api-schemas/settings.js.map +1 -0
  61. package/dist/api-schemas/skills.d.ts +19 -0
  62. package/dist/api-schemas/skills.d.ts.map +1 -0
  63. package/dist/api-schemas/skills.js +16 -0
  64. package/dist/api-schemas/skills.js.map +1 -0
  65. package/dist/api-schemas/storage.d.ts +46 -0
  66. package/dist/api-schemas/storage.d.ts.map +1 -0
  67. package/dist/api-schemas/storage.js +32 -0
  68. package/dist/api-schemas/storage.js.map +1 -0
  69. package/dist/api-schemas/threads.d.ts +58 -0
  70. package/dist/api-schemas/threads.d.ts.map +1 -0
  71. package/dist/api-schemas/threads.js +52 -0
  72. package/dist/api-schemas/threads.js.map +1 -0
  73. package/dist/api-schemas/users.d.ts +49 -0
  74. package/dist/api-schemas/users.d.ts.map +1 -0
  75. package/dist/api-schemas/users.js +44 -0
  76. package/dist/api-schemas/users.js.map +1 -0
  77. package/dist/api-schemas/workflows.d.ts +489 -0
  78. package/dist/api-schemas/workflows.d.ts.map +1 -0
  79. package/dist/api-schemas/workflows.js +248 -0
  80. package/dist/api-schemas/workflows.js.map +1 -0
  81. package/dist/api-schemas/workspace.d.ts +88 -0
  82. package/dist/api-schemas/workspace.d.ts.map +1 -0
  83. package/dist/api-schemas/workspace.js +65 -0
  84. package/dist/api-schemas/workspace.js.map +1 -0
  85. package/dist/api-types.d.ts +809 -0
  86. package/dist/api-types.d.ts.map +1 -0
  87. package/dist/api-types.js +9 -0
  88. package/dist/api-types.js.map +1 -0
  89. package/dist/graph.d.ts +75 -0
  90. package/dist/graph.d.ts.map +1 -0
  91. package/dist/graph.js +15 -0
  92. package/dist/graph.js.map +1 -0
  93. package/dist/index.d.ts +12 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +12 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/messages.d.ts +334 -0
  98. package/dist/messages.d.ts.map +1 -0
  99. package/dist/messages.js +71 -0
  100. package/dist/messages.js.map +1 -0
  101. package/dist/toolSchemas.d.ts +108 -0
  102. package/dist/toolSchemas.d.ts.map +1 -0
  103. package/dist/toolSchemas.js +205 -0
  104. package/dist/toolSchemas.js.map +1 -0
  105. package/dist/type-metadata.d.ts +39 -0
  106. package/dist/type-metadata.d.ts.map +1 -0
  107. package/dist/type-metadata.js +126 -0
  108. package/dist/type-metadata.js.map +1 -0
  109. package/dist/typecheck.d.ts +17 -0
  110. package/dist/typecheck.d.ts.map +1 -0
  111. package/dist/typecheck.js +63 -0
  112. package/dist/typecheck.js.map +1 -0
  113. package/dist/wrap-primitives.d.ts +18 -0
  114. package/dist/wrap-primitives.d.ts.map +1 -0
  115. package/dist/wrap-primitives.js +28 -0
  116. package/dist/wrap-primitives.js.map +1 -0
  117. package/package.json +58 -0
@@ -0,0 +1,217 @@
1
+ /**
2
+ * @nodetool-ai/protocol – Agent WebSocket Protocol
3
+ *
4
+ * Shared type definitions for the agent runtime and WebSocket protocol
5
+ * exchanged between the server (where the agent SDK runs) and renderers
6
+ * (web/electron) over the `/ws/agent` WebSocket endpoint.
7
+ *
8
+ * This is the single source of truth. The server runtime and the renderer
9
+ * both import from here to stay in lockstep.
10
+ */
11
+ export type AgentProvider = "claude" | "codex" | "opencode" | "pi" | "llm";
12
+ export interface AgentModelDescriptor {
13
+ id: string;
14
+ label: string;
15
+ isDefault?: boolean;
16
+ provider?: AgentProvider;
17
+ /**
18
+ * For `provider === "llm"` only: the underlying chat provider id
19
+ * (e.g. "anthropic", "openai", "gemini") that should serve this model.
20
+ * Lets one logical "llm" agent provider front-end models from many
21
+ * registered runtime providers without overloading `id`.
22
+ */
23
+ chatProviderId?: string;
24
+ /** Supports adjustable reasoning effort (Codex) */
25
+ supportsReasoningEffort?: boolean;
26
+ /** Supports max turns setting */
27
+ supportsMaxTurns?: boolean;
28
+ }
29
+ /** Runtime parameters for an agent session */
30
+ export interface AgentModelParams {
31
+ /** Max agentic turns before stopping */
32
+ maxTurns?: number;
33
+ /** Reasoning effort level (Codex only) */
34
+ reasoningEffort?: "minimal" | "low" | "medium" | "high" | "xhigh";
35
+ }
36
+ export interface AgentSessionOptions {
37
+ provider?: AgentProvider;
38
+ model: string;
39
+ /** Underlying chat provider id when `provider === "llm"`. */
40
+ chatProviderId?: string;
41
+ workspacePath?: string;
42
+ resumeSessionId?: string;
43
+ modelParams?: AgentModelParams;
44
+ }
45
+ export interface AgentModelsRequest {
46
+ provider?: AgentProvider;
47
+ workspacePath?: string;
48
+ }
49
+ export interface AgentListSessionsRequest {
50
+ dir?: string;
51
+ limit?: number;
52
+ offset?: number;
53
+ /** When set, only query this provider. Otherwise queries all providers. */
54
+ provider?: AgentProvider;
55
+ }
56
+ export interface AgentSessionInfoEntry {
57
+ sessionId: string;
58
+ summary: string;
59
+ lastModified: number;
60
+ cwd?: string;
61
+ gitBranch?: string;
62
+ customTitle?: string;
63
+ firstPrompt?: string;
64
+ createdAt?: number;
65
+ /** Which provider owns this session */
66
+ provider?: AgentProvider;
67
+ }
68
+ export interface AgentGetSessionMessagesRequest {
69
+ sessionId: string;
70
+ dir?: string;
71
+ }
72
+ export interface AgentTranscriptMessage {
73
+ type: "user" | "assistant";
74
+ uuid: string;
75
+ session_id: string;
76
+ text: string;
77
+ }
78
+ /**
79
+ * Serializable representation of an SDK message for transport.
80
+ * Matches the renderer-facing AgentMessage shape used by the chat UI.
81
+ */
82
+ export interface AgentMessage {
83
+ type: "assistant" | "user" | "result" | "system" | "status" | "stream_event";
84
+ uuid: string;
85
+ session_id: string;
86
+ /** Text content for assistant and result messages */
87
+ text?: string;
88
+ /** Error flag for result messages */
89
+ is_error?: boolean;
90
+ /** Error messages for error results */
91
+ errors?: string[];
92
+ /** Result subtype */
93
+ subtype?: string;
94
+ /** Original message content blocks (for assistant messages) */
95
+ content?: Array<{
96
+ type: string;
97
+ text?: string;
98
+ }>;
99
+ /** Tool calls in OpenAI-style format for NodeTool UI compatibility */
100
+ tool_calls?: Array<{
101
+ id: string;
102
+ type: string;
103
+ function: {
104
+ name: string;
105
+ arguments: string;
106
+ };
107
+ }>;
108
+ }
109
+ /** Manifest entry describing a frontend (renderer-executed) tool. */
110
+ export interface FrontendToolManifest {
111
+ name: string;
112
+ description: string;
113
+ parameters: unknown;
114
+ }
115
+ /**
116
+ * Client-to-server commands.
117
+ * Each command carries a `request_id` so the server can correlate the
118
+ * eventual `response` envelope with the original request.
119
+ */
120
+ export type AgentClientMessage = {
121
+ command: "create_session";
122
+ request_id: string;
123
+ options: AgentSessionOptions;
124
+ } | {
125
+ command: "send_message";
126
+ request_id: string;
127
+ session_id: string;
128
+ message: string;
129
+ } | {
130
+ command: "stop_execution";
131
+ request_id: string;
132
+ session_id: string;
133
+ } | {
134
+ command: "close_session";
135
+ request_id: string;
136
+ session_id: string;
137
+ } | {
138
+ command: "list_models";
139
+ request_id: string;
140
+ options: AgentModelsRequest;
141
+ } | {
142
+ command: "list_sessions";
143
+ request_id: string;
144
+ options: AgentListSessionsRequest;
145
+ } | {
146
+ command: "get_session_messages";
147
+ request_id: string;
148
+ options: AgentGetSessionMessagesRequest;
149
+ } | {
150
+ /** Reply to a server-initiated `tools_manifest_request`. */
151
+ command: "tools_manifest_response";
152
+ request_id: string;
153
+ manifest: FrontendToolManifest[];
154
+ } | {
155
+ /** Reply to a server-initiated `tool_call_request`. */
156
+ command: "tool_call_response";
157
+ request_id: string;
158
+ result: {
159
+ result?: unknown;
160
+ isError: boolean;
161
+ error?: string;
162
+ };
163
+ };
164
+ /** Command name literal union for discriminating typed request helpers. */
165
+ export type AgentClientCommand = AgentClientMessage["command"];
166
+ /**
167
+ * Map command name → the payload-only shape (the full envelope minus the
168
+ * `command` and `request_id` fields). Used to type request/response helpers.
169
+ */
170
+ export type AgentClientPayload<C extends AgentClientCommand> = Omit<Extract<AgentClientMessage, {
171
+ command: C;
172
+ }>, "command" | "request_id">;
173
+ /**
174
+ * Server-to-client envelopes.
175
+ * `response` correlates with a previously sent client `command` via `request_id`.
176
+ * Other types are server-initiated push events.
177
+ */
178
+ export type AgentServerMessage = {
179
+ type: "response";
180
+ request_id: string;
181
+ data?: unknown;
182
+ error?: string;
183
+ } | {
184
+ type: "agent_stream_message";
185
+ session_id: string;
186
+ message: AgentMessage;
187
+ done: boolean;
188
+ } | {
189
+ type: "tools_manifest_request";
190
+ request_id: string;
191
+ session_id: string;
192
+ } | {
193
+ type: "tool_call_request";
194
+ request_id: string;
195
+ session_id: string;
196
+ tool_call_id: string;
197
+ name: string;
198
+ args: unknown;
199
+ } | {
200
+ type: "tool_call_abort";
201
+ session_id: string;
202
+ };
203
+ /**
204
+ * Minimal runtime validator for incoming client messages. Returns the message
205
+ * typed as `AgentClientMessage` when the shape looks right, or a descriptive
206
+ * error string otherwise. Enough to reject malformed input early so callers
207
+ * get clear feedback instead of silently falling through to the `never`
208
+ * exhaustive check.
209
+ */
210
+ export declare function validateAgentClientMessage(raw: unknown): {
211
+ ok: true;
212
+ value: AgentClientMessage;
213
+ } | {
214
+ ok: false;
215
+ error: string;
216
+ };
217
+ //# sourceMappingURL=agent-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-protocol.d.ts","sourceRoot":"","sources":["../src/agent-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,KAAK,CAAC;AAE3E,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mDAAmD;IACnD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,8CAA8C;AAC9C,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,eAAe,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CACnE;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,aAAa,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E,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf,GACD;IACE,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAMN;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,OAAO,GACX;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAgExE"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @nodetool-ai/protocol – Agent WebSocket Protocol
3
+ *
4
+ * Shared type definitions for the agent runtime and WebSocket protocol
5
+ * exchanged between the server (where the agent SDK runs) and renderers
6
+ * (web/electron) over the `/ws/agent` WebSocket endpoint.
7
+ *
8
+ * This is the single source of truth. The server runtime and the renderer
9
+ * both import from here to stay in lockstep.
10
+ */
11
+ // ---------------------------------------------------------------------------
12
+ // Runtime validators (shape checks, no dependency on Zod)
13
+ // ---------------------------------------------------------------------------
14
+ /**
15
+ * Minimal runtime validator for incoming client messages. Returns the message
16
+ * typed as `AgentClientMessage` when the shape looks right, or a descriptive
17
+ * error string otherwise. Enough to reject malformed input early so callers
18
+ * get clear feedback instead of silently falling through to the `never`
19
+ * exhaustive check.
20
+ */
21
+ export function validateAgentClientMessage(raw) {
22
+ if (!raw || typeof raw !== "object") {
23
+ return { ok: false, error: "message is not an object" };
24
+ }
25
+ const obj = raw;
26
+ if (typeof obj.command !== "string") {
27
+ return { ok: false, error: "missing or non-string `command`" };
28
+ }
29
+ if (typeof obj.request_id !== "string") {
30
+ return { ok: false, error: "missing or non-string `request_id`" };
31
+ }
32
+ switch (obj.command) {
33
+ case "create_session":
34
+ if (!obj.options || typeof obj.options !== "object") {
35
+ return { ok: false, error: "create_session: `options` is required" };
36
+ }
37
+ return { ok: true, value: obj };
38
+ case "send_message":
39
+ if (typeof obj.session_id !== "string" || typeof obj.message !== "string") {
40
+ return {
41
+ ok: false,
42
+ error: "send_message: `session_id` and `message` must be strings",
43
+ };
44
+ }
45
+ return { ok: true, value: obj };
46
+ case "stop_execution":
47
+ case "close_session":
48
+ if (typeof obj.session_id !== "string") {
49
+ return {
50
+ ok: false,
51
+ error: `${obj.command}: \`session_id\` must be a string`,
52
+ };
53
+ }
54
+ return { ok: true, value: obj };
55
+ case "list_models":
56
+ case "list_sessions":
57
+ case "get_session_messages":
58
+ if (!obj.options || typeof obj.options !== "object") {
59
+ return {
60
+ ok: false,
61
+ error: `${obj.command}: \`options\` is required`,
62
+ };
63
+ }
64
+ return { ok: true, value: obj };
65
+ case "tools_manifest_response":
66
+ if (!Array.isArray(obj.manifest)) {
67
+ return {
68
+ ok: false,
69
+ error: "tools_manifest_response: `manifest` must be an array",
70
+ };
71
+ }
72
+ return { ok: true, value: obj };
73
+ case "tool_call_response":
74
+ if (!obj.result || typeof obj.result !== "object") {
75
+ return {
76
+ ok: false,
77
+ error: "tool_call_response: `result` is required",
78
+ };
79
+ }
80
+ return { ok: true, value: obj };
81
+ default:
82
+ return { ok: false, error: `unknown command: ${String(obj.command)}` };
83
+ }
84
+ }
85
+ //# sourceMappingURL=agent-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-protocol.js","sourceRoot":"","sources":["../src/agent-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA6NH,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,GAAY;IAEZ,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,0BAA0B,EAAE,CAAC;IAC1D,CAAC;IACD,MAAM,GAAG,GAAG,GAA8B,CAAC;IAC3C,IAAI,OAAO,GAAG,CAAC,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ERROR",
9
+ SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
10
+ WORKFLOW_NOT_FOUND = "WORKFLOW_NOT_FOUND",
11
+ WORKFLOW_EXECUTION_FAILED = "WORKFLOW_EXECUTION_FAILED",
12
+ ASSET_NOT_FOUND = "ASSET_NOT_FOUND",
13
+ ASSET_UPLOAD_FAILED = "ASSET_UPLOAD_FAILED",
14
+ PYTHON_BRIDGE_UNAVAILABLE = "PYTHON_BRIDGE_UNAVAILABLE"
15
+ }
16
+ export interface ApiErrorResponse {
17
+ code: ApiErrorCode;
18
+ detail: string;
19
+ }
20
+ export declare function apiError(code: ApiErrorCode, detail: string): ApiErrorResponse;
21
+ //# sourceMappingURL=api-error-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-error-code.d.ts","sourceRoot":"","sources":["../../src/api-schemas/api-error-code.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,sBAAsB,2BAA2B;IACjD,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IACzC,yBAAyB,8BAA8B;IACvD,eAAe,oBAAoB;IACnC,mBAAmB,wBAAwB;IAC3C,yBAAyB,8BAA8B;CACxD;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAE7E"}
@@ -0,0 +1,20 @@
1
+ export var ApiErrorCode;
2
+ (function (ApiErrorCode) {
3
+ ApiErrorCode["NOT_FOUND"] = "NOT_FOUND";
4
+ ApiErrorCode["ALREADY_EXISTS"] = "ALREADY_EXISTS";
5
+ ApiErrorCode["INVALID_INPUT"] = "INVALID_INPUT";
6
+ ApiErrorCode["MISSING_REQUIRED_FIELD"] = "MISSING_REQUIRED_FIELD";
7
+ ApiErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
8
+ ApiErrorCode["FORBIDDEN"] = "FORBIDDEN";
9
+ ApiErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
10
+ ApiErrorCode["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
11
+ ApiErrorCode["WORKFLOW_NOT_FOUND"] = "WORKFLOW_NOT_FOUND";
12
+ ApiErrorCode["WORKFLOW_EXECUTION_FAILED"] = "WORKFLOW_EXECUTION_FAILED";
13
+ ApiErrorCode["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
14
+ ApiErrorCode["ASSET_UPLOAD_FAILED"] = "ASSET_UPLOAD_FAILED";
15
+ ApiErrorCode["PYTHON_BRIDGE_UNAVAILABLE"] = "PYTHON_BRIDGE_UNAVAILABLE";
16
+ })(ApiErrorCode || (ApiErrorCode = {}));
17
+ export function apiError(code, detail) {
18
+ return { code, detail };
19
+ }
20
+ //# sourceMappingURL=api-error-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-error-code.js","sourceRoot":"","sources":["../../src/api-schemas/api-error-code.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAcX;AAdD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iDAAiC,CAAA;IACjC,+CAA+B,CAAA;IAC/B,iEAAiD,CAAA;IACjD,6CAA6B,CAAA;IAC7B,uCAAuB,CAAA;IACvB,iDAAiC,CAAA;IACjC,2DAA2C,CAAA;IAC3C,yDAAyC,CAAA;IACzC,uEAAuD,CAAA;IACvD,mDAAmC,CAAA;IACnC,2DAA2C,CAAA;IAC3C,uEAAuD,CAAA;AACzD,CAAC,EAdW,YAAY,KAAZ,YAAY,QAcvB;AAOD,MAAM,UAAU,QAAQ,CAAC,IAAkB,EAAE,MAAc;IACzD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,162 @@
1
+ import { z } from "zod";
2
+ export declare const assetResponse: z.ZodObject<{
3
+ id: z.ZodString;
4
+ user_id: z.ZodString;
5
+ workflow_id: z.ZodNullable<z.ZodString>;
6
+ parent_id: z.ZodNullable<z.ZodString>;
7
+ name: z.ZodString;
8
+ content_type: z.ZodString;
9
+ size: z.ZodNullable<z.ZodNumber>;
10
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
11
+ created_at: z.ZodString;
12
+ get_url: z.ZodNullable<z.ZodString>;
13
+ thumb_url: z.ZodNullable<z.ZodString>;
14
+ duration: z.ZodNullable<z.ZodNumber>;
15
+ node_id: z.ZodNullable<z.ZodString>;
16
+ job_id: z.ZodNullable<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ export type AssetResponse = z.infer<typeof assetResponse>;
19
+ export declare const listInput: z.ZodObject<{
20
+ parent_id: z.ZodOptional<z.ZodString>;
21
+ content_type: z.ZodOptional<z.ZodString>;
22
+ workflow_id: z.ZodOptional<z.ZodString>;
23
+ node_id: z.ZodOptional<z.ZodString>;
24
+ job_id: z.ZodOptional<z.ZodString>;
25
+ page_size: z.ZodDefault<z.ZodNumber>;
26
+ }, z.core.$strip>;
27
+ export type ListInput = z.infer<typeof listInput>;
28
+ export declare const listOutput: z.ZodObject<{
29
+ assets: z.ZodArray<z.ZodObject<{
30
+ id: z.ZodString;
31
+ user_id: z.ZodString;
32
+ workflow_id: z.ZodNullable<z.ZodString>;
33
+ parent_id: z.ZodNullable<z.ZodString>;
34
+ name: z.ZodString;
35
+ content_type: z.ZodString;
36
+ size: z.ZodNullable<z.ZodNumber>;
37
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ created_at: z.ZodString;
39
+ get_url: z.ZodNullable<z.ZodString>;
40
+ thumb_url: z.ZodNullable<z.ZodString>;
41
+ duration: z.ZodNullable<z.ZodNumber>;
42
+ node_id: z.ZodNullable<z.ZodString>;
43
+ job_id: z.ZodNullable<z.ZodString>;
44
+ }, z.core.$strip>>;
45
+ next: z.ZodNullable<z.ZodString>;
46
+ }, z.core.$strip>;
47
+ export type ListOutput = z.infer<typeof listOutput>;
48
+ export declare const getInput: z.ZodObject<{
49
+ id: z.ZodString;
50
+ }, z.core.$strip>;
51
+ export type GetInput = z.infer<typeof getInput>;
52
+ export declare const createInput: z.ZodObject<{
53
+ name: z.ZodString;
54
+ content_type: z.ZodString;
55
+ parent_id: z.ZodString;
56
+ workflow_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
+ node_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ job_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
60
+ size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
61
+ }, z.core.$strip>;
62
+ export type CreateInput = z.infer<typeof createInput>;
63
+ export declare const updateInput: z.ZodObject<{
64
+ id: z.ZodString;
65
+ name: z.ZodOptional<z.ZodString>;
66
+ content_type: z.ZodOptional<z.ZodString>;
67
+ parent_id: z.ZodOptional<z.ZodString>;
68
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
69
+ size: z.ZodOptional<z.ZodNumber>;
70
+ data: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ data_encoding: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
72
+ base64: "base64";
73
+ "utf-8": "utf-8";
74
+ }>>>;
75
+ }, z.core.$strip>;
76
+ export type UpdateInput = z.infer<typeof updateInput>;
77
+ export declare const deleteInput: z.ZodObject<{
78
+ id: z.ZodString;
79
+ }, z.core.$strip>;
80
+ export type DeleteInput = z.infer<typeof deleteInput>;
81
+ export declare const deleteOutput: z.ZodObject<{
82
+ deleted_asset_ids: z.ZodArray<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ export type DeleteOutput = z.infer<typeof deleteOutput>;
85
+ export declare const childrenInput: z.ZodObject<{
86
+ id: z.ZodString;
87
+ limit: z.ZodDefault<z.ZodNumber>;
88
+ }, z.core.$strip>;
89
+ export type ChildrenInput = z.infer<typeof childrenInput>;
90
+ export declare const childAsset: z.ZodObject<{
91
+ id: z.ZodString;
92
+ name: z.ZodString;
93
+ content_type: z.ZodString;
94
+ }, z.core.$strip>;
95
+ export type ChildAsset = z.infer<typeof childAsset>;
96
+ export declare const childrenOutput: z.ZodObject<{
97
+ assets: z.ZodArray<z.ZodObject<{
98
+ id: z.ZodString;
99
+ name: z.ZodString;
100
+ content_type: z.ZodString;
101
+ }, z.core.$strip>>;
102
+ next: z.ZodNullable<z.ZodString>;
103
+ }, z.core.$strip>;
104
+ export type ChildrenOutput = z.infer<typeof childrenOutput>;
105
+ export declare const recursiveInput: z.ZodObject<{
106
+ id: z.ZodString;
107
+ }, z.core.$strip>;
108
+ export type RecursiveInput = z.infer<typeof recursiveInput>;
109
+ export declare const recursiveOutput: z.ZodObject<{
110
+ assets: z.ZodArray<z.ZodObject<{
111
+ id: z.ZodString;
112
+ user_id: z.ZodString;
113
+ workflow_id: z.ZodNullable<z.ZodString>;
114
+ parent_id: z.ZodNullable<z.ZodString>;
115
+ name: z.ZodString;
116
+ content_type: z.ZodString;
117
+ size: z.ZodNullable<z.ZodNumber>;
118
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
119
+ created_at: z.ZodString;
120
+ get_url: z.ZodNullable<z.ZodString>;
121
+ thumb_url: z.ZodNullable<z.ZodString>;
122
+ duration: z.ZodNullable<z.ZodNumber>;
123
+ node_id: z.ZodNullable<z.ZodString>;
124
+ job_id: z.ZodNullable<z.ZodString>;
125
+ }, z.core.$strip>>;
126
+ }, z.core.$strip>;
127
+ export type RecursiveOutput = z.infer<typeof recursiveOutput>;
128
+ export declare const searchInput: z.ZodObject<{
129
+ query: z.ZodString;
130
+ content_type: z.ZodOptional<z.ZodString>;
131
+ page_size: z.ZodDefault<z.ZodNumber>;
132
+ cursor: z.ZodOptional<z.ZodString>;
133
+ workflow_id: z.ZodOptional<z.ZodString>;
134
+ }, z.core.$strip>;
135
+ export type SearchInput = z.infer<typeof searchInput>;
136
+ export declare const searchOutput: z.ZodObject<{
137
+ assets: z.ZodArray<z.ZodObject<{
138
+ id: z.ZodString;
139
+ user_id: z.ZodString;
140
+ workflow_id: z.ZodNullable<z.ZodString>;
141
+ parent_id: z.ZodNullable<z.ZodString>;
142
+ name: z.ZodString;
143
+ content_type: z.ZodString;
144
+ size: z.ZodNullable<z.ZodNumber>;
145
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
146
+ created_at: z.ZodString;
147
+ get_url: z.ZodNullable<z.ZodString>;
148
+ thumb_url: z.ZodNullable<z.ZodString>;
149
+ duration: z.ZodNullable<z.ZodNumber>;
150
+ node_id: z.ZodNullable<z.ZodString>;
151
+ job_id: z.ZodNullable<z.ZodString>;
152
+ }, z.core.$strip>>;
153
+ next_cursor: z.ZodNullable<z.ZodString>;
154
+ total_count: z.ZodNumber;
155
+ is_global_search: z.ZodBoolean;
156
+ }, z.core.$strip>;
157
+ export type SearchOutput = z.infer<typeof searchOutput>;
158
+ export declare const byFilenameInput: z.ZodObject<{
159
+ filename: z.ZodString;
160
+ }, z.core.$strip>;
161
+ export type ByFilenameInput = z.infer<typeof byFilenameInput>;
162
+ //# sourceMappingURL=assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/api-schemas/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;iBAexB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAK1D,eAAO,MAAM,SAAS;;;;;;;iBAO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CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;iBAE1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAI9D,eAAO,MAAM,WAAW;;;;;;iBAMtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;iBAKvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAGxD,eAAO,MAAM,eAAe;;iBAE1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+ // ── Asset response ───────────────────────────────────────────────
3
+ // Mirrors `toAssetResponse` in the legacy http-api.ts handler. `get_url`
4
+ // and `thumb_url` are resolved server-side; `duration` is only set for
5
+ // audio/video assets.
6
+ export const assetResponse = z.object({
7
+ id: z.string(),
8
+ user_id: z.string(),
9
+ workflow_id: z.string().nullable(),
10
+ parent_id: z.string().nullable(),
11
+ name: z.string(),
12
+ content_type: z.string(),
13
+ size: z.number().nullable(),
14
+ metadata: z.record(z.string(), z.unknown()).nullable(),
15
+ created_at: z.string(),
16
+ get_url: z.string().nullable(),
17
+ thumb_url: z.string().nullable(),
18
+ duration: z.number().nullable(),
19
+ node_id: z.string().nullable(),
20
+ job_id: z.string().nullable()
21
+ });
22
+ // ── list (GET /api/assets) ───────────────────────────────────────
23
+ // All filter parameters are optional; legacy defaults to the user's
24
+ // home folder if none are specified.
25
+ export const listInput = z.object({
26
+ parent_id: z.string().optional(),
27
+ content_type: z.string().optional(),
28
+ workflow_id: z.string().optional(),
29
+ node_id: z.string().optional(),
30
+ job_id: z.string().optional(),
31
+ page_size: z.number().int().min(1).max(10000).default(10000)
32
+ });
33
+ export const listOutput = z.object({
34
+ assets: z.array(assetResponse),
35
+ next: z.string().nullable()
36
+ });
37
+ // ── get (GET /api/assets/:id) ────────────────────────────────────
38
+ export const getInput = z.object({
39
+ id: z.string().min(1)
40
+ });
41
+ // ── create (POST /api/assets, JSON-only) ─────────────────────────
42
+ // Multipart/file uploads stay on REST — only the JSON-creation path
43
+ // (e.g. folder creation, metadata-only asset registration) is exposed here.
44
+ export const createInput = z.object({
45
+ name: z.string().min(1),
46
+ content_type: z.string().min(1),
47
+ parent_id: z.string().min(1),
48
+ workflow_id: z.string().nullable().optional(),
49
+ node_id: z.string().nullable().optional(),
50
+ job_id: z.string().nullable().optional(),
51
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
52
+ size: z.number().nullable().optional()
53
+ });
54
+ // ── update (PUT /api/assets/:id) ─────────────────────────────────
55
+ // The `data` field (base64 or utf-8 content) is supported here for
56
+ // small text/data writes; large binary uploads should go through the
57
+ // multipart REST endpoint instead.
58
+ export const updateInput = z.object({
59
+ id: z.string().min(1),
60
+ name: z.string().optional(),
61
+ content_type: z.string().optional(),
62
+ parent_id: z.string().optional(),
63
+ metadata: z.record(z.string(), z.unknown()).optional(),
64
+ size: z.number().optional(),
65
+ data: z.string().nullable().optional(),
66
+ data_encoding: z.enum(["base64", "utf-8"]).nullable().optional()
67
+ });
68
+ // ── delete (DELETE /api/assets/:id) ──────────────────────────────
69
+ // Cascading delete: folders remove all contents recursively. Response
70
+ // carries every id that was deleted so clients can invalidate caches.
71
+ export const deleteInput = z.object({
72
+ id: z.string().min(1)
73
+ });
74
+ export const deleteOutput = z.object({
75
+ deleted_asset_ids: z.array(z.string())
76
+ });
77
+ // ── children (GET /api/assets/:id/children) ──────────────────────
78
+ // Returns a trimmed list of direct children (just id/name/content_type).
79
+ export const childrenInput = z.object({
80
+ id: z.string().min(1),
81
+ limit: z.number().int().min(1).max(10000).default(100)
82
+ });
83
+ export const childAsset = z.object({
84
+ id: z.string(),
85
+ name: z.string(),
86
+ content_type: z.string()
87
+ });
88
+ export const childrenOutput = z.object({
89
+ assets: z.array(childAsset),
90
+ next: z.string().nullable()
91
+ });
92
+ // ── recursive (GET /api/assets/:id/recursive) ────────────────────
93
+ // Flat list of every asset under the folder, including nested sub-folders.
94
+ export const recursiveInput = z.object({
95
+ id: z.string().min(1)
96
+ });
97
+ export const recursiveOutput = z.object({
98
+ assets: z.array(assetResponse)
99
+ });
100
+ // ── search (GET /api/assets/search) ──────────────────────────────
101
+ // Minimum query length of 2 characters; matches by name substring.
102
+ export const searchInput = z.object({
103
+ query: z.string().min(2),
104
+ content_type: z.string().optional(),
105
+ page_size: z.number().int().min(1).max(10000).default(200),
106
+ cursor: z.string().optional(),
107
+ workflow_id: z.string().optional()
108
+ });
109
+ export const searchOutput = z.object({
110
+ assets: z.array(assetResponse),
111
+ next_cursor: z.string().nullable(),
112
+ total_count: z.number(),
113
+ is_global_search: z.boolean()
114
+ });
115
+ // ── byFilename (GET /api/assets/by-filename/:filename) ───────────
116
+ export const byFilenameInput = z.object({
117
+ filename: z.string().min(1)
118
+ });
119
+ //# sourceMappingURL=assets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/api-schemas/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,oEAAoE;AACpE,yEAAyE;AACzE,uEAAuE;AACvE,sBAAsB;AACtB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,SAAS,EAAE,CAAC,CAAC,MAAM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