@xtrape/capsule-contracts-node 0.1.0-public-review.0 → 0.2.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/README.md CHANGED
@@ -13,9 +13,9 @@ schemas, inferred TypeScript types, enum values, ID helpers, pagination helpers,
13
13
  and protocol error helpers for the Agent/Admin/System wire contracts.
14
14
 
15
15
  > **Package status:** Xtrape Capsule is currently in **Public Review** before
16
- > the `v0.1.0 Public Preview` release. This package is prepared for npm
17
- > publication under the `public-review` dist-tag. APIs, contracts, deployment
18
- > instructions, and SDK interfaces may still change.
16
+ > the `v0.1.0 Public Preview` release. This package is **published to npm** under the
17
+ > `public-review` dist-tag. APIs, contracts, deployment instructions, and SDK
18
+ > interfaces may still change.
19
19
 
20
20
  ## Install
21
21
 
@@ -48,7 +48,7 @@ The package currently exports:
48
48
  - Command schemas: create command, command detail, command result.
49
49
  - Audit and dashboard schemas.
50
50
  - System health/version schemas.
51
- - Helpers: `newId`, `parseSort`, `paginate`, `HttpError`, `ListQueryBase`.
51
+ - Helpers: `parseSort`, `paginate`, `HttpError`, `ListQueryBase`.
52
52
 
53
53
  ## Validate Agent Registration
54
54
 
@@ -155,8 +155,26 @@ const action = ActionDefinitionInputSchema.parse({
155
155
 
156
156
  ## Validate Action Prepare Result
157
157
 
158
- Action prepare responses are delivered as successful Command Results. The
159
- SDK/backend convention is:
158
+ Use `ActionPrepareResultSchema` to validate the action-prepare payload directly:
159
+
160
+ ```ts
161
+ import { ActionPrepareResultSchema } from "@xtrape/capsule-contracts-node";
162
+
163
+ const prepare = ActionPrepareResultSchema.parse({
164
+ initialPayload: { message: "hello" },
165
+ currentState: { service: "ready" },
166
+ inputSchema: {
167
+ type: "object",
168
+ properties: {
169
+ message: { type: "string", default: "hello" },
170
+ },
171
+ },
172
+ });
173
+ ```
174
+
175
+ When reported back to Opstage for an `ACTION_PREPARE` command, this shape is
176
+ placed under `ReportCommandResultRequest.data`. Command result reporting still
177
+ uses `ReportCommandResultRequestSchema`:
160
178
 
161
179
  ```ts
162
180
  import { ReportCommandResultRequestSchema } from "@xtrape/capsule-contracts-node";
@@ -231,16 +249,27 @@ Currently exported codes include:
231
249
 
232
250
  See the OpenAPI contract and docs site for endpoint-specific errors.
233
251
 
234
- ## ID Helpers
252
+ ## ID generation
253
+
254
+ This package validates IDs at the wire boundary (via Zod) but does **not** mint
255
+ them. Until v0.1.x there was a small `newId()` helper plus an `idPrefixes`
256
+ table; both were removed in `0.2.0` to keep the contracts surface focused on
257
+ the wire spec — see [`CHANGELOG.md`](./CHANGELOG.md) and the
258
+ "Breaking changes" section at the top of this README.
259
+
260
+ Consumers that need local ID generation should provide their own factory.
261
+ Example using `nanoid` directly:
235
262
 
236
263
  ```ts
237
- import { newId } from "@xtrape/capsule-contracts-node";
264
+ import { customAlphabet } from "nanoid";
238
265
 
239
- const commandId = newId("cmd_");
266
+ const idBody = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 21);
267
+ const commandId = `cmd_${idBody()}`;
240
268
  ```
241
269
 
242
- Supported prefixes include `wks_`, `usr_`, `agt_`, `tok_`, `svc_`, `hlr_`,
243
- `cfg_`, `act_`, `cmd_`, `crs_`, and `aud_`.
270
+ Documented ID prefixes in use across CE and the Agent SDK include `wks_`,
271
+ `usr_`, `agt_`, `tok_`, `svc_`, `hlr_`, `cfg_`, `act_`, `cmd_`, `crs_`, and
272
+ `aud_`. These are enforced by the Zod schemas via `z.string().startsWith(...)`.
244
273
 
245
274
  ## List Helpers
246
275
 
@@ -262,6 +291,9 @@ const response = paginate(items, query.page, query.pageSize, total);
262
291
  Opstage CE backend validation and protocol handling.
263
292
  - [`xtrape-capsule-agent-node`](https://github.com/xtrape-com/xtrape-capsule-agent-node)
264
293
  — Node embedded Agent SDK request/response types.
294
+ - [`xtrape-capsule-demo`](https://github.com/xtrape-com/xtrape-capsule-demo)
295
+ — End-to-end runnable Capsule Service that imports these schemas through
296
+ the Agent SDK.
265
297
  - Capsule Service implementations that want local validation before reporting to
266
298
  Opstage.
267
299
 
@@ -269,10 +301,43 @@ const response = paginate(items, query.page, query.pageSize, total);
269
301
 
270
302
  | Package | Compatible with |
271
303
  | -------------------------------------- | ---------------------------------------- |
304
+ | `@xtrape/capsule-contracts-node@0.2.x` | Opstage CE `0.2.x` and Agent SDK `0.2.x` |
272
305
  | `@xtrape/capsule-contracts-node@0.1.x` | Opstage CE `0.1.x` and Agent SDK `0.1.x` |
273
306
 
274
- During Public Review and Public Preview, keep CE, Agent SDK, and Contracts on
275
- matching minor versions. The wire protocol may still evolve before `v1.0`.
307
+ Pin matching minor versions across CE, Agent SDK, and Contracts. The wire
308
+ protocol may still evolve before `v1.0`.
309
+
310
+ ## Breaking changes in `0.2.0`
311
+
312
+ - **`newId()` removed.** The helper minted random IDs with a prefix; it was
313
+ never used by CE (entity IDs are minted in the backend). External consumers
314
+ that imported `newId` must wire their own factory — see the
315
+ [ID generation](#id-generation) section above.
316
+ - **`idPrefixes` constant and `IdPrefix` type removed.** Same rationale.
317
+ - **`nanoid` runtime dependency removed** as a consequence. Consumers that
318
+ relied on a transitive `nanoid` install must now add it directly.
319
+
320
+ The wire schemas themselves are **unchanged** between `0.1.x` and `0.2.x`;
321
+ existing `0.1.x` agents continue to validate against a `0.2.x` backend.
322
+
323
+ ## Schema Stability
324
+
325
+ The package follows semver. For Public Review and Public Preview, the
326
+ guarantees per schema group are:
327
+
328
+ | Group | Stability | Notes |
329
+ | ---------------------------------------------------------------------------------------------------------------- | :---------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
330
+ | Status enums (`AgentStatus`, `CapsuleServiceStatus`, `HealthStatus`, `CommandStatus`, `DangerLevel`, `TokenStatus`) | Stable | New values may be added in minor versions; existing values will not be removed before `v1.0`. |
331
+ | Agent ↔ Backend wire schemas (`RegisterAgentRequest`, `AgentHeartbeat*`, `ServiceReport*`, `ReportCommandResult*`) | Evolving | Field shape is stable; additive optional fields may land in minor versions. Required fields will not be added before `v1.0` without a deprecation cycle. |
332
+ | Capsule Service shapes (`CapsuleManifest`, `ReportedService`, `HealthReportInput`, `ConfigItemInput`, `ActionDefinitionInput`) | Evolving | Same policy as wire schemas. |
333
+ | Persisted shapes (`Agent`, `CapsuleService`, `ConfigItem`, `ActionDefinition`, `Command*`, `AuditEvent`, `User`) | Evolving | Track CE storage; safe to consume read-only. |
334
+ | `ActionPrepareResultSchema` | Provisional | Added in `0.1.0-public-review.0`. Field shape may still tighten before `v1.0`. |
335
+ | `Command.type` enum | Evolving | Currently `ACTION_PREPARE` / `ACTION_EXECUTE`. New types may be added. |
336
+ | Error codes (`ErrorCode`) | Evolving | New codes may be added. Existing codes will not change meaning before `v1.0`. |
337
+ | Helpers (`parseSort`, `paginate`, `HttpError`, `ListQueryBase`) | Provisional | Helpful for backend-style consumers but not strictly part of the wire spec; may move to a separate utility package in a future minor. (`newId` / `idPrefixes` / `IdPrefix` were removed in `0.2.0` — see "Breaking changes in `0.2.0`" above.) |
338
+
339
+ **Until `v1.0`**, pin to a single minor across CE / Agent SDK / Contracts.
340
+ Breaking changes will be called out in `CHANGELOG.md`.
276
341
 
277
342
  ## Documentation
278
343
 
package/dist/index.cjs CHANGED
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ActionDefinitionInputSchema: () => ActionDefinitionInputSchema,
24
24
  ActionDefinitionSchema: () => ActionDefinitionSchema,
25
+ ActionPrepareResultSchema: () => ActionPrepareResultSchema,
25
26
  AdminLoginRequestSchema: () => AdminLoginRequestSchema,
26
27
  AdminSessionSchema: () => AdminSessionSchema,
27
28
  AgentHeartbeatRequestSchema: () => AgentHeartbeatRequestSchema,
@@ -43,6 +44,7 @@ __export(index_exports, {
43
44
  CommandSchema: () => CommandSchema,
44
45
  CommandStatus: () => CommandStatus,
45
46
  CommandStatusSchema: () => CommandStatusSchema,
47
+ CommandTypeSchema: () => CommandTypeSchema,
46
48
  ConfigItemInputSchema: () => ConfigItemInputSchema,
47
49
  ConfigItemSchema: () => ConfigItemSchema,
48
50
  CreateActionCommandRequestSchema: () => CreateActionCommandRequestSchema,
@@ -63,6 +65,7 @@ __export(index_exports, {
63
65
  RegistrationTokenSchema: () => RegistrationTokenSchema,
64
66
  ReportCommandResultRequestSchema: () => ReportCommandResultRequestSchema,
65
67
  ReportedServiceSchema: () => ReportedServiceSchema,
68
+ RuntimeKindSchema: () => RuntimeKindSchema,
66
69
  ServiceReportRequestSchema: () => ServiceReportRequestSchema,
67
70
  SystemHealthSchema: () => SystemHealthSchema,
68
71
  SystemVersionSchema: () => SystemVersionSchema,
@@ -70,6 +73,7 @@ __export(index_exports, {
70
73
  UserRole: () => UserRole,
71
74
  UserSchema: () => UserSchema,
72
75
  actionDefinitionInputSchema: () => actionDefinitionInputSchema,
76
+ actionPrepareResultSchema: () => actionPrepareResultSchema,
73
77
  adminLoginRequestSchema: () => adminLoginRequestSchema,
74
78
  agentHeartbeatRequestSchema: () => agentHeartbeatRequestSchema,
75
79
  configItemInputSchema: () => configItemInputSchema,
@@ -77,8 +81,6 @@ __export(index_exports, {
77
81
  createRegistrationTokenRequestSchema: () => createRegistrationTokenRequestSchema,
78
82
  createUserRequestSchema: () => createUserRequestSchema,
79
83
  healthReportInputSchema: () => healthReportInputSchema,
80
- idPrefixes: () => idPrefixes,
81
- newId: () => newId,
82
84
  paginate: () => paginate,
83
85
  parseSort: () => parseSort,
84
86
  registerAgentRequestSchema: () => registerAgentRequestSchema,
@@ -90,7 +92,6 @@ __export(index_exports, {
90
92
  z: () => import_zod.z
91
93
  });
92
94
  module.exports = __toCommonJS(index_exports);
93
- var import_nanoid = require("nanoid");
94
95
  var import_zod = require("zod");
95
96
  var AgentStatus = ["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"];
96
97
  var CapsuleServiceStatus = ["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"];
@@ -115,11 +116,6 @@ var ErrorCode = {
115
116
  AGENT_REVOKED: "AGENT_REVOKED",
116
117
  AGENT_DISABLED: "AGENT_DISABLED"
117
118
  };
118
- var idPrefixes = ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
119
- var NANO = (0, import_nanoid.customAlphabet)("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-", 21);
120
- function newId(prefix) {
121
- return `${prefix}${NANO()}`;
122
- }
123
119
  var AnyJson = import_zod.z.record(import_zod.z.any());
124
120
  var AgentStatusSchema = import_zod.z.enum(AgentStatus);
125
121
  var CapsuleServiceStatusSchema = import_zod.z.enum(CapsuleServiceStatus);
@@ -150,7 +146,8 @@ var ReportedServiceSchema = import_zod.z.object({ code: import_zod.z.string().mi
150
146
  var reportedServiceSchema = ReportedServiceSchema;
151
147
  var ServiceReportRequestSchema = import_zod.z.object({ services: import_zod.z.array(ReportedServiceSchema).min(1) });
152
148
  var serviceReportRequestSchema = ServiceReportRequestSchema;
153
- var RegisterAgentRequestSchema = import_zod.z.object({ registrationToken: import_zod.z.string().startsWith("opstage_reg_"), agent: import_zod.z.object({ code: import_zod.z.string(), name: import_zod.z.string().optional(), mode: import_zod.z.literal("embedded"), runtime: import_zod.z.string().optional() }), service: ReportedServiceSchema.optional() });
149
+ var RuntimeKindSchema = import_zod.z.enum(["nodejs", "java", "python", "go", "other"]);
150
+ var RegisterAgentRequestSchema = import_zod.z.object({ registrationToken: import_zod.z.string().startsWith("opstage_reg_"), agent: import_zod.z.object({ code: import_zod.z.string(), name: import_zod.z.string().optional(), mode: import_zod.z.literal("embedded"), runtime: RuntimeKindSchema.optional() }), service: ReportedServiceSchema.optional() });
154
151
  var registerAgentRequestSchema = RegisterAgentRequestSchema;
155
152
  var RegisterAgentResponseSchema = import_zod.z.object({ agentId: import_zod.z.string().startsWith("agt_"), agentToken: import_zod.z.string().startsWith("opstage_agent_"), heartbeatIntervalSeconds: import_zod.z.number().int(), commandPollIntervalSeconds: import_zod.z.number().int() });
156
153
  var AgentHeartbeatResponseSchema = import_zod.z.object({ heartbeatIntervalSeconds: import_zod.z.number().int(), commandPollIntervalSeconds: import_zod.z.number().int() });
@@ -161,9 +158,17 @@ var HealthReportSchema = import_zod.z.object({ id: import_zod.z.string().startsW
161
158
  var ConfigItemSchema = import_zod.z.object({ id: import_zod.z.string().startsWith("cfg_"), serviceId: import_zod.z.string().startsWith("svc_"), key: import_zod.z.string(), label: import_zod.z.string().nullable().optional(), type: import_zod.z.string(), source: import_zod.z.string().nullable().optional(), editable: import_zod.z.boolean().default(false), sensitive: import_zod.z.boolean(), valuePreview: import_zod.z.string().nullable().optional(), defaultValue: import_zod.z.string().nullable().optional(), secretRef: import_zod.z.string().nullable().optional() });
162
159
  var ActionDefinitionSchema = import_zod.z.object({ id: import_zod.z.string().startsWith("act_"), serviceId: import_zod.z.string().startsWith("svc_"), name: import_zod.z.string(), label: import_zod.z.string(), description: import_zod.z.string().nullable().optional(), dangerLevel: import_zod.z.enum(DangerLevel), requiresConfirmation: import_zod.z.boolean(), category: import_zod.z.string().optional(), order: import_zod.z.number().int().optional(), inputSchema: AnyJson.optional(), outputSchema: AnyJson.optional(), timeoutSeconds: import_zod.z.number().int().optional() });
163
160
  var CapsuleServiceDetailSchema = CapsuleServiceSchema.extend({ manifest: AnyJson.optional(), health: HealthReportSchema.nullable().optional(), configs: import_zod.z.array(ConfigItemSchema).optional(), actions: import_zod.z.array(ActionDefinitionSchema).optional() });
161
+ var ActionPrepareResultSchema = import_zod.z.object({
162
+ action: AnyJson.optional(),
163
+ inputSchema: AnyJson.optional(),
164
+ initialPayload: AnyJson.optional(),
165
+ currentState: AnyJson.optional()
166
+ });
167
+ var actionPrepareResultSchema = ActionPrepareResultSchema;
164
168
  var CreateActionCommandRequestSchema = import_zod.z.object({ payload: AnyJson.optional(), confirmation: import_zod.z.boolean().optional() });
165
169
  var createActionCommandRequestSchema = CreateActionCommandRequestSchema;
166
- var CommandSchema = import_zod.z.object({ id: import_zod.z.string().startsWith("cmd_"), agentId: import_zod.z.string().startsWith("agt_"), serviceId: import_zod.z.string().startsWith("svc_"), type: import_zod.z.enum(["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]), actionName: import_zod.z.string(), status: CommandStatusSchema, payload: AnyJson.optional(), createdByUserId: import_zod.z.string().startsWith("usr_").nullable().optional(), createdAt: import_zod.z.string(), startedAt: import_zod.z.string().nullable().optional(), completedAt: import_zod.z.string().nullable().optional(), expiresAt: import_zod.z.string().nullable().optional() });
170
+ var CommandTypeSchema = import_zod.z.enum(["ACTION_PREPARE", "ACTION_EXECUTE"]);
171
+ var CommandSchema = import_zod.z.object({ id: import_zod.z.string().startsWith("cmd_"), agentId: import_zod.z.string().startsWith("agt_"), serviceId: import_zod.z.string().startsWith("svc_"), type: CommandTypeSchema, actionName: import_zod.z.string(), status: CommandStatusSchema, payload: AnyJson.optional(), createdByUserId: import_zod.z.string().startsWith("usr_").nullable().optional(), createdAt: import_zod.z.string(), startedAt: import_zod.z.string().nullable().optional(), completedAt: import_zod.z.string().nullable().optional(), expiresAt: import_zod.z.string().nullable().optional() });
167
172
  var ReportCommandResultRequestSchema = import_zod.z.object({ success: import_zod.z.boolean(), message: import_zod.z.string().optional(), data: AnyJson.optional(), error: AnyJson.optional(), startedAt: import_zod.z.string().optional(), finishedAt: import_zod.z.string().optional() });
168
173
  var reportCommandResultRequestSchema = ReportCommandResultRequestSchema;
169
174
  var CommandResultSchema = import_zod.z.object({ id: import_zod.z.string().startsWith("crs_"), commandId: import_zod.z.string().startsWith("cmd_"), success: import_zod.z.boolean(), message: import_zod.z.string().nullable().optional(), data: AnyJson.optional(), error: AnyJson.optional(), reportedAt: import_zod.z.string() });
@@ -202,6 +207,7 @@ function paginate(items, page, pageSize, total) {
202
207
  0 && (module.exports = {
203
208
  ActionDefinitionInputSchema,
204
209
  ActionDefinitionSchema,
210
+ ActionPrepareResultSchema,
205
211
  AdminLoginRequestSchema,
206
212
  AdminSessionSchema,
207
213
  AgentHeartbeatRequestSchema,
@@ -223,6 +229,7 @@ function paginate(items, page, pageSize, total) {
223
229
  CommandSchema,
224
230
  CommandStatus,
225
231
  CommandStatusSchema,
232
+ CommandTypeSchema,
226
233
  ConfigItemInputSchema,
227
234
  ConfigItemSchema,
228
235
  CreateActionCommandRequestSchema,
@@ -243,6 +250,7 @@ function paginate(items, page, pageSize, total) {
243
250
  RegistrationTokenSchema,
244
251
  ReportCommandResultRequestSchema,
245
252
  ReportedServiceSchema,
253
+ RuntimeKindSchema,
246
254
  ServiceReportRequestSchema,
247
255
  SystemHealthSchema,
248
256
  SystemVersionSchema,
@@ -250,6 +258,7 @@ function paginate(items, page, pageSize, total) {
250
258
  UserRole,
251
259
  UserSchema,
252
260
  actionDefinitionInputSchema,
261
+ actionPrepareResultSchema,
253
262
  adminLoginRequestSchema,
254
263
  agentHeartbeatRequestSchema,
255
264
  configItemInputSchema,
@@ -257,8 +266,6 @@ function paginate(items, page, pageSize, total) {
257
266
  createRegistrationTokenRequestSchema,
258
267
  createUserRequestSchema,
259
268
  healthReportInputSchema,
260
- idPrefixes,
261
- newId,
262
269
  paginate,
263
270
  parseSort,
264
271
  registerAgentRequestSchema,
package/dist/index.d.cts CHANGED
@@ -33,10 +33,6 @@ declare const ErrorCode: {
33
33
  readonly AGENT_DISABLED: "AGENT_DISABLED";
34
34
  };
35
35
  type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
36
- declare const idPrefixes: readonly ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
37
- type IdPrefix = typeof idPrefixes[number];
38
-
39
- declare function newId<P extends IdPrefix>(prefix: P): `${P}${string}`;
40
36
  declare const AnyJson: z.ZodRecord<z.ZodString, z.ZodAny>;
41
37
  declare const AgentStatusSchema: z.ZodEnum<["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"]>;
42
38
  declare const CapsuleServiceStatusSchema: z.ZodEnum<["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"]>;
@@ -1244,23 +1240,25 @@ declare const serviceReportRequestSchema: z.ZodObject<{
1244
1240
  }[] | undefined;
1245
1241
  }[];
1246
1242
  }>;
1243
+ declare const RuntimeKindSchema: z.ZodEnum<["nodejs", "java", "python", "go", "other"]>;
1244
+ type RuntimeKind = z.infer<typeof RuntimeKindSchema>;
1247
1245
  declare const RegisterAgentRequestSchema: z.ZodObject<{
1248
1246
  registrationToken: z.ZodString;
1249
1247
  agent: z.ZodObject<{
1250
1248
  code: z.ZodString;
1251
1249
  name: z.ZodOptional<z.ZodString>;
1252
1250
  mode: z.ZodLiteral<"embedded">;
1253
- runtime: z.ZodOptional<z.ZodString>;
1251
+ runtime: z.ZodOptional<z.ZodEnum<["nodejs", "java", "python", "go", "other"]>>;
1254
1252
  }, "strip", z.ZodTypeAny, {
1255
1253
  code: string;
1256
1254
  mode: "embedded";
1257
1255
  name?: string | undefined;
1258
- runtime?: string | undefined;
1256
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1259
1257
  }, {
1260
1258
  code: string;
1261
1259
  mode: "embedded";
1262
1260
  name?: string | undefined;
1263
- runtime?: string | undefined;
1261
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1264
1262
  }>;
1265
1263
  service: z.ZodOptional<z.ZodObject<{
1266
1264
  code: z.ZodString;
@@ -1424,7 +1422,7 @@ declare const RegisterAgentRequestSchema: z.ZodObject<{
1424
1422
  code: string;
1425
1423
  mode: "embedded";
1426
1424
  name?: string | undefined;
1427
- runtime?: string | undefined;
1425
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1428
1426
  };
1429
1427
  service?: {
1430
1428
  code: string;
@@ -1468,7 +1466,7 @@ declare const RegisterAgentRequestSchema: z.ZodObject<{
1468
1466
  code: string;
1469
1467
  mode: "embedded";
1470
1468
  name?: string | undefined;
1471
- runtime?: string | undefined;
1469
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1472
1470
  };
1473
1471
  service?: {
1474
1472
  code: string;
@@ -1514,17 +1512,17 @@ declare const registerAgentRequestSchema: z.ZodObject<{
1514
1512
  code: z.ZodString;
1515
1513
  name: z.ZodOptional<z.ZodString>;
1516
1514
  mode: z.ZodLiteral<"embedded">;
1517
- runtime: z.ZodOptional<z.ZodString>;
1515
+ runtime: z.ZodOptional<z.ZodEnum<["nodejs", "java", "python", "go", "other"]>>;
1518
1516
  }, "strip", z.ZodTypeAny, {
1519
1517
  code: string;
1520
1518
  mode: "embedded";
1521
1519
  name?: string | undefined;
1522
- runtime?: string | undefined;
1520
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1523
1521
  }, {
1524
1522
  code: string;
1525
1523
  mode: "embedded";
1526
1524
  name?: string | undefined;
1527
- runtime?: string | undefined;
1525
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1528
1526
  }>;
1529
1527
  service: z.ZodOptional<z.ZodObject<{
1530
1528
  code: z.ZodString;
@@ -1688,7 +1686,7 @@ declare const registerAgentRequestSchema: z.ZodObject<{
1688
1686
  code: string;
1689
1687
  mode: "embedded";
1690
1688
  name?: string | undefined;
1691
- runtime?: string | undefined;
1689
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1692
1690
  };
1693
1691
  service?: {
1694
1692
  code: string;
@@ -1732,7 +1730,7 @@ declare const registerAgentRequestSchema: z.ZodObject<{
1732
1730
  code: string;
1733
1731
  mode: "embedded";
1734
1732
  name?: string | undefined;
1735
- runtime?: string | undefined;
1733
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1736
1734
  };
1737
1735
  service?: {
1738
1736
  code: string;
@@ -2231,6 +2229,45 @@ declare const CapsuleServiceDetailSchema: z.ZodObject<{
2231
2229
  lastHealthAt?: string | null | undefined;
2232
2230
  }>;
2233
2231
  type CapsuleServiceDetail = z.infer<typeof CapsuleServiceDetailSchema>;
2232
+ /**
2233
+ * Shape returned by an Agent's action `prepare` handler when responding to an
2234
+ * `ACTION_PREPARE` command. Used by the SDK as the contract between
2235
+ * `prepare()` callbacks and the backend; the backend forwards it to the UI as
2236
+ * the `data` field of the prepare command result.
2237
+ */
2238
+ declare const ActionPrepareResultSchema: z.ZodObject<{
2239
+ action: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2240
+ inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2241
+ initialPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2242
+ currentState: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2243
+ }, "strip", z.ZodTypeAny, {
2244
+ inputSchema?: Record<string, any> | undefined;
2245
+ action?: Record<string, any> | undefined;
2246
+ initialPayload?: Record<string, any> | undefined;
2247
+ currentState?: Record<string, any> | undefined;
2248
+ }, {
2249
+ inputSchema?: Record<string, any> | undefined;
2250
+ action?: Record<string, any> | undefined;
2251
+ initialPayload?: Record<string, any> | undefined;
2252
+ currentState?: Record<string, any> | undefined;
2253
+ }>;
2254
+ type ActionPrepareResult = z.infer<typeof ActionPrepareResultSchema>;
2255
+ declare const actionPrepareResultSchema: z.ZodObject<{
2256
+ action: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2257
+ inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2258
+ initialPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2259
+ currentState: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2260
+ }, "strip", z.ZodTypeAny, {
2261
+ inputSchema?: Record<string, any> | undefined;
2262
+ action?: Record<string, any> | undefined;
2263
+ initialPayload?: Record<string, any> | undefined;
2264
+ currentState?: Record<string, any> | undefined;
2265
+ }, {
2266
+ inputSchema?: Record<string, any> | undefined;
2267
+ action?: Record<string, any> | undefined;
2268
+ initialPayload?: Record<string, any> | undefined;
2269
+ currentState?: Record<string, any> | undefined;
2270
+ }>;
2234
2271
  declare const CreateActionCommandRequestSchema: z.ZodObject<{
2235
2272
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2236
2273
  confirmation: z.ZodOptional<z.ZodBoolean>;
@@ -2252,11 +2289,13 @@ declare const createActionCommandRequestSchema: z.ZodObject<{
2252
2289
  payload?: Record<string, any> | undefined;
2253
2290
  confirmation?: boolean | undefined;
2254
2291
  }>;
2292
+ declare const CommandTypeSchema: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2293
+ type CommandType = z.infer<typeof CommandTypeSchema>;
2255
2294
  declare const CommandSchema: z.ZodObject<{
2256
2295
  id: z.ZodString;
2257
2296
  agentId: z.ZodString;
2258
2297
  serviceId: z.ZodString;
2259
- type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]>;
2298
+ type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2260
2299
  actionName: z.ZodString;
2261
2300
  status: z.ZodEnum<["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "EXPIRED", "CANCELLED"]>;
2262
2301
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -2266,7 +2305,7 @@ declare const CommandSchema: z.ZodObject<{
2266
2305
  completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2267
2306
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2268
2307
  }, "strip", z.ZodTypeAny, {
2269
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2308
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2270
2309
  id: string;
2271
2310
  createdAt: string;
2272
2311
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2279,7 +2318,7 @@ declare const CommandSchema: z.ZodObject<{
2279
2318
  startedAt?: string | null | undefined;
2280
2319
  completedAt?: string | null | undefined;
2281
2320
  }, {
2282
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2321
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2283
2322
  id: string;
2284
2323
  createdAt: string;
2285
2324
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2368,7 +2407,7 @@ declare const CommandDetailSchema: z.ZodObject<{
2368
2407
  id: z.ZodString;
2369
2408
  agentId: z.ZodString;
2370
2409
  serviceId: z.ZodString;
2371
- type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]>;
2410
+ type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2372
2411
  actionName: z.ZodString;
2373
2412
  status: z.ZodEnum<["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "EXPIRED", "CANCELLED"]>;
2374
2413
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -2404,7 +2443,7 @@ declare const CommandDetailSchema: z.ZodObject<{
2404
2443
  error?: Record<string, any> | undefined;
2405
2444
  }>>>;
2406
2445
  }, "strip", z.ZodTypeAny, {
2407
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2446
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2408
2447
  id: string;
2409
2448
  createdAt: string;
2410
2449
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2426,7 +2465,7 @@ declare const CommandDetailSchema: z.ZodObject<{
2426
2465
  error?: Record<string, any> | undefined;
2427
2466
  } | null | undefined;
2428
2467
  }, {
2429
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2468
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2430
2469
  id: string;
2431
2470
  createdAt: string;
2432
2471
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2463,9 +2502,9 @@ declare const AuditEventSchema: z.ZodObject<{
2463
2502
  }, "strip", z.ZodTypeAny, {
2464
2503
  id: string;
2465
2504
  createdAt: string;
2505
+ action: string;
2466
2506
  result: "SUCCESS" | "FAILURE";
2467
2507
  actorType: "USER" | "AGENT" | "SYSTEM";
2468
- action: string;
2469
2508
  message?: string | null | undefined;
2470
2509
  actorId?: string | null | undefined;
2471
2510
  targetType?: string | null | undefined;
@@ -2474,9 +2513,9 @@ declare const AuditEventSchema: z.ZodObject<{
2474
2513
  }, {
2475
2514
  id: string;
2476
2515
  createdAt: string;
2516
+ action: string;
2477
2517
  result: "SUCCESS" | "FAILURE";
2478
2518
  actorType: "USER" | "AGENT" | "SYSTEM";
2479
- action: string;
2480
2519
  message?: string | null | undefined;
2481
2520
  actorId?: string | null | undefined;
2482
2521
  targetType?: string | null | undefined;
@@ -2492,7 +2531,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2492
2531
  id: z.ZodString;
2493
2532
  agentId: z.ZodString;
2494
2533
  serviceId: z.ZodString;
2495
- type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]>;
2534
+ type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2496
2535
  actionName: z.ZodString;
2497
2536
  status: z.ZodEnum<["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "EXPIRED", "CANCELLED"]>;
2498
2537
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -2502,7 +2541,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2502
2541
  completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2503
2542
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2504
2543
  }, "strip", z.ZodTypeAny, {
2505
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2544
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2506
2545
  id: string;
2507
2546
  createdAt: string;
2508
2547
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2515,7 +2554,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2515
2554
  startedAt?: string | null | undefined;
2516
2555
  completedAt?: string | null | undefined;
2517
2556
  }, {
2518
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2557
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2519
2558
  id: string;
2520
2559
  createdAt: string;
2521
2560
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2542,9 +2581,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2542
2581
  }, "strip", z.ZodTypeAny, {
2543
2582
  id: string;
2544
2583
  createdAt: string;
2584
+ action: string;
2545
2585
  result: "SUCCESS" | "FAILURE";
2546
2586
  actorType: "USER" | "AGENT" | "SYSTEM";
2547
- action: string;
2548
2587
  message?: string | null | undefined;
2549
2588
  actorId?: string | null | undefined;
2550
2589
  targetType?: string | null | undefined;
@@ -2553,9 +2592,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2553
2592
  }, {
2554
2593
  id: string;
2555
2594
  createdAt: string;
2595
+ action: string;
2556
2596
  result: "SUCCESS" | "FAILURE";
2557
2597
  actorType: "USER" | "AGENT" | "SYSTEM";
2558
- action: string;
2559
2598
  message?: string | null | undefined;
2560
2599
  actorId?: string | null | undefined;
2561
2600
  targetType?: string | null | undefined;
@@ -2567,7 +2606,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2567
2606
  serviceCounts: Record<string, number>;
2568
2607
  commandCounts: Record<string, number>;
2569
2608
  recentCommands?: {
2570
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2609
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2571
2610
  id: string;
2572
2611
  createdAt: string;
2573
2612
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2583,9 +2622,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2583
2622
  recentAuditEvents?: {
2584
2623
  id: string;
2585
2624
  createdAt: string;
2625
+ action: string;
2586
2626
  result: "SUCCESS" | "FAILURE";
2587
2627
  actorType: "USER" | "AGENT" | "SYSTEM";
2588
- action: string;
2589
2628
  message?: string | null | undefined;
2590
2629
  actorId?: string | null | undefined;
2591
2630
  targetType?: string | null | undefined;
@@ -2597,7 +2636,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2597
2636
  serviceCounts: Record<string, number>;
2598
2637
  commandCounts: Record<string, number>;
2599
2638
  recentCommands?: {
2600
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2639
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2601
2640
  id: string;
2602
2641
  createdAt: string;
2603
2642
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2613,9 +2652,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2613
2652
  recentAuditEvents?: {
2614
2653
  id: string;
2615
2654
  createdAt: string;
2655
+ action: string;
2616
2656
  result: "SUCCESS" | "FAILURE";
2617
2657
  actorType: "USER" | "AGENT" | "SYSTEM";
2618
- action: string;
2619
2658
  message?: string | null | undefined;
2620
2659
  actorId?: string | null | undefined;
2621
2660
  targetType?: string | null | undefined;
@@ -2738,4 +2777,4 @@ declare function paginate<T>(items: T[], page: number, pageSize: number, total:
2738
2777
  };
2739
2778
  };
2740
2779
 
2741
- export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError, type IdPrefix, ListQueryBase, type Pagination, type RegisterAgentRequest, RegisterAgentRequestSchema, type RegisterAgentResponse, RegisterAgentResponseSchema, type RegistrationToken, RegistrationTokenSchema, type ReportCommandResultRequest, ReportCommandResultRequestSchema, type ReportedService, ReportedServiceSchema, type ResetUserPasswordRequest, type ServiceReportRequest, ServiceReportRequestSchema, type SuccessEnvelope, type SystemHealth, SystemHealthSchema, type SystemVersion, SystemVersionSchema, TokenStatus, type UpdateUserRequest, type User, UserRole, UserSchema, actionDefinitionInputSchema, adminLoginRequestSchema, agentHeartbeatRequestSchema, configItemInputSchema, createActionCommandRequestSchema, createRegistrationTokenRequestSchema, createUserRequestSchema, healthReportInputSchema, idPrefixes, newId, paginate, parseSort, registerAgentRequestSchema, reportCommandResultRequestSchema, reportedServiceSchema, resetUserPasswordRequestSchema, serviceReportRequestSchema, updateUserRequestSchema };
2780
+ export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type ActionPrepareResult, ActionPrepareResultSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type CommandType, CommandTypeSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError, ListQueryBase, type Pagination, type RegisterAgentRequest, RegisterAgentRequestSchema, type RegisterAgentResponse, RegisterAgentResponseSchema, type RegistrationToken, RegistrationTokenSchema, type ReportCommandResultRequest, ReportCommandResultRequestSchema, type ReportedService, ReportedServiceSchema, type ResetUserPasswordRequest, type RuntimeKind, RuntimeKindSchema, type ServiceReportRequest, ServiceReportRequestSchema, type SuccessEnvelope, type SystemHealth, SystemHealthSchema, type SystemVersion, SystemVersionSchema, TokenStatus, type UpdateUserRequest, type User, UserRole, UserSchema, actionDefinitionInputSchema, actionPrepareResultSchema, adminLoginRequestSchema, agentHeartbeatRequestSchema, configItemInputSchema, createActionCommandRequestSchema, createRegistrationTokenRequestSchema, createUserRequestSchema, healthReportInputSchema, paginate, parseSort, registerAgentRequestSchema, reportCommandResultRequestSchema, reportedServiceSchema, resetUserPasswordRequestSchema, serviceReportRequestSchema, updateUserRequestSchema };
package/dist/index.d.ts CHANGED
@@ -33,10 +33,6 @@ declare const ErrorCode: {
33
33
  readonly AGENT_DISABLED: "AGENT_DISABLED";
34
34
  };
35
35
  type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
36
- declare const idPrefixes: readonly ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
37
- type IdPrefix = typeof idPrefixes[number];
38
-
39
- declare function newId<P extends IdPrefix>(prefix: P): `${P}${string}`;
40
36
  declare const AnyJson: z.ZodRecord<z.ZodString, z.ZodAny>;
41
37
  declare const AgentStatusSchema: z.ZodEnum<["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"]>;
42
38
  declare const CapsuleServiceStatusSchema: z.ZodEnum<["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"]>;
@@ -1244,23 +1240,25 @@ declare const serviceReportRequestSchema: z.ZodObject<{
1244
1240
  }[] | undefined;
1245
1241
  }[];
1246
1242
  }>;
1243
+ declare const RuntimeKindSchema: z.ZodEnum<["nodejs", "java", "python", "go", "other"]>;
1244
+ type RuntimeKind = z.infer<typeof RuntimeKindSchema>;
1247
1245
  declare const RegisterAgentRequestSchema: z.ZodObject<{
1248
1246
  registrationToken: z.ZodString;
1249
1247
  agent: z.ZodObject<{
1250
1248
  code: z.ZodString;
1251
1249
  name: z.ZodOptional<z.ZodString>;
1252
1250
  mode: z.ZodLiteral<"embedded">;
1253
- runtime: z.ZodOptional<z.ZodString>;
1251
+ runtime: z.ZodOptional<z.ZodEnum<["nodejs", "java", "python", "go", "other"]>>;
1254
1252
  }, "strip", z.ZodTypeAny, {
1255
1253
  code: string;
1256
1254
  mode: "embedded";
1257
1255
  name?: string | undefined;
1258
- runtime?: string | undefined;
1256
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1259
1257
  }, {
1260
1258
  code: string;
1261
1259
  mode: "embedded";
1262
1260
  name?: string | undefined;
1263
- runtime?: string | undefined;
1261
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1264
1262
  }>;
1265
1263
  service: z.ZodOptional<z.ZodObject<{
1266
1264
  code: z.ZodString;
@@ -1424,7 +1422,7 @@ declare const RegisterAgentRequestSchema: z.ZodObject<{
1424
1422
  code: string;
1425
1423
  mode: "embedded";
1426
1424
  name?: string | undefined;
1427
- runtime?: string | undefined;
1425
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1428
1426
  };
1429
1427
  service?: {
1430
1428
  code: string;
@@ -1468,7 +1466,7 @@ declare const RegisterAgentRequestSchema: z.ZodObject<{
1468
1466
  code: string;
1469
1467
  mode: "embedded";
1470
1468
  name?: string | undefined;
1471
- runtime?: string | undefined;
1469
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1472
1470
  };
1473
1471
  service?: {
1474
1472
  code: string;
@@ -1514,17 +1512,17 @@ declare const registerAgentRequestSchema: z.ZodObject<{
1514
1512
  code: z.ZodString;
1515
1513
  name: z.ZodOptional<z.ZodString>;
1516
1514
  mode: z.ZodLiteral<"embedded">;
1517
- runtime: z.ZodOptional<z.ZodString>;
1515
+ runtime: z.ZodOptional<z.ZodEnum<["nodejs", "java", "python", "go", "other"]>>;
1518
1516
  }, "strip", z.ZodTypeAny, {
1519
1517
  code: string;
1520
1518
  mode: "embedded";
1521
1519
  name?: string | undefined;
1522
- runtime?: string | undefined;
1520
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1523
1521
  }, {
1524
1522
  code: string;
1525
1523
  mode: "embedded";
1526
1524
  name?: string | undefined;
1527
- runtime?: string | undefined;
1525
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1528
1526
  }>;
1529
1527
  service: z.ZodOptional<z.ZodObject<{
1530
1528
  code: z.ZodString;
@@ -1688,7 +1686,7 @@ declare const registerAgentRequestSchema: z.ZodObject<{
1688
1686
  code: string;
1689
1687
  mode: "embedded";
1690
1688
  name?: string | undefined;
1691
- runtime?: string | undefined;
1689
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1692
1690
  };
1693
1691
  service?: {
1694
1692
  code: string;
@@ -1732,7 +1730,7 @@ declare const registerAgentRequestSchema: z.ZodObject<{
1732
1730
  code: string;
1733
1731
  mode: "embedded";
1734
1732
  name?: string | undefined;
1735
- runtime?: string | undefined;
1733
+ runtime?: "nodejs" | "java" | "python" | "go" | "other" | undefined;
1736
1734
  };
1737
1735
  service?: {
1738
1736
  code: string;
@@ -2231,6 +2229,45 @@ declare const CapsuleServiceDetailSchema: z.ZodObject<{
2231
2229
  lastHealthAt?: string | null | undefined;
2232
2230
  }>;
2233
2231
  type CapsuleServiceDetail = z.infer<typeof CapsuleServiceDetailSchema>;
2232
+ /**
2233
+ * Shape returned by an Agent's action `prepare` handler when responding to an
2234
+ * `ACTION_PREPARE` command. Used by the SDK as the contract between
2235
+ * `prepare()` callbacks and the backend; the backend forwards it to the UI as
2236
+ * the `data` field of the prepare command result.
2237
+ */
2238
+ declare const ActionPrepareResultSchema: z.ZodObject<{
2239
+ action: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2240
+ inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2241
+ initialPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2242
+ currentState: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2243
+ }, "strip", z.ZodTypeAny, {
2244
+ inputSchema?: Record<string, any> | undefined;
2245
+ action?: Record<string, any> | undefined;
2246
+ initialPayload?: Record<string, any> | undefined;
2247
+ currentState?: Record<string, any> | undefined;
2248
+ }, {
2249
+ inputSchema?: Record<string, any> | undefined;
2250
+ action?: Record<string, any> | undefined;
2251
+ initialPayload?: Record<string, any> | undefined;
2252
+ currentState?: Record<string, any> | undefined;
2253
+ }>;
2254
+ type ActionPrepareResult = z.infer<typeof ActionPrepareResultSchema>;
2255
+ declare const actionPrepareResultSchema: z.ZodObject<{
2256
+ action: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2257
+ inputSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2258
+ initialPayload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2259
+ currentState: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2260
+ }, "strip", z.ZodTypeAny, {
2261
+ inputSchema?: Record<string, any> | undefined;
2262
+ action?: Record<string, any> | undefined;
2263
+ initialPayload?: Record<string, any> | undefined;
2264
+ currentState?: Record<string, any> | undefined;
2265
+ }, {
2266
+ inputSchema?: Record<string, any> | undefined;
2267
+ action?: Record<string, any> | undefined;
2268
+ initialPayload?: Record<string, any> | undefined;
2269
+ currentState?: Record<string, any> | undefined;
2270
+ }>;
2234
2271
  declare const CreateActionCommandRequestSchema: z.ZodObject<{
2235
2272
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
2236
2273
  confirmation: z.ZodOptional<z.ZodBoolean>;
@@ -2252,11 +2289,13 @@ declare const createActionCommandRequestSchema: z.ZodObject<{
2252
2289
  payload?: Record<string, any> | undefined;
2253
2290
  confirmation?: boolean | undefined;
2254
2291
  }>;
2292
+ declare const CommandTypeSchema: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2293
+ type CommandType = z.infer<typeof CommandTypeSchema>;
2255
2294
  declare const CommandSchema: z.ZodObject<{
2256
2295
  id: z.ZodString;
2257
2296
  agentId: z.ZodString;
2258
2297
  serviceId: z.ZodString;
2259
- type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]>;
2298
+ type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2260
2299
  actionName: z.ZodString;
2261
2300
  status: z.ZodEnum<["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "EXPIRED", "CANCELLED"]>;
2262
2301
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -2266,7 +2305,7 @@ declare const CommandSchema: z.ZodObject<{
2266
2305
  completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2267
2306
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2268
2307
  }, "strip", z.ZodTypeAny, {
2269
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2308
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2270
2309
  id: string;
2271
2310
  createdAt: string;
2272
2311
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2279,7 +2318,7 @@ declare const CommandSchema: z.ZodObject<{
2279
2318
  startedAt?: string | null | undefined;
2280
2319
  completedAt?: string | null | undefined;
2281
2320
  }, {
2282
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2321
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2283
2322
  id: string;
2284
2323
  createdAt: string;
2285
2324
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2368,7 +2407,7 @@ declare const CommandDetailSchema: z.ZodObject<{
2368
2407
  id: z.ZodString;
2369
2408
  agentId: z.ZodString;
2370
2409
  serviceId: z.ZodString;
2371
- type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]>;
2410
+ type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2372
2411
  actionName: z.ZodString;
2373
2412
  status: z.ZodEnum<["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "EXPIRED", "CANCELLED"]>;
2374
2413
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -2404,7 +2443,7 @@ declare const CommandDetailSchema: z.ZodObject<{
2404
2443
  error?: Record<string, any> | undefined;
2405
2444
  }>>>;
2406
2445
  }, "strip", z.ZodTypeAny, {
2407
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2446
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2408
2447
  id: string;
2409
2448
  createdAt: string;
2410
2449
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2426,7 +2465,7 @@ declare const CommandDetailSchema: z.ZodObject<{
2426
2465
  error?: Record<string, any> | undefined;
2427
2466
  } | null | undefined;
2428
2467
  }, {
2429
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2468
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2430
2469
  id: string;
2431
2470
  createdAt: string;
2432
2471
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2463,9 +2502,9 @@ declare const AuditEventSchema: z.ZodObject<{
2463
2502
  }, "strip", z.ZodTypeAny, {
2464
2503
  id: string;
2465
2504
  createdAt: string;
2505
+ action: string;
2466
2506
  result: "SUCCESS" | "FAILURE";
2467
2507
  actorType: "USER" | "AGENT" | "SYSTEM";
2468
- action: string;
2469
2508
  message?: string | null | undefined;
2470
2509
  actorId?: string | null | undefined;
2471
2510
  targetType?: string | null | undefined;
@@ -2474,9 +2513,9 @@ declare const AuditEventSchema: z.ZodObject<{
2474
2513
  }, {
2475
2514
  id: string;
2476
2515
  createdAt: string;
2516
+ action: string;
2477
2517
  result: "SUCCESS" | "FAILURE";
2478
2518
  actorType: "USER" | "AGENT" | "SYSTEM";
2479
- action: string;
2480
2519
  message?: string | null | undefined;
2481
2520
  actorId?: string | null | undefined;
2482
2521
  targetType?: string | null | undefined;
@@ -2492,7 +2531,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2492
2531
  id: z.ZodString;
2493
2532
  agentId: z.ZodString;
2494
2533
  serviceId: z.ZodString;
2495
- type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]>;
2534
+ type: z.ZodEnum<["ACTION_PREPARE", "ACTION_EXECUTE"]>;
2496
2535
  actionName: z.ZodString;
2497
2536
  status: z.ZodEnum<["PENDING", "RUNNING", "SUCCEEDED", "FAILED", "EXPIRED", "CANCELLED"]>;
2498
2537
  payload: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
@@ -2502,7 +2541,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2502
2541
  completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2503
2542
  expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2504
2543
  }, "strip", z.ZodTypeAny, {
2505
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2544
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2506
2545
  id: string;
2507
2546
  createdAt: string;
2508
2547
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2515,7 +2554,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2515
2554
  startedAt?: string | null | undefined;
2516
2555
  completedAt?: string | null | undefined;
2517
2556
  }, {
2518
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2557
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2519
2558
  id: string;
2520
2559
  createdAt: string;
2521
2560
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2542,9 +2581,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2542
2581
  }, "strip", z.ZodTypeAny, {
2543
2582
  id: string;
2544
2583
  createdAt: string;
2584
+ action: string;
2545
2585
  result: "SUCCESS" | "FAILURE";
2546
2586
  actorType: "USER" | "AGENT" | "SYSTEM";
2547
- action: string;
2548
2587
  message?: string | null | undefined;
2549
2588
  actorId?: string | null | undefined;
2550
2589
  targetType?: string | null | undefined;
@@ -2553,9 +2592,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2553
2592
  }, {
2554
2593
  id: string;
2555
2594
  createdAt: string;
2595
+ action: string;
2556
2596
  result: "SUCCESS" | "FAILURE";
2557
2597
  actorType: "USER" | "AGENT" | "SYSTEM";
2558
- action: string;
2559
2598
  message?: string | null | undefined;
2560
2599
  actorId?: string | null | undefined;
2561
2600
  targetType?: string | null | undefined;
@@ -2567,7 +2606,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2567
2606
  serviceCounts: Record<string, number>;
2568
2607
  commandCounts: Record<string, number>;
2569
2608
  recentCommands?: {
2570
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2609
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2571
2610
  id: string;
2572
2611
  createdAt: string;
2573
2612
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2583,9 +2622,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2583
2622
  recentAuditEvents?: {
2584
2623
  id: string;
2585
2624
  createdAt: string;
2625
+ action: string;
2586
2626
  result: "SUCCESS" | "FAILURE";
2587
2627
  actorType: "USER" | "AGENT" | "SYSTEM";
2588
- action: string;
2589
2628
  message?: string | null | undefined;
2590
2629
  actorId?: string | null | undefined;
2591
2630
  targetType?: string | null | undefined;
@@ -2597,7 +2636,7 @@ declare const DashboardSummarySchema: z.ZodObject<{
2597
2636
  serviceCounts: Record<string, number>;
2598
2637
  commandCounts: Record<string, number>;
2599
2638
  recentCommands?: {
2600
- type: "ACTION_PREPARE" | "ACTION_EXECUTE" | "ACTION";
2639
+ type: "ACTION_PREPARE" | "ACTION_EXECUTE";
2601
2640
  id: string;
2602
2641
  createdAt: string;
2603
2642
  status: "PENDING" | "RUNNING" | "SUCCEEDED" | "FAILED" | "EXPIRED" | "CANCELLED";
@@ -2613,9 +2652,9 @@ declare const DashboardSummarySchema: z.ZodObject<{
2613
2652
  recentAuditEvents?: {
2614
2653
  id: string;
2615
2654
  createdAt: string;
2655
+ action: string;
2616
2656
  result: "SUCCESS" | "FAILURE";
2617
2657
  actorType: "USER" | "AGENT" | "SYSTEM";
2618
- action: string;
2619
2658
  message?: string | null | undefined;
2620
2659
  actorId?: string | null | undefined;
2621
2660
  targetType?: string | null | undefined;
@@ -2738,4 +2777,4 @@ declare function paginate<T>(items: T[], page: number, pageSize: number, total:
2738
2777
  };
2739
2778
  };
2740
2779
 
2741
- export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError, type IdPrefix, ListQueryBase, type Pagination, type RegisterAgentRequest, RegisterAgentRequestSchema, type RegisterAgentResponse, RegisterAgentResponseSchema, type RegistrationToken, RegistrationTokenSchema, type ReportCommandResultRequest, ReportCommandResultRequestSchema, type ReportedService, ReportedServiceSchema, type ResetUserPasswordRequest, type ServiceReportRequest, ServiceReportRequestSchema, type SuccessEnvelope, type SystemHealth, SystemHealthSchema, type SystemVersion, SystemVersionSchema, TokenStatus, type UpdateUserRequest, type User, UserRole, UserSchema, actionDefinitionInputSchema, adminLoginRequestSchema, agentHeartbeatRequestSchema, configItemInputSchema, createActionCommandRequestSchema, createRegistrationTokenRequestSchema, createUserRequestSchema, healthReportInputSchema, idPrefixes, newId, paginate, parseSort, registerAgentRequestSchema, reportCommandResultRequestSchema, reportedServiceSchema, resetUserPasswordRequestSchema, serviceReportRequestSchema, updateUserRequestSchema };
2780
+ export { type ActionDefinition, type ActionDefinitionInput, ActionDefinitionInputSchema, ActionDefinitionSchema, type ActionPrepareResult, ActionPrepareResultSchema, type AdminLoginRequest, AdminLoginRequestSchema, type AdminSession, AdminSessionSchema, type Agent, type AgentHeartbeatRequest, AgentHeartbeatRequestSchema, type AgentHeartbeatResponse, AgentHeartbeatResponseSchema, AgentSchema, AgentStatus, AgentStatusSchema, AnyJson, AuditActorType, type AuditEvent, AuditEventSchema, AuditResult, type CapsuleManifest, CapsuleManifestSchema, type CapsuleService, type CapsuleServiceDetail, CapsuleServiceDetailSchema, CapsuleServiceSchema, CapsuleServiceStatus, CapsuleServiceStatusSchema, type Command, type CommandDetail, CommandDetailSchema, type CommandResult, CommandResultSchema, CommandSchema, CommandStatus, CommandStatusSchema, type CommandType, CommandTypeSchema, type ConfigItem, type ConfigItemInput, ConfigItemInputSchema, ConfigItemSchema, type CreateActionCommandRequest, CreateActionCommandRequestSchema, type CreateRegistrationTokenRequest, CreateRegistrationTokenRequestSchema, type CreateRegistrationTokenResponse, CreateRegistrationTokenResponseSchema, type CreateUserRequest, DangerLevel, DangerLevelSchema, type DashboardSummary, DashboardSummarySchema, ErrorCode, type ErrorEnvelope, type HealthReport, type HealthReportInput, HealthReportInputSchema, HealthReportSchema, HealthStatus, HealthStatusSchema, HttpError, ListQueryBase, type Pagination, type RegisterAgentRequest, RegisterAgentRequestSchema, type RegisterAgentResponse, RegisterAgentResponseSchema, type RegistrationToken, RegistrationTokenSchema, type ReportCommandResultRequest, ReportCommandResultRequestSchema, type ReportedService, ReportedServiceSchema, type ResetUserPasswordRequest, type RuntimeKind, RuntimeKindSchema, type ServiceReportRequest, ServiceReportRequestSchema, type SuccessEnvelope, type SystemHealth, SystemHealthSchema, type SystemVersion, SystemVersionSchema, TokenStatus, type UpdateUserRequest, type User, UserRole, UserSchema, actionDefinitionInputSchema, actionPrepareResultSchema, adminLoginRequestSchema, agentHeartbeatRequestSchema, configItemInputSchema, createActionCommandRequestSchema, createRegistrationTokenRequestSchema, createUserRequestSchema, healthReportInputSchema, paginate, parseSort, registerAgentRequestSchema, reportCommandResultRequestSchema, reportedServiceSchema, resetUserPasswordRequestSchema, serviceReportRequestSchema, updateUserRequestSchema };
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  // src/index.ts
2
- import { customAlphabet } from "nanoid";
3
2
  import { z } from "zod";
4
3
  var AgentStatus = ["PENDING", "ONLINE", "OFFLINE", "DISABLED", "REVOKED"];
5
4
  var CapsuleServiceStatus = ["UNKNOWN", "HEALTHY", "UNHEALTHY", "STALE", "OFFLINE"];
@@ -24,11 +23,6 @@ var ErrorCode = {
24
23
  AGENT_REVOKED: "AGENT_REVOKED",
25
24
  AGENT_DISABLED: "AGENT_DISABLED"
26
25
  };
27
- var idPrefixes = ["wks_", "usr_", "agt_", "tok_", "svc_", "hlr_", "cfg_", "act_", "cmd_", "crs_", "aud_"];
28
- var NANO = customAlphabet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-", 21);
29
- function newId(prefix) {
30
- return `${prefix}${NANO()}`;
31
- }
32
26
  var AnyJson = z.record(z.any());
33
27
  var AgentStatusSchema = z.enum(AgentStatus);
34
28
  var CapsuleServiceStatusSchema = z.enum(CapsuleServiceStatus);
@@ -59,7 +53,8 @@ var ReportedServiceSchema = z.object({ code: z.string().min(1).max(80), name: z.
59
53
  var reportedServiceSchema = ReportedServiceSchema;
60
54
  var ServiceReportRequestSchema = z.object({ services: z.array(ReportedServiceSchema).min(1) });
61
55
  var serviceReportRequestSchema = ServiceReportRequestSchema;
62
- var RegisterAgentRequestSchema = z.object({ registrationToken: z.string().startsWith("opstage_reg_"), agent: z.object({ code: z.string(), name: z.string().optional(), mode: z.literal("embedded"), runtime: z.string().optional() }), service: ReportedServiceSchema.optional() });
56
+ var RuntimeKindSchema = z.enum(["nodejs", "java", "python", "go", "other"]);
57
+ var RegisterAgentRequestSchema = z.object({ registrationToken: z.string().startsWith("opstage_reg_"), agent: z.object({ code: z.string(), name: z.string().optional(), mode: z.literal("embedded"), runtime: RuntimeKindSchema.optional() }), service: ReportedServiceSchema.optional() });
63
58
  var registerAgentRequestSchema = RegisterAgentRequestSchema;
64
59
  var RegisterAgentResponseSchema = z.object({ agentId: z.string().startsWith("agt_"), agentToken: z.string().startsWith("opstage_agent_"), heartbeatIntervalSeconds: z.number().int(), commandPollIntervalSeconds: z.number().int() });
65
60
  var AgentHeartbeatResponseSchema = z.object({ heartbeatIntervalSeconds: z.number().int(), commandPollIntervalSeconds: z.number().int() });
@@ -70,9 +65,17 @@ var HealthReportSchema = z.object({ id: z.string().startsWith("hlr_"), serviceId
70
65
  var ConfigItemSchema = z.object({ id: z.string().startsWith("cfg_"), serviceId: z.string().startsWith("svc_"), key: z.string(), label: z.string().nullable().optional(), type: z.string(), source: z.string().nullable().optional(), editable: z.boolean().default(false), sensitive: z.boolean(), valuePreview: z.string().nullable().optional(), defaultValue: z.string().nullable().optional(), secretRef: z.string().nullable().optional() });
71
66
  var ActionDefinitionSchema = z.object({ id: z.string().startsWith("act_"), serviceId: z.string().startsWith("svc_"), name: z.string(), label: z.string(), description: z.string().nullable().optional(), dangerLevel: z.enum(DangerLevel), requiresConfirmation: z.boolean(), category: z.string().optional(), order: z.number().int().optional(), inputSchema: AnyJson.optional(), outputSchema: AnyJson.optional(), timeoutSeconds: z.number().int().optional() });
72
67
  var CapsuleServiceDetailSchema = CapsuleServiceSchema.extend({ manifest: AnyJson.optional(), health: HealthReportSchema.nullable().optional(), configs: z.array(ConfigItemSchema).optional(), actions: z.array(ActionDefinitionSchema).optional() });
68
+ var ActionPrepareResultSchema = z.object({
69
+ action: AnyJson.optional(),
70
+ inputSchema: AnyJson.optional(),
71
+ initialPayload: AnyJson.optional(),
72
+ currentState: AnyJson.optional()
73
+ });
74
+ var actionPrepareResultSchema = ActionPrepareResultSchema;
73
75
  var CreateActionCommandRequestSchema = z.object({ payload: AnyJson.optional(), confirmation: z.boolean().optional() });
74
76
  var createActionCommandRequestSchema = CreateActionCommandRequestSchema;
75
- var CommandSchema = z.object({ id: z.string().startsWith("cmd_"), agentId: z.string().startsWith("agt_"), serviceId: z.string().startsWith("svc_"), type: z.enum(["ACTION_PREPARE", "ACTION_EXECUTE", "ACTION"]), actionName: z.string(), status: CommandStatusSchema, payload: AnyJson.optional(), createdByUserId: z.string().startsWith("usr_").nullable().optional(), createdAt: z.string(), startedAt: z.string().nullable().optional(), completedAt: z.string().nullable().optional(), expiresAt: z.string().nullable().optional() });
77
+ var CommandTypeSchema = z.enum(["ACTION_PREPARE", "ACTION_EXECUTE"]);
78
+ var CommandSchema = z.object({ id: z.string().startsWith("cmd_"), agentId: z.string().startsWith("agt_"), serviceId: z.string().startsWith("svc_"), type: CommandTypeSchema, actionName: z.string(), status: CommandStatusSchema, payload: AnyJson.optional(), createdByUserId: z.string().startsWith("usr_").nullable().optional(), createdAt: z.string(), startedAt: z.string().nullable().optional(), completedAt: z.string().nullable().optional(), expiresAt: z.string().nullable().optional() });
76
79
  var ReportCommandResultRequestSchema = z.object({ success: z.boolean(), message: z.string().optional(), data: AnyJson.optional(), error: AnyJson.optional(), startedAt: z.string().optional(), finishedAt: z.string().optional() });
77
80
  var reportCommandResultRequestSchema = ReportCommandResultRequestSchema;
78
81
  var CommandResultSchema = z.object({ id: z.string().startsWith("crs_"), commandId: z.string().startsWith("cmd_"), success: z.boolean(), message: z.string().nullable().optional(), data: AnyJson.optional(), error: AnyJson.optional(), reportedAt: z.string() });
@@ -110,6 +113,7 @@ function paginate(items, page, pageSize, total) {
110
113
  export {
111
114
  ActionDefinitionInputSchema,
112
115
  ActionDefinitionSchema,
116
+ ActionPrepareResultSchema,
113
117
  AdminLoginRequestSchema,
114
118
  AdminSessionSchema,
115
119
  AgentHeartbeatRequestSchema,
@@ -131,6 +135,7 @@ export {
131
135
  CommandSchema,
132
136
  CommandStatus,
133
137
  CommandStatusSchema,
138
+ CommandTypeSchema,
134
139
  ConfigItemInputSchema,
135
140
  ConfigItemSchema,
136
141
  CreateActionCommandRequestSchema,
@@ -151,6 +156,7 @@ export {
151
156
  RegistrationTokenSchema,
152
157
  ReportCommandResultRequestSchema,
153
158
  ReportedServiceSchema,
159
+ RuntimeKindSchema,
154
160
  ServiceReportRequestSchema,
155
161
  SystemHealthSchema,
156
162
  SystemVersionSchema,
@@ -158,6 +164,7 @@ export {
158
164
  UserRole,
159
165
  UserSchema,
160
166
  actionDefinitionInputSchema,
167
+ actionPrepareResultSchema,
161
168
  adminLoginRequestSchema,
162
169
  agentHeartbeatRequestSchema,
163
170
  configItemInputSchema,
@@ -165,8 +172,6 @@ export {
165
172
  createRegistrationTokenRequestSchema,
166
173
  createUserRequestSchema,
167
174
  healthReportInputSchema,
168
- idPrefixes,
169
- newId,
170
175
  paginate,
171
176
  parseSort,
172
177
  registerAgentRequestSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtrape/capsule-contracts-node",
3
- "version": "0.1.0-public-review.0",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript contracts and Zod schemas for Xtrape Capsule and Opstage wire protocols.",
5
5
  "keywords": [
6
6
  "xtrape",
@@ -36,15 +36,7 @@
36
36
  "LICENSE",
37
37
  "NOTICE"
38
38
  ],
39
- "scripts": {
40
- "build": "tsup src/index.ts --format esm,cjs --dts",
41
- "prepack": "pnpm build",
42
- "test": "vitest run",
43
- "typecheck": "tsc --noEmit",
44
- "lint": "tsc --noEmit"
45
- },
46
39
  "dependencies": {
47
- "nanoid": "^5.0.9",
48
40
  "zod": "^3.25.0"
49
41
  },
50
42
  "devDependencies": {
@@ -59,5 +51,11 @@
59
51
  "registry": "https://registry.npmjs.org/",
60
52
  "access": "public"
61
53
  },
62
- "license": "Apache-2.0"
63
- }
54
+ "license": "Apache-2.0",
55
+ "scripts": {
56
+ "build": "tsup src/index.ts --format esm,cjs --dts",
57
+ "test": "vitest run",
58
+ "typecheck": "tsc --noEmit",
59
+ "lint": "tsc --noEmit"
60
+ }
61
+ }
@@ -1730,7 +1730,7 @@ components:
1730
1730
  pattern: '^svc_'
1731
1731
  type:
1732
1732
  type: string
1733
- enum: [ACTION_PREPARE, ACTION_EXECUTE, ACTION]
1733
+ enum: [ACTION_PREPARE, ACTION_EXECUTE]
1734
1734
  actionName:
1735
1735
  type: string
1736
1736
  status: