@agentdock/wire 0.0.90 → 0.0.91
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/activityPreferences.js +1 -2
- package/dist/agentCapabilities.d.ts +2 -0
- package/dist/agentCapabilities.js +1 -199
- package/dist/agentCommonEnv.js +1 -20
- package/dist/agentInstallGuide.js +1 -81
- package/dist/bgTask.js +1 -128
- package/dist/checkpointSchemas.d.ts +142 -98
- package/dist/checkpointSchemas.js +1 -46
- package/dist/controlLevel.js +1 -11
- package/dist/edition.js +1 -13
- package/dist/envelope.d.ts +5668 -563
- package/dist/envelope.js +1 -77
- package/dist/errorMessage.js +1 -6
- package/dist/events.d.ts +2053 -324
- package/dist/events.js +1 -107
- package/dist/features.js +1 -123
- package/dist/feedback.d.ts +2 -2
- package/dist/feedback.js +1 -61
- package/dist/fileWhitelist.js +1 -189
- package/dist/inboundEvents.d.ts +531 -0
- package/dist/inboundEvents.js +1 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +1 -73
- package/dist/interactionEvents.d.ts +153 -106
- package/dist/interactionEvents.js +1 -111
- package/dist/legacyProtocol.d.ts +512 -272
- package/dist/legacyProtocol.js +1 -30
- package/dist/license.js +1 -28
- package/dist/machine.d.ts +108 -62
- package/dist/machine.js +1 -66
- package/dist/messageMeta.d.ts +34 -28
- package/dist/messageMeta.js +1 -60
- package/dist/messages.d.ts +34900 -1862
- package/dist/messages.js +1 -35
- package/dist/notification.d.ts +48 -0
- package/dist/notification.js +1 -0
- package/dist/ops.d.ts +165 -122
- package/dist/ops.js +1 -74
- package/dist/pairing.d.ts +4 -4
- package/dist/pairing.js +1 -150
- package/dist/permissionSubject.js +1 -68
- package/dist/protocol.js +1 -7
- package/dist/rpc.d.ts +749 -189
- package/dist/rpc.js +1 -269
- package/dist/scheduledTasks.d.ts +619 -304
- package/dist/scheduledTasks.js +1 -188
- package/dist/semver.js +1 -60
- package/dist/sessionResult.d.ts +31 -17
- package/dist/sessionResult.js +1 -23
- package/dist/socketEvents.d.ts +7 -0
- package/dist/socketEvents.js +1 -55
- package/dist/sourceMetadata.d.ts +44 -0
- package/dist/sourceMetadata.js +1 -0
- package/dist/spawnError.d.ts +21 -17
- package/dist/spawnError.js +1 -31
- package/dist/stats.d.ts +73 -73
- package/dist/stats.js +1 -117
- package/dist/sync.d.ts +2165 -819
- package/dist/sync.js +1 -99
- package/dist/taskResult.js +1 -113
- package/dist/telemetry.d.ts +120 -64
- package/dist/telemetry.js +1 -115
- package/dist/utils.js +1 -2
- package/package.json +3 -2
- package/dist/activityPreferences.d.ts.map +0 -1
- package/dist/activityPreferences.js.map +0 -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/bgTask.d.ts.map +0 -1
- package/dist/bgTask.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/edition.d.ts.map +0 -1
- package/dist/edition.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/fileWhitelist.d.ts.map +0 -1
- package/dist/fileWhitelist.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/license.d.ts.map +0 -1
- package/dist/license.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/permissionSubject.d.ts.map +0 -1
- package/dist/permissionSubject.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/taskResult.d.ts.map +0 -1
- package/dist/taskResult.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/pairing.js
CHANGED
|
@@ -1,150 +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
|
-
// KNOWN-DEBT: KNOWN_DERIVATION_VERSIONS 预导出无跨包消费者 (see docs/ops/KNOWN-DEBT.md)
|
|
13
|
-
import { z } from 'zod';
|
|
14
|
-
/** 6-digit numeric PIN for iOS PWA fallback. */
|
|
15
|
-
const PinSchema = z.string().regex(/^\d{6}$/, 'PIN must be exactly 6 digits');
|
|
16
|
-
/** Pairing state machine. */
|
|
17
|
-
export const PairingState = z.enum(['pending', 'exchange', 'authorized', 'expired']);
|
|
18
|
-
/**
|
|
19
|
-
* Validates that a string is a base64/base64url-encoded 32-byte Curve25519 public key.
|
|
20
|
-
* Accepts both standard base64 (with padding) and base64url (without padding).
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Check if a base64/base64url string decodes to exactly `expectedBytes` bytes.
|
|
24
|
-
* Uses string-length math: 4 base64 chars = 3 bytes.
|
|
25
|
-
* No runtime decoding needed — just validate charset + length.
|
|
26
|
-
*/
|
|
27
|
-
function isBase64OfLength(val, expectedBytes) {
|
|
28
|
-
// Must be non-empty and only valid base64/base64url characters
|
|
29
|
-
if (!/^[A-Za-z0-9+/\-_]+=*$/.test(val))
|
|
30
|
-
return false;
|
|
31
|
-
// Normalize base64url → standard base64
|
|
32
|
-
const b64 = val.replace(/-/g, '+').replace(/_/g, '/');
|
|
33
|
-
const padded = b64.padEnd(b64.length + ((4 - (b64.length % 4)) % 4), '=');
|
|
34
|
-
// Count padding
|
|
35
|
-
const paddingCount = (padded.match(/=+$/) ?? [''])[0].length;
|
|
36
|
-
const totalBytes = (padded.length / 4) * 3 - paddingCount;
|
|
37
|
-
return totalBytes === expectedBytes;
|
|
38
|
-
}
|
|
39
|
-
const Curve25519PublicKeySchema = z
|
|
40
|
-
.string()
|
|
41
|
-
.min(1)
|
|
42
|
-
.refine((val) => isBase64OfLength(val, 32), {
|
|
43
|
-
message: 'publicKey must be a base64-encoded 32-byte Curve25519 key',
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* CLI → Server: initiate a pairing request.
|
|
47
|
-
*
|
|
48
|
-
* publicKey: base64-encoded Curve25519 public key (32 bytes)
|
|
49
|
-
* pin: optional 6-digit PIN for manual entry (iOS PWA fallback)
|
|
50
|
-
* label: optional human-readable device label
|
|
51
|
-
*/
|
|
52
|
-
export const PairingRequestSchema = z.object({
|
|
53
|
-
publicKey: Curve25519PublicKeySchema,
|
|
54
|
-
pin: PinSchema.optional(),
|
|
55
|
-
label: z.string().max(100).optional(),
|
|
56
|
-
type: z.enum(['join', 'invite']).optional(),
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Web → Server: approve pairing with encrypted key material.
|
|
60
|
-
*
|
|
61
|
-
* publicKey: identifies which pairing request to respond to (32-byte Curve25519 key)
|
|
62
|
-
* encryptedPayload: NaCl Box encrypted data (base64) containing the DEK
|
|
63
|
-
*/
|
|
64
|
-
export const PairingResponseSchema = z.object({
|
|
65
|
-
publicKey: Curve25519PublicKeySchema,
|
|
66
|
-
encryptedPayload: z.string().min(1),
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* New device → Server: submit device's temporary Curve25519 public key.
|
|
70
|
-
* Used in invite flow when a new device joins an existing account.
|
|
71
|
-
*/
|
|
72
|
-
export const PairingExchangeSchema = z.object({
|
|
73
|
-
daemonPublicKey: Curve25519PublicKeySchema,
|
|
74
|
-
devicePublicKey: Curve25519PublicKeySchema,
|
|
75
|
-
});
|
|
76
|
-
/**
|
|
77
|
-
* Daemon → Server: deliver encrypted master secret to new device.
|
|
78
|
-
* Requires Bearer auth. Encrypted via NaCl Box using device's public key.
|
|
79
|
-
*/
|
|
80
|
-
export const PairingDeliverSchema = z.object({
|
|
81
|
-
publicKey: Curve25519PublicKeySchema,
|
|
82
|
-
encryptedPayload: z.string().min(1),
|
|
83
|
-
});
|
|
84
|
-
/**
|
|
85
|
-
* Server → CLI: current pairing status (polled).
|
|
86
|
-
* Discriminated union on `state`:
|
|
87
|
-
* - pending: waiting for web approval
|
|
88
|
-
* - authorized: web approved, encryptedPayload + token required
|
|
89
|
-
* - expired: request timed out
|
|
90
|
-
*/
|
|
91
|
-
const PairingStatusPending = z.object({
|
|
92
|
-
state: z.literal('pending'),
|
|
93
|
-
publicKey: z.string().min(1),
|
|
94
|
-
});
|
|
95
|
-
const PairingStatusExchange = z.object({
|
|
96
|
-
state: z.literal('exchange'),
|
|
97
|
-
publicKey: z.string().min(1),
|
|
98
|
-
devicePublicKey: z.string().min(1),
|
|
99
|
-
});
|
|
100
|
-
const PairingStatusAuthorized = z.object({
|
|
101
|
-
state: z.literal('authorized'),
|
|
102
|
-
publicKey: z.string().min(1),
|
|
103
|
-
encryptedPayload: z.string().min(1),
|
|
104
|
-
token: z.string().min(1),
|
|
105
|
-
});
|
|
106
|
-
const PairingStatusExpired = z.object({
|
|
107
|
-
state: z.literal('expired'),
|
|
108
|
-
publicKey: z.string().min(1),
|
|
109
|
-
});
|
|
110
|
-
export const PairingStatusSchema = z.discriminatedUnion('state', [
|
|
111
|
-
PairingStatusPending,
|
|
112
|
-
PairingStatusExchange,
|
|
113
|
-
PairingStatusAuthorized,
|
|
114
|
-
PairingStatusExpired,
|
|
115
|
-
]);
|
|
116
|
-
/** Known derivation versions (whitelist). */
|
|
117
|
-
export const KNOWN_DERIVATION_VERSIONS = new Set([0, 1]);
|
|
118
|
-
/**
|
|
119
|
-
* Current derivation version for newly created identities.
|
|
120
|
-
* 0 = legacy ('Happy EnCoder'), 1 = CCPark ('CCPark EnCoder').
|
|
121
|
-
*/
|
|
122
|
-
export const CURRENT_DERIVATION_VERSION = 1;
|
|
123
|
-
/**
|
|
124
|
-
* Encode a master secret with its derivation version as a pairing payload.
|
|
125
|
-
* Inverse of {@link parseVersionByte}: produces [version_byte, ...masterSecret] (33 bytes).
|
|
126
|
-
*/
|
|
127
|
-
export function encodeVersionByte(masterSecret, version) {
|
|
128
|
-
const payload = new Uint8Array(1 + masterSecret.length);
|
|
129
|
-
payload[0] = version;
|
|
130
|
-
payload.set(masterSecret, 1);
|
|
131
|
-
return payload;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Parse derivation version from decrypted pairing payload.
|
|
135
|
-
* Version 1+: payload = [version_byte, ...masterSecret] (33 bytes)
|
|
136
|
-
* Version 0 (legacy): payload = masterSecret (32 bytes, no prefix)
|
|
137
|
-
* Returns null for unknown versions or unexpected lengths.
|
|
138
|
-
*/
|
|
139
|
-
export function parseVersionByte(rawPayload) {
|
|
140
|
-
if (rawPayload.length === 33 && rawPayload[0] !== undefined) {
|
|
141
|
-
if (!KNOWN_DERIVATION_VERSIONS.has(rawPayload[0]))
|
|
142
|
-
return null;
|
|
143
|
-
return { masterSecret: rawPayload.slice(1), derivationVersion: rawPayload[0] };
|
|
144
|
-
}
|
|
145
|
-
if (rawPayload.length === 32) {
|
|
146
|
-
return { masterSecret: rawPayload, derivationVersion: 0 };
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
//# 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 a(t,r){if(!/^[A-Za-z0-9+/\-_]+=*$/.test(t))return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/"),c=n.padEnd(n.length+(4-n.length%4)%4,"="),s=(c.match(/=+$/)??[""])[0].length;return c.length/4*3-s===r}const i=e.string().min(1).refine(t=>a(t,32),{message:"publicKey must be a base64-encoded 32-byte Curve25519 key"});export const PairingRequestSchema=e.object({publicKey:i,pin:o.optional(),label:e.string().max(100).optional(),type:e.enum(["join","invite"]).optional()}).strict(),PairingResponseSchema=e.object({publicKey:i,encryptedPayload:e.string().min(1)}).strict(),PairingExchangeSchema=e.object({daemonPublicKey:i,devicePublicKey:i}).strict(),PairingDeliverSchema=e.object({publicKey:i,encryptedPayload:e.string().min(1)}).strict();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)}),u=e.object({state:e.literal("authorized"),publicKey:e.string().min(1),encryptedPayload:e.string().min(1),token:e.string().min(1)}),p=e.object({state:e.literal("expired"),publicKey:e.string().min(1)});export const PairingStatusSchema=e.discriminatedUnion("state",[g,l,u,p]),KNOWN_DERIVATION_VERSIONS=new Set([0,1]),CURRENT_DERIVATION_VERSION=1;export function encodeVersionByte(t,r){const n=new Uint8Array(1+t.length);return n[0]=r,n.set(t,1),n}export function parseVersionByte(t){return t.length===33&&t[0]!==void 0?KNOWN_DERIVATION_VERSIONS.has(t[0])?{masterSecret:t.slice(1),derivationVersion:t[0]}:null:t.length===32?{masterSecret:t,derivationVersion:0}:null}
|
|
@@ -1,68 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// extraction. Shared by the web rule generator (useInteraction.makeRuleIdentifier)
|
|
3
|
-
// and the daemon matcher (permissionRuleStore.extractSubject).
|
|
4
|
-
//
|
|
5
|
-
// WHY HERE: web and daemon are the two consumers; wire is their only common
|
|
6
|
-
// upstream (wire→…→web, wire→…→daemon). Doing the first-token/basename transform
|
|
7
|
-
// in ONE place stops the two sides from drifting apart. When they drift:
|
|
8
|
-
// - front-end stores a rule the daemon can never match → "allow and don't ask
|
|
9
|
-
// again" silently keeps re-prompting (Bug 1), or
|
|
10
|
-
// - the subject degrades to '' and `x.startsWith('')` matches EVERY command,
|
|
11
|
-
// whitelisting all shell commands (Bug 2, a security hole).
|
|
12
|
-
//
|
|
13
|
-
// SCOPE: applies ONLY to the `command` field of Bash-like tools. path / url /
|
|
14
|
-
// pattern subjects MUST keep their full prefix and are handled by the caller
|
|
15
|
-
// (see permissionRuleStore.extractSubject field priority).
|
|
16
|
-
/**
|
|
17
|
-
* Raw agent tool names whose input carries a `command` field. These are the
|
|
18
|
-
* ORIGINAL agent-emitted names (NOT normalized): Claude `Bash`, OpenCode/Hermes/
|
|
19
|
-
* OpenClaw `execute`, Codex `shell`. The permission-request event and the danger
|
|
20
|
-
* detector both see raw names, so this set is matched against raw names.
|
|
21
|
-
*/
|
|
22
|
-
export const BASH_TOOL_NAMES = new Set(['Bash', 'bash', 'execute', 'shell']);
|
|
23
|
-
/** True when `toolName` (a raw agent name) is a Bash-like command tool. */
|
|
24
|
-
export function isBashToolName(toolName) {
|
|
25
|
-
return BASH_TOOL_NAMES.has(toolName);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Extract the prefix subject from a Bash-like command string:
|
|
29
|
-
* trim → first token (quote-aware so `"C:\Program Files\..."` isn't split on
|
|
30
|
-
* spaces) → basename (`.../pwsh.exe` → `pwsh.exe`).
|
|
31
|
-
*
|
|
32
|
-
* Returns '' ONLY for an empty/blank command. When the first token ends in a
|
|
33
|
-
* path separator its basename is empty; we fall back to the un-split token
|
|
34
|
-
* rather than '' — an empty subject makes every command match
|
|
35
|
-
* (`x.startsWith('')` is always true), the Bug 2 security hole.
|
|
36
|
-
*/
|
|
37
|
-
export function extractCommandSubject(command) {
|
|
38
|
-
const trimmed = command.trim();
|
|
39
|
-
if (!trimmed)
|
|
40
|
-
return '';
|
|
41
|
-
let firstToken;
|
|
42
|
-
if (trimmed[0] === '"' || trimmed[0] === "'") {
|
|
43
|
-
const quote = trimmed[0];
|
|
44
|
-
const end = trimmed.indexOf(quote, 1);
|
|
45
|
-
firstToken = end > 0 ? trimmed.slice(1, end) : trimmed.slice(1);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
firstToken = trimmed.split(/\s+/)[0] ?? trimmed;
|
|
49
|
-
}
|
|
50
|
-
// Basename: "C:\...\pwsh.exe" → "pwsh.exe". A trailing separator yields ''
|
|
51
|
-
// from .pop(); '' is not nullish so '??' won't catch it — guard on truthiness
|
|
52
|
-
// and fall back to the full token so the subject never degrades to '' (Bug 2).
|
|
53
|
-
const base = firstToken.split(/[/\\]/).pop();
|
|
54
|
-
const clean = base ? base : firstToken;
|
|
55
|
-
// Strip quotes that survived token extraction — shell variable assignments
|
|
56
|
-
// like FILE="/path/to/tool" leave a trailing/leading quote in the basename.
|
|
57
|
-
return clean.replace(/^["']|["']$/g, '');
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Minimum length for a command subject to be used in a prefix rule.
|
|
61
|
-
* Single-char subjects (e.g. `#` from a comment line, `.` from a dotfile)
|
|
62
|
-
* are too broad — they effectively wildcard-match every command that starts
|
|
63
|
-
* with that character.
|
|
64
|
-
*
|
|
65
|
-
* Used by the front-end to reject overly broad rules before they are stored.
|
|
66
|
-
*/
|
|
67
|
-
export const MIN_SUBJECT_LENGTH = 2;
|
|
68
|
-
//# sourceMappingURL=permissionSubject.js.map
|
|
1
|
+
"use strict";export const BASH_TOOL_NAMES=new Set(["Bash","bash","execute","shell"]);export function isBashToolName(n){return BASH_TOOL_NAMES.has(n)}export function extractCommandSubject(n){const e=n.trim();if(!e)return"";let t;if(e[0]==='"'||e[0]==="'"){const c=e[0],o=e.indexOf(c,1);t=o>0?e.slice(1,o):e.slice(1)}else t=e.split(/\s+/)[0]??e;const s=t.split(/[/\\]/).pop();return(s||t).replace(/^["']|["']$/g,"")}export const MIN_SUBJECT_LENGTH=2;
|
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;
|