session-peer 0.5.2 → 0.6.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/PARITY.md +20 -5
- package/README.ja.md +8 -8
- package/README.ko.md +8 -8
- package/README.md +8 -8
- package/README.zh-CN.md +8 -8
- package/RELEASING.md +73 -0
- package/VALIDATION.md +102 -1
- package/dist/cli.js +54 -4
- package/dist/diagnostics.js +17 -98
- package/dist/discovery.d.ts +32 -0
- package/dist/discovery.js +405 -68
- package/dist/handoff-operations.js +23 -3
- package/dist/help.js +18 -2
- package/dist/macos-acl.d.ts +10 -0
- package/dist/macos-acl.js +75 -0
- package/dist/output.js +6 -1
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +1 -1
- package/dist/receipt-collector.d.ts +12 -0
- package/dist/receipt-collector.js +283 -0
- package/dist/receipt-command.d.ts +10 -0
- package/dist/receipt-command.js +246 -0
- package/dist/receipt-producer.d.ts +7 -0
- package/dist/receipt-producer.js +107 -0
- package/dist/receipt-protocol.d.ts +219 -0
- package/dist/receipt-protocol.js +374 -0
- package/dist/receipt-send.d.ts +26 -0
- package/dist/receipt-send.js +375 -0
- package/dist/receipt-state.d.ts +89 -0
- package/dist/receipt-state.js +503 -0
- package/dist/receipt-store.d.ts +32 -0
- package/dist/receipt-store.js +286 -0
- package/dist/replies.js +3 -1
- package/dist/send.d.ts +5 -2
- package/dist/send.js +34 -49
- package/dist/skill-metadata.js +4 -3
- package/docs/api.md +32 -7
- package/docs/design/typescript-skill-compatibility.md +29 -0
- package/docs/guide.ja.md +41 -15
- package/docs/guide.ko.md +43 -17
- package/docs/guide.md +42 -16
- package/docs/guide.zh-CN.md +41 -15
- package/docs/shorthand.md +1 -1
- package/package.json +3 -3
package/dist/diagnostics.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// Diagnostics read bounded configuration and metadata, returning sanitized checks.
|
|
2
2
|
// Never probe/connect to an inbox,
|
|
3
3
|
// acquire a writer lock, execute an agent binary, or write configuration.
|
|
4
|
-
import { accessSync, constants,
|
|
4
|
+
import { accessSync, constants, statSync } from 'node:fs';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { delimiter, isAbsolute, join } from 'node:path';
|
|
7
|
-
import { listingCandidates } from './discovery.js';
|
|
7
|
+
import { claudeInventory, listingCandidates } from './discovery.js';
|
|
8
8
|
import { classifyCodexStorage, storageDiagnostic } from './codex-storage.js';
|
|
9
9
|
import { inspectSkill } from './skill-metadata.js';
|
|
10
10
|
import { batchShim } from './process.js';
|
|
11
|
-
import { windowsProcessStart } from './windows.js';
|
|
12
11
|
const failure = (error, missing, unknown) => {
|
|
13
12
|
const code = error.code;
|
|
14
13
|
return code === 'ENOENT' || code === 'ENOTDIR' ? { status: 'missing', code: missing } :
|
|
@@ -86,104 +85,24 @@ export async function diagnoseCodex(home, binary) {
|
|
|
86
85
|
sendAuthorized: false };
|
|
87
86
|
}
|
|
88
87
|
export function diagnoseClaude() {
|
|
89
|
-
const
|
|
90
|
-
const result = { sessionsDir:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
for (const entry of entries) {
|
|
102
|
-
if (!/^[0-9]+\.json$/.test(entry))
|
|
103
|
-
continue;
|
|
104
|
-
let record;
|
|
105
|
-
try {
|
|
106
|
-
const path = join(directory, entry), info = statSync(path);
|
|
107
|
-
if (!info.isFile() || info.size > 65536) {
|
|
108
|
-
result.invalidRecords++;
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const value = JSON.parse(readFileSync(path, 'utf8'));
|
|
112
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
113
|
-
result.invalidRecords++;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
record = value;
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
if (['EACCES', 'EPERM'].includes(error.code ?? ''))
|
|
120
|
-
result.permissionFailures++;
|
|
121
|
-
else if (error instanceof SyntaxError)
|
|
122
|
-
result.invalidRecords++;
|
|
123
|
-
else
|
|
124
|
-
result.unknownInspections++;
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
const pid = record.pid;
|
|
128
|
-
if (typeof pid !== 'number' || !Number.isSafeInteger(pid) || pid <= 1 || pid > 2147483647) {
|
|
129
|
-
result.invalidRecords++;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
result.records++;
|
|
133
|
-
if (pid !== Number(entry.slice(0, -5))) {
|
|
134
|
-
result.staleRecords++;
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
let live = false;
|
|
138
|
-
if (process.platform === 'win32') {
|
|
139
|
-
const ticks = windowsProcessStart(pid);
|
|
140
|
-
if (ticks === undefined || typeof record.startedAt !== 'number' || !Number.isSafeInteger(record.startedAt) || record.startedAt <= 0) {
|
|
141
|
-
result.unknownInspections++;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
live = Number((ticks - 116444736000000000n) / 10000n) <= record.startedAt + 2000;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
try {
|
|
148
|
-
process.kill(pid, 0);
|
|
149
|
-
live = true;
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
if (error.code !== 'ESRCH') {
|
|
153
|
-
result.unknownInspections++;
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (!live) {
|
|
159
|
-
result.staleRecords++;
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
result.aliveSessions++;
|
|
163
|
-
const socket = typeof record.messagingSocketPath === 'string' ? record.messagingSocketPath : '';
|
|
164
|
-
if (process.platform === 'win32') {
|
|
165
|
-
// A named pipe advertisement is not proof that the pipe exists or accepts connections.
|
|
166
|
-
if (/^\\\\\.\\pipe\\[^\r\n]+$/i.test(socket))
|
|
167
|
-
result.availableInboxes++;
|
|
168
|
-
}
|
|
169
|
-
else if (socket) {
|
|
170
|
-
try {
|
|
171
|
-
if (statSync(socket).isSocket())
|
|
172
|
-
result.availableInboxes++;
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
if (!['ENOENT', 'ENOTDIR'].includes(error.code ?? '')) {
|
|
176
|
-
result.unknownInspections++;
|
|
177
|
-
if (['EACCES', 'EPERM'].includes(error.code ?? ''))
|
|
178
|
-
result.permissionFailures++;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
88
|
+
const inventory = claudeInventory(), rows = inventory.sessions;
|
|
89
|
+
const result = { sessionsDir: inventory.directories[0], records: inventory.records,
|
|
90
|
+
invalidRecords: inventory.invalidRecords, aliveSessions: rows.filter(row => row.alive).length,
|
|
91
|
+
availableInboxes: rows.filter(row => row.reachable).length,
|
|
92
|
+
staleRecords: rows.filter(row => !row.alive && row.staleReason !== 'process_unverified').length,
|
|
93
|
+
unknownInspections: inventory.unknownInspections, permissionFailures: inventory.permissionFailures };
|
|
94
|
+
if (inventory.selectedStatus !== 'present' && (inventory.selectedStatus !== 'missing' || inventory.errors.length === 0) &&
|
|
95
|
+
rows.length === 0 && inventory.directories.length === 1) {
|
|
96
|
+
const status = inventory.selectedStatus;
|
|
97
|
+
return { ...result, ready: false, status, code: status === 'missing' ? 'sessions_dir_missing' :
|
|
98
|
+
status === 'unsupported' ? 'sessions_path_not_directory' : status === 'permission_denied' ? 'permission_denied' : 'sessions_dir_unreadable' };
|
|
182
99
|
}
|
|
183
|
-
const ready = result.availableInboxes > 0 &&
|
|
100
|
+
const ready = result.availableInboxes > 0 && inventory.errors.length === 0 && result.unknownInspections === 0;
|
|
184
101
|
const code = result.permissionFailures ? 'permission_denied' : result.unknownInspections ? 'inspection_unknown' :
|
|
185
|
-
|
|
102
|
+
inventory.errors.length ? 'claude_discovery_incomplete' : result.availableInboxes ? 'inbox_advertised' :
|
|
103
|
+
result.aliveSessions ? 'inbox_unavailable' : 'no_live_sessions';
|
|
186
104
|
return { ...result, ready, status: ready ? 'available' : 'unavailable', code,
|
|
105
|
+
...(inventory.errors.length ? { errors: inventory.errors } : {}),
|
|
187
106
|
verification: process.platform === 'win32' ? 'process_and_pipe_advertisement' : 'process_and_filesystem',
|
|
188
107
|
inboxConnected: false, sendAuthorized: false };
|
|
189
108
|
}
|
package/dist/discovery.d.ts
CHANGED
|
@@ -5,6 +5,38 @@ export declare class Refusal extends Error {
|
|
|
5
5
|
constructor(code: string, exitCode?: number);
|
|
6
6
|
}
|
|
7
7
|
export declare function canonical(path: string): string;
|
|
8
|
+
export declare const CLAUDE_PROFILE_LIMIT = 128;
|
|
9
|
+
export declare const CLAUDE_ENTRY_LIMIT = 4096;
|
|
10
|
+
export declare const CLAUDE_ACL_LIMITS: Readonly<{
|
|
11
|
+
paths: 4481;
|
|
12
|
+
batchPaths: 128;
|
|
13
|
+
argumentBytes: 32768;
|
|
14
|
+
batchOutput: 262144;
|
|
15
|
+
totalOutput: 8388608;
|
|
16
|
+
batches: 128;
|
|
17
|
+
timeoutMs: 5000;
|
|
18
|
+
}>;
|
|
19
|
+
export type ClaudeInventory = {
|
|
20
|
+
sessions: Row[];
|
|
21
|
+
errors: string[];
|
|
22
|
+
directories: string[];
|
|
23
|
+
records: number;
|
|
24
|
+
invalidRecords: number;
|
|
25
|
+
permissionFailures: number;
|
|
26
|
+
unknownInspections: number;
|
|
27
|
+
selectedStatus: 'present' | 'missing' | 'unsupported' | 'permission_denied' | 'unknown';
|
|
28
|
+
};
|
|
29
|
+
export declare function claudeInventory(): ClaudeInventory;
|
|
30
|
+
export declare function revalidateClaudeInventory(row: Row, other?: Row): void;
|
|
31
|
+
export declare function claudeSelectionIdentity(row: Row): string;
|
|
32
|
+
export type ClaudeReceiptProvenance = Readonly<{
|
|
33
|
+
registryDirectory: string;
|
|
34
|
+
registryRecordPath: string;
|
|
35
|
+
registryIdentity: string;
|
|
36
|
+
socketPath: string;
|
|
37
|
+
routeIdentity: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function claudeReceiptProvenance(row: Row): ClaudeReceiptProvenance;
|
|
8
40
|
export declare function claude(all: boolean): Row;
|
|
9
41
|
export declare function configuredHomePaths(): string[];
|
|
10
42
|
export declare function orcaHomePaths(): string[];
|