@agentdock/wire 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentCapabilities.js +1 -195
- package/dist/agentCommonEnv.js +1 -20
- package/dist/agentInstallGuide.js +1 -81
- package/dist/checkpointSchemas.js +1 -46
- package/dist/controlLevel.js +1 -11
- package/dist/edition.d.ts +5 -0
- package/dist/edition.js +1 -0
- package/dist/envelope.js +1 -78
- package/dist/errorMessage.js +1 -6
- package/dist/events.js +1 -97
- package/dist/features.d.ts +2 -0
- package/dist/features.js +1 -112
- package/dist/feedback.js +1 -26
- package/dist/index.d.ts +13 -4
- package/dist/index.js +1 -60
- package/dist/interactionEvents.js +1 -108
- package/dist/legacyProtocol.js +1 -30
- package/dist/license.d.ts +52 -0
- package/dist/license.js +1 -0
- package/dist/machine.d.ts +34 -0
- package/dist/machine.js +1 -56
- package/dist/messageMeta.js +1 -60
- package/dist/messages.d.ts +8 -8
- package/dist/messages.js +1 -35
- package/dist/ops.js +1 -74
- package/dist/pairing.js +1 -115
- package/dist/protocol.js +1 -7
- package/dist/rpc.d.ts +7 -7
- package/dist/rpc.js +1 -230
- package/dist/scheduledTasks.js +1 -81
- package/dist/semver.js +1 -60
- package/dist/sessionResult.js +1 -23
- package/dist/socketEvents.d.ts +1 -0
- package/dist/socketEvents.js +1 -43
- package/dist/spawnError.js +1 -31
- package/dist/stats.d.ts +28 -0
- package/dist/stats.js +1 -115
- package/dist/sync.d.ts +23 -23
- package/dist/sync.js +1 -78
- package/dist/telemetry.js +1 -80
- package/dist/utils.js +1 -2
- package/package.json +1 -1
- package/dist/agentCapabilities.d.ts.map +0 -1
- package/dist/agentCapabilities.js.map +0 -1
- package/dist/agentCommonEnv.d.ts.map +0 -1
- package/dist/agentCommonEnv.js.map +0 -1
- package/dist/agentInstallGuide.d.ts.map +0 -1
- package/dist/agentInstallGuide.js.map +0 -1
- package/dist/checkpointSchemas.d.ts.map +0 -1
- package/dist/checkpointSchemas.js.map +0 -1
- package/dist/controlLevel.d.ts.map +0 -1
- package/dist/controlLevel.js.map +0 -1
- package/dist/envelope.d.ts.map +0 -1
- package/dist/envelope.js.map +0 -1
- package/dist/errorMessage.d.ts.map +0 -1
- package/dist/errorMessage.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/features.d.ts.map +0 -1
- package/dist/features.js.map +0 -1
- package/dist/feedback.d.ts.map +0 -1
- package/dist/feedback.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interactionEvents.d.ts.map +0 -1
- package/dist/interactionEvents.js.map +0 -1
- package/dist/legacyProtocol.d.ts.map +0 -1
- package/dist/legacyProtocol.js.map +0 -1
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js.map +0 -1
- package/dist/messageMeta.d.ts.map +0 -1
- package/dist/messageMeta.js.map +0 -1
- package/dist/messages.d.ts.map +0 -1
- package/dist/messages.js.map +0 -1
- package/dist/ops.d.ts.map +0 -1
- package/dist/ops.js.map +0 -1
- package/dist/pairing.d.ts.map +0 -1
- package/dist/pairing.js.map +0 -1
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/scheduledTasks.d.ts.map +0 -1
- package/dist/scheduledTasks.js.map +0 -1
- package/dist/semver.d.ts.map +0 -1
- package/dist/semver.js.map +0 -1
- package/dist/sessionResult.d.ts.map +0 -1
- package/dist/sessionResult.js.map +0 -1
- package/dist/socketEvents.d.ts.map +0 -1
- package/dist/socketEvents.js.map +0 -1
- package/dist/spawnError.d.ts.map +0 -1
- package/dist/spawnError.js.map +0 -1
- package/dist/stats.d.ts.map +0 -1
- package/dist/stats.js.map +0 -1
- package/dist/sync.d.ts.map +0 -1
- package/dist/sync.js.map +0 -1
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/messages.d.ts
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
export declare const SessionMessageContentSchema: z.ZodObject<{
|
|
9
9
|
c: z.ZodString;
|
|
10
|
-
t: z.
|
|
10
|
+
t: z.ZodEnum<["encrypted", "plaintext"]>;
|
|
11
11
|
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
t: "encrypted";
|
|
12
|
+
t: "encrypted" | "plaintext";
|
|
13
13
|
c: string;
|
|
14
14
|
}, {
|
|
15
|
-
t: "encrypted";
|
|
15
|
+
t: "encrypted" | "plaintext";
|
|
16
16
|
c: string;
|
|
17
17
|
}>;
|
|
18
18
|
export type SessionMessageContent = z.infer<typeof SessionMessageContentSchema>;
|
|
@@ -22,12 +22,12 @@ export declare const SessionMessageSchema: z.ZodObject<{
|
|
|
22
22
|
localId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
23
23
|
content: z.ZodObject<{
|
|
24
24
|
c: z.ZodString;
|
|
25
|
-
t: z.
|
|
25
|
+
t: z.ZodEnum<["encrypted", "plaintext"]>;
|
|
26
26
|
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
t: "encrypted";
|
|
27
|
+
t: "encrypted" | "plaintext";
|
|
28
28
|
c: string;
|
|
29
29
|
}, {
|
|
30
|
-
t: "encrypted";
|
|
30
|
+
t: "encrypted" | "plaintext";
|
|
31
31
|
c: string;
|
|
32
32
|
}>;
|
|
33
33
|
createdAt: z.ZodNumber;
|
|
@@ -35,7 +35,7 @@ export declare const SessionMessageSchema: z.ZodObject<{
|
|
|
35
35
|
}, "strip", z.ZodTypeAny, {
|
|
36
36
|
id: string;
|
|
37
37
|
content: {
|
|
38
|
-
t: "encrypted";
|
|
38
|
+
t: "encrypted" | "plaintext";
|
|
39
39
|
c: string;
|
|
40
40
|
};
|
|
41
41
|
seq: number;
|
|
@@ -45,7 +45,7 @@ export declare const SessionMessageSchema: z.ZodObject<{
|
|
|
45
45
|
}, {
|
|
46
46
|
id: string;
|
|
47
47
|
content: {
|
|
48
|
-
t: "encrypted";
|
|
48
|
+
t: "encrypted" | "plaintext";
|
|
49
49
|
c: string;
|
|
50
50
|
};
|
|
51
51
|
seq: number;
|
package/dist/messages.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Message schemas — aligned with Happy messages.ts.
|
|
3
|
-
*
|
|
4
|
-
* SessionMessage: encrypted content container.
|
|
5
|
-
* Timestamps are Unix numbers (milliseconds).
|
|
6
|
-
*/
|
|
7
|
-
import { z } from 'zod';
|
|
8
|
-
import { SessionEnvelopeSchema } from './envelope.js';
|
|
9
|
-
import { MessageMetaSchema } from './messageMeta.js';
|
|
10
|
-
import { UserMessageSchema, AgentMessageSchema } from './legacyProtocol.js';
|
|
11
|
-
export const SessionMessageContentSchema = z.object({
|
|
12
|
-
c: z.string(),
|
|
13
|
-
t: z.literal('encrypted'),
|
|
14
|
-
});
|
|
15
|
-
export const SessionMessageSchema = z.object({
|
|
16
|
-
id: z.string(),
|
|
17
|
-
seq: z.number(),
|
|
18
|
-
localId: z.string().nullish(),
|
|
19
|
-
content: SessionMessageContentSchema,
|
|
20
|
-
createdAt: z.number(),
|
|
21
|
-
updatedAt: z.number(),
|
|
22
|
-
});
|
|
23
|
-
// ── SessionProtocolMessage (bridges envelope into message content) ──
|
|
24
|
-
export const SessionProtocolMessageSchema = z.object({
|
|
25
|
-
role: z.literal('session'),
|
|
26
|
-
content: SessionEnvelopeSchema,
|
|
27
|
-
meta: MessageMetaSchema.optional(),
|
|
28
|
-
});
|
|
29
|
-
// ── MessageContent (union of all message content types) ─────────────
|
|
30
|
-
export const MessageContentSchema = z.discriminatedUnion('role', [
|
|
31
|
-
UserMessageSchema,
|
|
32
|
-
AgentMessageSchema,
|
|
33
|
-
SessionProtocolMessageSchema,
|
|
34
|
-
]);
|
|
35
|
-
//# sourceMappingURL=messages.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";import{SessionEnvelopeSchema as t}from"./envelope.js";import{MessageMetaSchema as o}from"./messageMeta.js";import{UserMessageSchema as s,AgentMessageSchema as n}from"./legacyProtocol.js";export const SessionMessageContentSchema=e.object({c:e.string(),t:e.enum(["encrypted","plaintext"])}),SessionMessageSchema=e.object({id:e.string(),seq:e.number(),localId:e.string().nullish(),content:SessionMessageContentSchema,createdAt:e.number(),updatedAt:e.number()}),SessionProtocolMessageSchema=e.object({role:e.literal("session"),content:t,meta:o.optional()}),MessageContentSchema=e.discriminatedUnion("role",[s,n,SessionProtocolMessageSchema]);
|
package/dist/ops.js
CHANGED
|
@@ -1,74 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* Ops RPC method naming convention: namespace.action
|
|
4
|
-
* - file.* — RFC-033 file management
|
|
5
|
-
* - sync.* — RFC-034 data sync (Ops Agent → Server)
|
|
6
|
-
* - config.* — RFC-034 policy push (Server → Ops Agent)
|
|
7
|
-
*/
|
|
8
|
-
export const OpsMethodSchema = z
|
|
9
|
-
.string()
|
|
10
|
-
.min(1)
|
|
11
|
-
.regex(/^[a-z]+\.[a-z][a-z0-9-]*$/);
|
|
12
|
-
export const OpsRpcTypeSchema = z.enum(['request', 'response', 'event']);
|
|
13
|
-
/** Unified RPC message over the ops-upstream tunnel. */
|
|
14
|
-
export const OpsRpcMessageSchema = z.object({
|
|
15
|
-
id: z.string().min(1),
|
|
16
|
-
type: OpsRpcTypeSchema,
|
|
17
|
-
method: OpsMethodSchema,
|
|
18
|
-
payload: z.unknown(),
|
|
19
|
-
});
|
|
20
|
-
// FileEntry — directory listing item
|
|
21
|
-
export const FileEntrySchema = z.object({
|
|
22
|
-
name: z.string(),
|
|
23
|
-
type: z.enum(['file', 'directory']),
|
|
24
|
-
size: z.number().int().nonnegative(),
|
|
25
|
-
modifiedAt: z.string(),
|
|
26
|
-
mimeType: z.string().optional(),
|
|
27
|
-
});
|
|
28
|
-
// FileStat — detailed metadata
|
|
29
|
-
export const FileStatSchema = z.object({
|
|
30
|
-
name: z.string(),
|
|
31
|
-
path: z.string(),
|
|
32
|
-
type: z.enum(['file', 'directory']),
|
|
33
|
-
size: z.number().int().nonnegative(),
|
|
34
|
-
modifiedAt: z.string(),
|
|
35
|
-
createdAt: z.string(),
|
|
36
|
-
mimeType: z.string().optional(),
|
|
37
|
-
});
|
|
38
|
-
// StorageUsage — quota info
|
|
39
|
-
export const StorageUsageSchema = z.object({
|
|
40
|
-
used: z.number().int().nonnegative(),
|
|
41
|
-
limit: z.number().int().nonnegative(),
|
|
42
|
-
fileCount: z.number().int().nonnegative(),
|
|
43
|
-
});
|
|
44
|
-
// ─── Sync payloads (RFC-034 P1) ─────────────────────────
|
|
45
|
-
/** A single user record in a full sync push. */
|
|
46
|
-
export const SyncUserSchema = z.object({
|
|
47
|
-
username: z.string().min(1),
|
|
48
|
-
displayName: z.string(),
|
|
49
|
-
machineId: z.string().nullable(),
|
|
50
|
-
containerStatus: z.string(),
|
|
51
|
-
healthStatus: z.string().nullable(),
|
|
52
|
-
enabled: z.boolean(),
|
|
53
|
-
});
|
|
54
|
-
/** sync.full — all users pushed on tunnel connect/reconnect. */
|
|
55
|
-
export const SyncFullPayloadSchema = z.object({
|
|
56
|
-
users: z.array(SyncUserSchema),
|
|
57
|
-
});
|
|
58
|
-
/** sync.user-created — single user just created. */
|
|
59
|
-
export const SyncUserCreatedPayloadSchema = z.object({
|
|
60
|
-
username: z.string().min(1),
|
|
61
|
-
displayName: z.string(),
|
|
62
|
-
});
|
|
63
|
-
/** sync.container-status — container state change. */
|
|
64
|
-
export const SyncContainerStatusPayloadSchema = z.object({
|
|
65
|
-
username: z.string().min(1),
|
|
66
|
-
containerStatus: z.string(),
|
|
67
|
-
healthStatus: z.string().nullable().optional(),
|
|
68
|
-
});
|
|
69
|
-
/** sync.user-paired — daemon pairing detected, machineId available. */
|
|
70
|
-
export const SyncUserPairedPayloadSchema = z.object({
|
|
71
|
-
username: z.string().min(1),
|
|
72
|
-
machineId: z.string().min(1),
|
|
73
|
-
});
|
|
74
|
-
//# sourceMappingURL=ops.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";export const OpsMethodSchema=e.string().min(1).regex(/^[a-z]+\.[a-z][a-z0-9-]*$/),OpsRpcTypeSchema=e.enum(["request","response","event"]),OpsRpcMessageSchema=e.object({id:e.string().min(1),type:OpsRpcTypeSchema,method:OpsMethodSchema,payload:e.unknown()}),FileEntrySchema=e.object({name:e.string(),type:e.enum(["file","directory"]),size:e.number().int().nonnegative(),modifiedAt:e.string(),mimeType:e.string().optional()}),FileStatSchema=e.object({name:e.string(),path:e.string(),type:e.enum(["file","directory"]),size:e.number().int().nonnegative(),modifiedAt:e.string(),createdAt:e.string(),mimeType:e.string().optional()}),StorageUsageSchema=e.object({used:e.number().int().nonnegative(),limit:e.number().int().nonnegative(),fileCount:e.number().int().nonnegative()}),SyncUserSchema=e.object({username:e.string().min(1),displayName:e.string(),machineId:e.string().nullable(),containerStatus:e.string(),healthStatus:e.string().nullable(),enabled:e.boolean()}),SyncFullPayloadSchema=e.object({users:e.array(SyncUserSchema)}),SyncUserCreatedPayloadSchema=e.object({username:e.string().min(1),displayName:e.string()}),SyncContainerStatusPayloadSchema=e.object({username:e.string().min(1),containerStatus:e.string(),healthStatus:e.string().nullable().optional()}),SyncUserPairedPayloadSchema=e.object({username:e.string().min(1),machineId:e.string().min(1)});
|
package/dist/pairing.js
CHANGED
|
@@ -1,115 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Pairing protocol schemas.
|
|
3
|
-
*
|
|
4
|
-
* Defines the wire format for device pairing:
|
|
5
|
-
* - PairingRequest: CLI sends publicKey + optional PIN to server
|
|
6
|
-
* - PairingResponse: Web sends encrypted payload back via server
|
|
7
|
-
* - PairingStatus: Polling response — discriminated union on state
|
|
8
|
-
*
|
|
9
|
-
* Security: Uses NaCl Box (Curve25519 + XSalsa20-Poly1305) for key exchange.
|
|
10
|
-
* PIN code provides iOS PWA fallback where QR scanning is unreliable.
|
|
11
|
-
*/
|
|
12
|
-
import { z } from 'zod';
|
|
13
|
-
/** 6-digit numeric PIN for iOS PWA fallback. */
|
|
14
|
-
const PinSchema = z.string().regex(/^\d{6}$/, 'PIN must be exactly 6 digits');
|
|
15
|
-
/** Pairing state machine. */
|
|
16
|
-
export const PairingState = z.enum(['pending', 'exchange', 'authorized', 'expired']);
|
|
17
|
-
/**
|
|
18
|
-
* Validates that a string is a base64/base64url-encoded 32-byte Curve25519 public key.
|
|
19
|
-
* Accepts both standard base64 (with padding) and base64url (without padding).
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Check if a base64/base64url string decodes to exactly `expectedBytes` bytes.
|
|
23
|
-
* Uses string-length math: 4 base64 chars = 3 bytes.
|
|
24
|
-
* No runtime decoding needed — just validate charset + length.
|
|
25
|
-
*/
|
|
26
|
-
function isBase64OfLength(val, expectedBytes) {
|
|
27
|
-
// Must be non-empty and only valid base64/base64url characters
|
|
28
|
-
if (!/^[A-Za-z0-9+/\-_]+=*$/.test(val))
|
|
29
|
-
return false;
|
|
30
|
-
// Normalize base64url → standard base64
|
|
31
|
-
const b64 = val.replace(/-/g, '+').replace(/_/g, '/');
|
|
32
|
-
const padded = b64.padEnd(b64.length + ((4 - (b64.length % 4)) % 4), '=');
|
|
33
|
-
// Count padding
|
|
34
|
-
const paddingCount = (padded.match(/=+$/) ?? [''])[0].length;
|
|
35
|
-
const totalBytes = (padded.length / 4) * 3 - paddingCount;
|
|
36
|
-
return totalBytes === expectedBytes;
|
|
37
|
-
}
|
|
38
|
-
const Curve25519PublicKeySchema = z
|
|
39
|
-
.string()
|
|
40
|
-
.min(1)
|
|
41
|
-
.refine((val) => isBase64OfLength(val, 32), {
|
|
42
|
-
message: 'publicKey must be a base64-encoded 32-byte Curve25519 key',
|
|
43
|
-
});
|
|
44
|
-
/**
|
|
45
|
-
* CLI → Server: initiate a pairing request.
|
|
46
|
-
*
|
|
47
|
-
* publicKey: base64-encoded Curve25519 public key (32 bytes)
|
|
48
|
-
* pin: optional 6-digit PIN for manual entry (iOS PWA fallback)
|
|
49
|
-
* label: optional human-readable device label
|
|
50
|
-
*/
|
|
51
|
-
export const PairingRequestSchema = z.object({
|
|
52
|
-
publicKey: Curve25519PublicKeySchema,
|
|
53
|
-
pin: PinSchema.optional(),
|
|
54
|
-
label: z.string().max(100).optional(),
|
|
55
|
-
type: z.enum(['join', 'invite']).optional(),
|
|
56
|
-
});
|
|
57
|
-
/**
|
|
58
|
-
* Web → Server: approve pairing with encrypted key material.
|
|
59
|
-
*
|
|
60
|
-
* publicKey: identifies which pairing request to respond to (32-byte Curve25519 key)
|
|
61
|
-
* encryptedPayload: NaCl Box encrypted data (base64) containing the DEK
|
|
62
|
-
*/
|
|
63
|
-
export const PairingResponseSchema = z.object({
|
|
64
|
-
publicKey: Curve25519PublicKeySchema,
|
|
65
|
-
encryptedPayload: z.string().min(1),
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* New device → Server: submit device's temporary Curve25519 public key.
|
|
69
|
-
* Used in invite flow when a new device joins an existing account.
|
|
70
|
-
*/
|
|
71
|
-
export const PairingExchangeSchema = z.object({
|
|
72
|
-
daemonPublicKey: Curve25519PublicKeySchema,
|
|
73
|
-
devicePublicKey: Curve25519PublicKeySchema,
|
|
74
|
-
});
|
|
75
|
-
/**
|
|
76
|
-
* Daemon → Server: deliver encrypted master secret to new device.
|
|
77
|
-
* Requires Bearer auth. Encrypted via NaCl Box using device's public key.
|
|
78
|
-
*/
|
|
79
|
-
export const PairingDeliverSchema = z.object({
|
|
80
|
-
publicKey: Curve25519PublicKeySchema,
|
|
81
|
-
encryptedPayload: z.string().min(1),
|
|
82
|
-
});
|
|
83
|
-
/**
|
|
84
|
-
* Server → CLI: current pairing status (polled).
|
|
85
|
-
* Discriminated union on `state`:
|
|
86
|
-
* - pending: waiting for web approval
|
|
87
|
-
* - authorized: web approved, encryptedPayload + token required
|
|
88
|
-
* - expired: request timed out
|
|
89
|
-
*/
|
|
90
|
-
const PairingStatusPending = z.object({
|
|
91
|
-
state: z.literal('pending'),
|
|
92
|
-
publicKey: z.string().min(1),
|
|
93
|
-
});
|
|
94
|
-
const PairingStatusExchange = z.object({
|
|
95
|
-
state: z.literal('exchange'),
|
|
96
|
-
publicKey: z.string().min(1),
|
|
97
|
-
devicePublicKey: z.string().min(1),
|
|
98
|
-
});
|
|
99
|
-
const PairingStatusAuthorized = z.object({
|
|
100
|
-
state: z.literal('authorized'),
|
|
101
|
-
publicKey: z.string().min(1),
|
|
102
|
-
encryptedPayload: z.string().min(1),
|
|
103
|
-
token: z.string().min(1),
|
|
104
|
-
});
|
|
105
|
-
const PairingStatusExpired = z.object({
|
|
106
|
-
state: z.literal('expired'),
|
|
107
|
-
publicKey: z.string().min(1),
|
|
108
|
-
});
|
|
109
|
-
export const PairingStatusSchema = z.discriminatedUnion('state', [
|
|
110
|
-
PairingStatusPending,
|
|
111
|
-
PairingStatusExchange,
|
|
112
|
-
PairingStatusAuthorized,
|
|
113
|
-
PairingStatusExpired,
|
|
114
|
-
]);
|
|
115
|
-
//# sourceMappingURL=pairing.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";const o=e.string().regex(/^\d{6}$/,"PIN must be exactly 6 digits");export const PairingState=e.enum(["pending","exchange","authorized","expired"]);function s(i,c){if(!/^[A-Za-z0-9+/\-_]+=*$/.test(i))return!1;const n=i.replace(/-/g,"+").replace(/_/g,"/"),a=n.padEnd(n.length+(4-n.length%4)%4,"="),r=(a.match(/=+$/)??[""])[0].length;return a.length/4*3-r===c}const t=e.string().min(1).refine(i=>s(i,32),{message:"publicKey must be a base64-encoded 32-byte Curve25519 key"});export const PairingRequestSchema=e.object({publicKey:t,pin:o.optional(),label:e.string().max(100).optional(),type:e.enum(["join","invite"]).optional()}),PairingResponseSchema=e.object({publicKey:t,encryptedPayload:e.string().min(1)}),PairingExchangeSchema=e.object({daemonPublicKey:t,devicePublicKey:t}),PairingDeliverSchema=e.object({publicKey:t,encryptedPayload:e.string().min(1)});const g=e.object({state:e.literal("pending"),publicKey:e.string().min(1)}),l=e.object({state:e.literal("exchange"),publicKey:e.string().min(1),devicePublicKey:e.string().min(1)}),p=e.object({state:e.literal("authorized"),publicKey:e.string().min(1),encryptedPayload:e.string().min(1),token:e.string().min(1)}),d=e.object({state:e.literal("expired"),publicKey:e.string().min(1)});export const PairingStatusSchema=e.discriminatedUnion("state",[g,l,p,d]);
|
package/dist/protocol.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Wire protocol version.
|
|
3
|
-
* Increment ONLY on breaking schema changes (new enum values, renamed events, required fields).
|
|
4
|
-
* See RFC-021 for the full versioning strategy.
|
|
5
|
-
*/
|
|
6
|
-
export const PROTOCOL_VERSION = 1;
|
|
7
|
-
//# sourceMappingURL=protocol.js.map
|
|
1
|
+
"use strict";export const PROTOCOL_VERSION=1;
|
package/dist/rpc.d.ts
CHANGED
|
@@ -251,12 +251,12 @@ export declare const GetMessagesResponseSchema: z.ZodObject<{
|
|
|
251
251
|
localId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
252
252
|
content: z.ZodObject<{
|
|
253
253
|
c: z.ZodString;
|
|
254
|
-
t: z.
|
|
254
|
+
t: z.ZodEnum<["encrypted", "plaintext"]>;
|
|
255
255
|
}, "strip", z.ZodTypeAny, {
|
|
256
|
-
t: "encrypted";
|
|
256
|
+
t: "encrypted" | "plaintext";
|
|
257
257
|
c: string;
|
|
258
258
|
}, {
|
|
259
|
-
t: "encrypted";
|
|
259
|
+
t: "encrypted" | "plaintext";
|
|
260
260
|
c: string;
|
|
261
261
|
}>;
|
|
262
262
|
createdAt: z.ZodNumber;
|
|
@@ -264,7 +264,7 @@ export declare const GetMessagesResponseSchema: z.ZodObject<{
|
|
|
264
264
|
}, "strip", z.ZodTypeAny, {
|
|
265
265
|
id: string;
|
|
266
266
|
content: {
|
|
267
|
-
t: "encrypted";
|
|
267
|
+
t: "encrypted" | "plaintext";
|
|
268
268
|
c: string;
|
|
269
269
|
};
|
|
270
270
|
seq: number;
|
|
@@ -274,7 +274,7 @@ export declare const GetMessagesResponseSchema: z.ZodObject<{
|
|
|
274
274
|
}, {
|
|
275
275
|
id: string;
|
|
276
276
|
content: {
|
|
277
|
-
t: "encrypted";
|
|
277
|
+
t: "encrypted" | "plaintext";
|
|
278
278
|
c: string;
|
|
279
279
|
};
|
|
280
280
|
seq: number;
|
|
@@ -288,7 +288,7 @@ export declare const GetMessagesResponseSchema: z.ZodObject<{
|
|
|
288
288
|
messages: {
|
|
289
289
|
id: string;
|
|
290
290
|
content: {
|
|
291
|
-
t: "encrypted";
|
|
291
|
+
t: "encrypted" | "plaintext";
|
|
292
292
|
c: string;
|
|
293
293
|
};
|
|
294
294
|
seq: number;
|
|
@@ -302,7 +302,7 @@ export declare const GetMessagesResponseSchema: z.ZodObject<{
|
|
|
302
302
|
messages: {
|
|
303
303
|
id: string;
|
|
304
304
|
content: {
|
|
305
|
-
t: "encrypted";
|
|
305
|
+
t: "encrypted" | "plaintext";
|
|
306
306
|
c: string;
|
|
307
307
|
};
|
|
308
308
|
seq: number;
|
package/dist/rpc.js
CHANGED
|
@@ -1,230 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SessionMessageSchema } from './messages.js';
|
|
3
|
-
import { CLI_AGENT_TYPES, SPAWNABLE_AGENTS } from './messageMeta.js';
|
|
4
|
-
import { PermissionModeSchema } from './interactionEvents.js';
|
|
5
|
-
export const RpcMethod = z.enum([
|
|
6
|
-
'spawn-session',
|
|
7
|
-
'stop-session',
|
|
8
|
-
'list-sessions',
|
|
9
|
-
'abort',
|
|
10
|
-
'switch-mode',
|
|
11
|
-
'approve-permission',
|
|
12
|
-
'deny-permission',
|
|
13
|
-
'answer-question',
|
|
14
|
-
'shutdown-daemon',
|
|
15
|
-
'get-messages',
|
|
16
|
-
'get-stats',
|
|
17
|
-
'get-team-stats',
|
|
18
|
-
'start-invite',
|
|
19
|
-
'get-machine-info',
|
|
20
|
-
'get-agent-settings',
|
|
21
|
-
'set-agent-settings',
|
|
22
|
-
'get-labs-settings',
|
|
23
|
-
'set-labs-settings',
|
|
24
|
-
'check-path',
|
|
25
|
-
'backfill-history-session',
|
|
26
|
-
'trigger-upgrade',
|
|
27
|
-
'checkpoint-list',
|
|
28
|
-
'checkpoint-diff',
|
|
29
|
-
'checkpoint-rollback',
|
|
30
|
-
]);
|
|
31
|
-
/**
|
|
32
|
-
* Session-scoped RPC methods — registered by `agentdock start` (CLI process).
|
|
33
|
-
* These operate on a specific session and require the CLI to be running.
|
|
34
|
-
*/
|
|
35
|
-
export const SESSION_RPC_METHODS = [
|
|
36
|
-
'answer-question',
|
|
37
|
-
'approve-permission',
|
|
38
|
-
'deny-permission',
|
|
39
|
-
'abort',
|
|
40
|
-
'stop-session',
|
|
41
|
-
];
|
|
42
|
-
/**
|
|
43
|
-
* Machine-scoped RPC methods — registered by the persistent daemon only.
|
|
44
|
-
* These are account/machine-level operations independent of any session.
|
|
45
|
-
*/
|
|
46
|
-
export const MACHINE_RPC_METHODS = [
|
|
47
|
-
'start-invite',
|
|
48
|
-
'get-machine-info',
|
|
49
|
-
'get-agent-settings',
|
|
50
|
-
'set-agent-settings',
|
|
51
|
-
'get-labs-settings',
|
|
52
|
-
'set-labs-settings',
|
|
53
|
-
'check-path',
|
|
54
|
-
'backfill-history-session',
|
|
55
|
-
'trigger-upgrade',
|
|
56
|
-
'checkpoint-list',
|
|
57
|
-
'checkpoint-diff',
|
|
58
|
-
'checkpoint-rollback',
|
|
59
|
-
];
|
|
60
|
-
/**
|
|
61
|
-
* All RPC methods that must be registered for Web UI to function.
|
|
62
|
-
* Daemon registers MACHINE_RPC_METHODS; CLI registers SESSION_RPC_METHODS.
|
|
63
|
-
*
|
|
64
|
-
* @deprecated Use SESSION_RPC_METHODS or MACHINE_RPC_METHODS directly.
|
|
65
|
-
*/
|
|
66
|
-
export const DAEMON_REQUIRED_RPC_METHODS = [
|
|
67
|
-
...SESSION_RPC_METHODS,
|
|
68
|
-
...MACHINE_RPC_METHODS,
|
|
69
|
-
];
|
|
70
|
-
export const RpcCallSchema = z.object({
|
|
71
|
-
method: z.string().min(1),
|
|
72
|
-
params: z.unknown(),
|
|
73
|
-
timeout: z.number().int().positive().default(30000),
|
|
74
|
-
});
|
|
75
|
-
export const RpcResultSchema = z.discriminatedUnion('ok', [
|
|
76
|
-
z.object({ ok: z.literal(true), result: z.unknown() }),
|
|
77
|
-
z.object({ ok: z.literal(false), error: z.string() }),
|
|
78
|
-
]);
|
|
79
|
-
export const SpawnSessionParamsSchema = z.object({
|
|
80
|
-
agentType: z.enum(CLI_AGENT_TYPES),
|
|
81
|
-
cwd: z.string().min(1),
|
|
82
|
-
prompt: z.string().optional(),
|
|
83
|
-
permissionMode: PermissionModeSchema.default('default'),
|
|
84
|
-
env: z.record(z.string()).optional(),
|
|
85
|
-
model: z.string().optional(),
|
|
86
|
-
baseUrl: z.string().url().optional(),
|
|
87
|
-
/** System prompt text appended to the agent's built-in system prompt. */
|
|
88
|
-
appendSystemPrompt: z.string().optional(),
|
|
89
|
-
/** Restrict agent to only these tools (Claude CLI --allowedTools). */
|
|
90
|
-
allowedTools: z.array(z.string()).optional(),
|
|
91
|
-
/** Deny agent from using these tools (Claude CLI --disallowedTools). */
|
|
92
|
-
disallowedTools: z.array(z.string()).optional(),
|
|
93
|
-
/** MCP server config JSON string (Claude CLI --mcp-config). */
|
|
94
|
-
mcpConfig: z.string().optional(),
|
|
95
|
-
/** Resume a previous session by ID (Claude CLI --resume). */
|
|
96
|
-
resumeSessionId: z.string().optional(),
|
|
97
|
-
/** Server session ID to reuse (skip creating new session on resume). */
|
|
98
|
-
serverSessionId: z.string().optional(),
|
|
99
|
-
/** Maximum conversation turns before auto-stop (Claude CLI --max-turns). */
|
|
100
|
-
maxTurns: z.number().int().positive().optional(),
|
|
101
|
-
/** Target machine for multi-host routing. Omit for single-machine (auto-select). */
|
|
102
|
-
machineId: z.string().min(1).optional(),
|
|
103
|
-
// ── Claude CLI extended parameters ──────────────────────────────────
|
|
104
|
-
/** Replace the default system prompt entirely (Claude CLI --system-prompt). */
|
|
105
|
-
systemPrompt: z.string().optional(),
|
|
106
|
-
/** Load system prompt from a file path (Claude CLI --system-prompt-file). */
|
|
107
|
-
systemPromptFile: z.string().optional(),
|
|
108
|
-
/** Load append system prompt from a file path (Claude CLI --append-system-prompt-file). */
|
|
109
|
-
appendSystemPromptFile: z.string().optional(),
|
|
110
|
-
/** Fallback model when primary is overloaded (Claude CLI --fallback-model). */
|
|
111
|
-
fallbackModel: z.string().optional(),
|
|
112
|
-
/** Maximum dollar amount for API calls (Claude CLI --max-budget-usd). */
|
|
113
|
-
maxBudgetUsd: z.number().positive().optional(),
|
|
114
|
-
/** Specify available tools from the built-in set (Claude CLI --tools). */
|
|
115
|
-
tools: z.array(z.string()).optional(),
|
|
116
|
-
/** Reasoning effort level (Claude CLI --effort). */
|
|
117
|
-
effort: z.enum(['low', 'medium', 'high', 'xhigh', 'max']).optional(),
|
|
118
|
-
/** Additional directories to allow tool access to (Claude CLI --add-dir). */
|
|
119
|
-
addDirs: z.array(z.string()).optional(),
|
|
120
|
-
/** Agent for the session (Claude CLI --agent). */
|
|
121
|
-
agent: z.string().optional(),
|
|
122
|
-
/** JSON object defining custom agents (Claude CLI --agents). */
|
|
123
|
-
agents: z.string().optional(),
|
|
124
|
-
/** JSON Schema for structured output validation (Claude CLI --json-schema). */
|
|
125
|
-
jsonSchema: z.string().optional(),
|
|
126
|
-
/** Only use MCP servers from --mcp-config (Claude CLI --strict-mcp-config). */
|
|
127
|
-
strictMcpConfig: z.boolean().optional(),
|
|
128
|
-
/** Enable Chrome integration (Claude CLI --chrome / --no-chrome). */
|
|
129
|
-
chrome: z.boolean().optional(),
|
|
130
|
-
/** Create a git worktree for the session (Claude CLI --worktree). */
|
|
131
|
-
worktree: z.union([z.boolean(), z.string()]).optional(),
|
|
132
|
-
/** Create a new session ID when resuming (Claude CLI --fork-session). */
|
|
133
|
-
forkSession: z.boolean().optional(),
|
|
134
|
-
/** Use a specific session UUID (Claude CLI --session-id). */
|
|
135
|
-
sessionId: z.string().uuid().optional(),
|
|
136
|
-
/** Path to settings file or JSON string (Claude CLI --settings). */
|
|
137
|
-
settings: z.string().optional(),
|
|
138
|
-
/** Beta headers for API requests (Claude CLI --betas). */
|
|
139
|
-
betas: z.array(z.string()).optional(),
|
|
140
|
-
/** Enable brief mode with SendUserMessage tool (Claude CLI --brief). */
|
|
141
|
-
brief: z.boolean().optional(),
|
|
142
|
-
/** Disable session persistence (Claude CLI --no-session-persistence). */
|
|
143
|
-
noSessionPersistence: z.boolean().optional(),
|
|
144
|
-
/** Include partial message chunks (Claude CLI --include-partial-messages). */
|
|
145
|
-
includePartialMessages: z.boolean().optional(),
|
|
146
|
-
/** Re-emit user messages for acknowledgment (Claude CLI --replay-user-messages). */
|
|
147
|
-
replayUserMessages: z.boolean().optional(),
|
|
148
|
-
/** Comma-separated setting sources (Claude CLI --setting-sources). */
|
|
149
|
-
settingSources: z.string().optional(),
|
|
150
|
-
/** Disable all skills/slash commands (Claude CLI --disable-slash-commands). */
|
|
151
|
-
disableSlashCommands: z.boolean().optional(),
|
|
152
|
-
/** File resources to download at startup (Claude CLI --file). */
|
|
153
|
-
files: z.array(z.string()).optional(),
|
|
154
|
-
/** Load plugins from directories (Claude CLI --plugin-dir). */
|
|
155
|
-
pluginDirs: z.array(z.string()).optional(),
|
|
156
|
-
/** Bypass all permission checks (Claude CLI --dangerously-skip-permissions). */
|
|
157
|
-
dangerouslySkipPermissions: z.boolean().optional(),
|
|
158
|
-
/** Enable bypass option without auto-enabling (Claude CLI --allow-dangerously-skip-permissions). */
|
|
159
|
-
allowDangerouslySkipPermissions: z.boolean().optional(),
|
|
160
|
-
/** Shell commands to execute before agent starts (same shell, && chained). */
|
|
161
|
-
startupScripts: z.array(z.string()).optional(),
|
|
162
|
-
/** Session source — 'managed' (default), 'history' (scanner), 'scheduled' (cron). */
|
|
163
|
-
source: z.enum(['managed', 'history', 'scheduled']).default('managed'),
|
|
164
|
-
/** Run in background without a terminal window. Used by scheduled tasks. */
|
|
165
|
-
background: z.boolean().default(false),
|
|
166
|
-
});
|
|
167
|
-
// ── Get Messages (session history sync) ─────────────────────────────
|
|
168
|
-
export const GetMessagesParamsSchema = z.object({
|
|
169
|
-
sessionId: z.string().min(1),
|
|
170
|
-
fromSeq: z.number().int().nonnegative().optional(),
|
|
171
|
-
limit: z.number().int().positive().default(100),
|
|
172
|
-
});
|
|
173
|
-
export const GetMessagesResponseSchema = z.object({
|
|
174
|
-
messages: z.array(SessionMessageSchema),
|
|
175
|
-
total: z.number(),
|
|
176
|
-
hasMore: z.boolean(),
|
|
177
|
-
});
|
|
178
|
-
// ── Custom Model (user-defined) ─────────────────────────────────────
|
|
179
|
-
export const CustomModelSchema = z.object({
|
|
180
|
-
id: z.string().min(1),
|
|
181
|
-
label: z.string().min(1),
|
|
182
|
-
});
|
|
183
|
-
// ── Agent Settings (proxy + env per agent) ──────────────────────────
|
|
184
|
-
export const AGENT_ENV_NONE = 'none';
|
|
185
|
-
export const AgentEnvConfigSchema = z.object({
|
|
186
|
-
httpProxy: z.string().optional(),
|
|
187
|
-
httpsProxy: z.string().optional(),
|
|
188
|
-
customEnv: z.record(z.string()).optional(),
|
|
189
|
-
customModels: z.array(CustomModelSchema).optional(),
|
|
190
|
-
});
|
|
191
|
-
export const AgentSettingsSchema = z
|
|
192
|
-
.object({
|
|
193
|
-
defaults: AgentEnvConfigSchema.optional(),
|
|
194
|
-
startupScripts: z.array(z.string()).optional(),
|
|
195
|
-
telemetryEnabled: z.boolean().optional(),
|
|
196
|
-
})
|
|
197
|
-
.merge(z.object(Object.fromEntries(SPAWNABLE_AGENTS.map((a) => [a, AgentEnvConfigSchema.optional()]))));
|
|
198
|
-
// ── Get Machine Info (daemon environment) ───────────────────────────
|
|
199
|
-
export const MachineInfoResponseSchema = z.object({
|
|
200
|
-
homedir: z.string(),
|
|
201
|
-
defaultCwd: z.string().optional(),
|
|
202
|
-
recentCwds: z.array(z.string()),
|
|
203
|
-
/** All known project directories from ~/.claude/projects/ scan. */
|
|
204
|
-
projectPaths: z.array(z.string()).optional().default([]),
|
|
205
|
-
availableAgents: z.array(z.string()),
|
|
206
|
-
agentModels: z
|
|
207
|
-
.record(z.string(), z.array(z.object({
|
|
208
|
-
id: z.string(),
|
|
209
|
-
displayName: z.string(),
|
|
210
|
-
isDefault: z.boolean(),
|
|
211
|
-
hidden: z.boolean(),
|
|
212
|
-
})))
|
|
213
|
-
.optional(),
|
|
214
|
-
agentModes: z
|
|
215
|
-
.record(z.string(), z.array(z.object({ id: z.string(), label: z.string() })))
|
|
216
|
-
.optional(),
|
|
217
|
-
agentSettings: AgentSettingsSchema.optional(),
|
|
218
|
-
});
|
|
219
|
-
// ── Check Path (validate cwd on target machine) ────────────────────
|
|
220
|
-
export const CheckPathParamsSchema = z.object({
|
|
221
|
-
cwd: z.string().min(1),
|
|
222
|
-
/** Target machine for multi-host routing. Omit for single-machine (auto-select). */
|
|
223
|
-
machineId: z.string().min(1).optional(),
|
|
224
|
-
});
|
|
225
|
-
// ── Labs Settings (experimental features) ───────────────────────────
|
|
226
|
-
export const LabsSettingsSchema = z.object({
|
|
227
|
-
/** Enable discovery and sync of CLI history sessions (experimental). */
|
|
228
|
-
historySessionSync: z.boolean().default(false),
|
|
229
|
-
});
|
|
230
|
-
//# sourceMappingURL=rpc.js.map
|
|
1
|
+
"use strict";import{z as o}from"zod";import{SessionMessageSchema as e}from"./messages.js";import{CLI_AGENT_TYPES as n,SPAWNABLE_AGENTS as s}from"./messageMeta.js";import{PermissionModeSchema as i}from"./interactionEvents.js";export const RpcMethod=o.enum(["spawn-session","stop-session","list-sessions","abort","switch-mode","approve-permission","deny-permission","answer-question","shutdown-daemon","get-messages","get-stats","get-team-stats","start-invite","get-machine-info","get-agent-settings","set-agent-settings","get-labs-settings","set-labs-settings","check-path","backfill-history-session","trigger-upgrade","checkpoint-list","checkpoint-diff","checkpoint-rollback"]),SESSION_RPC_METHODS=["answer-question","approve-permission","deny-permission","abort","stop-session"],MACHINE_RPC_METHODS=["start-invite","get-machine-info","get-agent-settings","set-agent-settings","get-labs-settings","set-labs-settings","check-path","backfill-history-session","trigger-upgrade","checkpoint-list","checkpoint-diff","checkpoint-rollback"],DAEMON_REQUIRED_RPC_METHODS=[...SESSION_RPC_METHODS,...MACHINE_RPC_METHODS],RpcCallSchema=o.object({method:o.string().min(1),params:o.unknown(),timeout:o.number().int().positive().default(3e4)}),RpcResultSchema=o.discriminatedUnion("ok",[o.object({ok:o.literal(!0),result:o.unknown()}),o.object({ok:o.literal(!1),error:o.string()})]),SpawnSessionParamsSchema=o.object({agentType:o.enum(n),cwd:o.string().min(1),prompt:o.string().optional(),permissionMode:i.default("default"),env:o.record(o.string()).optional(),model:o.string().optional(),baseUrl:o.string().url().optional(),appendSystemPrompt:o.string().optional(),allowedTools:o.array(o.string()).optional(),disallowedTools:o.array(o.string()).optional(),mcpConfig:o.string().optional(),resumeSessionId:o.string().optional(),serverSessionId:o.string().optional(),maxTurns:o.number().int().positive().optional(),machineId:o.string().min(1).optional(),systemPrompt:o.string().optional(),systemPromptFile:o.string().optional(),appendSystemPromptFile:o.string().optional(),fallbackModel:o.string().optional(),maxBudgetUsd:o.number().positive().optional(),tools:o.array(o.string()).optional(),effort:o.enum(["low","medium","high","xhigh","max"]).optional(),addDirs:o.array(o.string()).optional(),agent:o.string().optional(),agents:o.string().optional(),jsonSchema:o.string().optional(),strictMcpConfig:o.boolean().optional(),chrome:o.boolean().optional(),worktree:o.union([o.boolean(),o.string()]).optional(),forkSession:o.boolean().optional(),sessionId:o.string().uuid().optional(),settings:o.string().optional(),betas:o.array(o.string()).optional(),brief:o.boolean().optional(),noSessionPersistence:o.boolean().optional(),includePartialMessages:o.boolean().optional(),replayUserMessages:o.boolean().optional(),settingSources:o.string().optional(),disableSlashCommands:o.boolean().optional(),files:o.array(o.string()).optional(),pluginDirs:o.array(o.string()).optional(),dangerouslySkipPermissions:o.boolean().optional(),allowDangerouslySkipPermissions:o.boolean().optional(),startupScripts:o.array(o.string()).optional(),source:o.enum(["managed","history","scheduled"]).default("managed"),background:o.boolean().default(!1)}),GetMessagesParamsSchema=o.object({sessionId:o.string().min(1),fromSeq:o.number().int().nonnegative().optional(),limit:o.number().int().positive().default(100)}),GetMessagesResponseSchema=o.object({messages:o.array(e),total:o.number(),hasMore:o.boolean()}),CustomModelSchema=o.object({id:o.string().min(1),label:o.string().min(1)}),AGENT_ENV_NONE="none",AgentEnvConfigSchema=o.object({httpProxy:o.string().optional(),httpsProxy:o.string().optional(),customEnv:o.record(o.string()).optional(),customModels:o.array(CustomModelSchema).optional()}),AgentSettingsSchema=o.object({defaults:AgentEnvConfigSchema.optional(),startupScripts:o.array(o.string()).optional(),telemetryEnabled:o.boolean().optional()}).merge(o.object(Object.fromEntries(s.map(t=>[t,AgentEnvConfigSchema.optional()])))),MachineInfoResponseSchema=o.object({homedir:o.string(),defaultCwd:o.string().optional(),recentCwds:o.array(o.string()),projectPaths:o.array(o.string()).optional().default([]),availableAgents:o.array(o.string()),agentModels:o.record(o.string(),o.array(o.object({id:o.string(),displayName:o.string(),isDefault:o.boolean(),hidden:o.boolean()}))).optional(),agentModes:o.record(o.string(),o.array(o.object({id:o.string(),label:o.string()}))).optional(),agentSettings:AgentSettingsSchema.optional()}),CheckPathParamsSchema=o.object({cwd:o.string().min(1),machineId:o.string().min(1).optional()}),LabsSettingsSchema=o.object({historySessionSync:o.boolean().default(!1)});
|
package/dist/scheduledTasks.js
CHANGED
|
@@ -1,81 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SpawnSessionParamsSchema } from './rpc.js';
|
|
3
|
-
// Derived from source schema via .pick() — no independent definition
|
|
4
|
-
// Extended with scheduler-only config fields (no migration needed, stored in spawnParams JSON).
|
|
5
|
-
export const RetryPolicySchema = z.object({
|
|
6
|
-
maxRetries: z.number().int().min(0).max(10).default(0),
|
|
7
|
-
retryDelayMs: z.number().int().min(1000).max(300000).default(60000),
|
|
8
|
-
});
|
|
9
|
-
export const MissedRunPolicySchema = z.enum(['skip', 'run-once']);
|
|
10
|
-
export const ScheduledSpawnParamsSchema = SpawnSessionParamsSchema.pick({
|
|
11
|
-
agentType: true,
|
|
12
|
-
cwd: true,
|
|
13
|
-
prompt: true,
|
|
14
|
-
model: true,
|
|
15
|
-
agent: true,
|
|
16
|
-
startupScripts: true,
|
|
17
|
-
})
|
|
18
|
-
.partial()
|
|
19
|
-
.required({ prompt: true })
|
|
20
|
-
.extend({
|
|
21
|
-
maxExecutionMs: z.number().int().positive().max(21600000).optional(),
|
|
22
|
-
retryPolicy: RetryPolicySchema.optional(),
|
|
23
|
-
missedRunPolicy: MissedRunPolicySchema.optional(),
|
|
24
|
-
circuitBreakerThreshold: z.number().int().min(1).max(20).optional(),
|
|
25
|
-
});
|
|
26
|
-
export const TaskExecutionStatusSchema = z.enum([
|
|
27
|
-
'pending',
|
|
28
|
-
'running',
|
|
29
|
-
'completed',
|
|
30
|
-
'failed',
|
|
31
|
-
'lost',
|
|
32
|
-
'skipped',
|
|
33
|
-
'cancelled',
|
|
34
|
-
]);
|
|
35
|
-
export const TaskExecutionTriggerSchema = z.enum(['scheduled', 'manual']);
|
|
36
|
-
// Basic 5-field cron format validation (each field: digits, *, -, /, ,).
|
|
37
|
-
// Server uses cron-parser for thorough range/interval validation.
|
|
38
|
-
export const CRON_RE = /^[0-9*/, -]+ [0-9*/, -]+ [0-9*/, -]+ [0-9*/, -]+ [0-9*/, -]+$/;
|
|
39
|
-
// API request/response schemas
|
|
40
|
-
export const CreateScheduledTaskSchema = z.object({
|
|
41
|
-
name: z.string().min(1).max(100),
|
|
42
|
-
schedule: z.string().min(1).max(100).regex(CRON_RE, 'Invalid 5-field cron expression'),
|
|
43
|
-
enabled: z.boolean().optional().default(true),
|
|
44
|
-
machineId: z.string().min(1).optional(),
|
|
45
|
-
spawnParams: ScheduledSpawnParamsSchema,
|
|
46
|
-
});
|
|
47
|
-
export const UpdateScheduledTaskSchema = CreateScheduledTaskSchema.partial();
|
|
48
|
-
export const ScheduledTaskSummarySchema = z.object({
|
|
49
|
-
id: z.string(),
|
|
50
|
-
name: z.string(),
|
|
51
|
-
schedule: z.string(),
|
|
52
|
-
enabled: z.boolean(),
|
|
53
|
-
machineId: z.string().nullable(),
|
|
54
|
-
nextRunAt: z.string().nullable(),
|
|
55
|
-
lastRunAt: z.string().nullable(),
|
|
56
|
-
lastExecution: z
|
|
57
|
-
.object({
|
|
58
|
-
status: TaskExecutionStatusSchema,
|
|
59
|
-
summary: z.string().nullable(),
|
|
60
|
-
})
|
|
61
|
-
.nullable(),
|
|
62
|
-
createdAt: z.string(),
|
|
63
|
-
updatedAt: z.string(),
|
|
64
|
-
consecutiveFailures: z.number().int(),
|
|
65
|
-
disabledReason: z.string().nullable(),
|
|
66
|
-
});
|
|
67
|
-
export const TaskExecutionSchema = z.object({
|
|
68
|
-
id: z.string(),
|
|
69
|
-
taskId: z.string(),
|
|
70
|
-
sessionId: z.string().nullable(),
|
|
71
|
-
status: TaskExecutionStatusSchema,
|
|
72
|
-
trigger: TaskExecutionTriggerSchema,
|
|
73
|
-
scheduledAt: z.string(),
|
|
74
|
-
startedAt: z.string().nullable(),
|
|
75
|
-
completedAt: z.string().nullable(),
|
|
76
|
-
error: z.string().nullable(),
|
|
77
|
-
retryCount: z.number(),
|
|
78
|
-
summary: z.string().nullable(),
|
|
79
|
-
createdAt: z.string(),
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=scheduledTasks.js.map
|
|
1
|
+
"use strict";import{z as e}from"zod";import{SpawnSessionParamsSchema as t}from"./rpc.js";export const RetryPolicySchema=e.object({maxRetries:e.number().int().min(0).max(10).default(0),retryDelayMs:e.number().int().min(1e3).max(3e5).default(6e4)}),MissedRunPolicySchema=e.enum(["skip","run-once"]),ScheduledSpawnParamsSchema=t.pick({agentType:!0,cwd:!0,prompt:!0,model:!0,agent:!0,startupScripts:!0}).partial().required({prompt:!0}).extend({maxExecutionMs:e.number().int().positive().max(216e5).optional(),retryPolicy:RetryPolicySchema.optional(),missedRunPolicy:MissedRunPolicySchema.optional(),circuitBreakerThreshold:e.number().int().min(1).max(20).optional()}),TaskExecutionStatusSchema=e.enum(["pending","running","completed","failed","lost","skipped","cancelled"]),TaskExecutionTriggerSchema=e.enum(["scheduled","manual"]),CRON_RE=/^[0-9*/, -]+ [0-9*/, -]+ [0-9*/, -]+ [0-9*/, -]+ [0-9*/, -]+$/,CreateScheduledTaskSchema=e.object({name:e.string().min(1).max(100),schedule:e.string().min(1).max(100).regex(CRON_RE,"Invalid 5-field cron expression"),enabled:e.boolean().optional().default(!0),machineId:e.string().min(1).optional(),spawnParams:ScheduledSpawnParamsSchema}),UpdateScheduledTaskSchema=CreateScheduledTaskSchema.partial(),ScheduledTaskSummarySchema=e.object({id:e.string(),name:e.string(),schedule:e.string(),enabled:e.boolean(),machineId:e.string().nullable(),nextRunAt:e.string().nullable(),lastRunAt:e.string().nullable(),lastExecution:e.object({status:TaskExecutionStatusSchema,summary:e.string().nullable()}).nullable(),createdAt:e.string(),updatedAt:e.string(),consecutiveFailures:e.number().int(),disabledReason:e.string().nullable()}),TaskExecutionSchema=e.object({id:e.string(),taskId:e.string(),sessionId:e.string().nullable(),status:TaskExecutionStatusSchema,trigger:TaskExecutionTriggerSchema,scheduledAt:e.string(),startedAt:e.string().nullable(),completedAt:e.string().nullable(),error:e.string().nullable(),retryCount:e.number(),summary:e.string().nullable(),createdAt:e.string()});
|