@astrosheep/square 0.4.7 → 0.4.8
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/card-format.d.ts +2 -0
- package/dist/card-format.js +2 -0
- package/dist/claude-mcp-context.d.ts +0 -1
- package/dist/claude-mcp-context.js +0 -10
- package/dist/claude-mod.d.ts +2 -0
- package/dist/claude-mod.js +211 -0
- package/dist/cli/context.d.ts +1 -1
- package/dist/cli/context.js +1 -12
- package/dist/cli/express-presentation.js +6 -33
- package/dist/cli/json.js +1 -1
- package/dist/cli/observation-commands.d.ts +2 -3
- package/dist/cli/observation-commands.js +21 -59
- package/dist/cli/registry.js +3 -5
- package/dist/cli/square-commands.d.ts +1 -2
- package/dist/cli/square-commands.js +7 -17
- package/dist/decisions.js +5 -4
- package/dist/harness-claude.js +3 -3
- package/dist/help.js +6 -8
- package/dist/mcp.js +1 -1
- package/dist/neutral.d.ts +15 -1
- package/dist/notifications.js +1 -1
- package/dist/operation-presentation.d.ts +17 -15
- package/dist/operation-presentation.js +58 -32
- package/dist/packages/agent-delivery/src/index.d.ts +4 -9
- package/dist/packages/agent-delivery/src/index.js +0 -9
- package/dist/packages/agent-delivery/src/local-endpoint.d.ts +2 -12
- package/dist/packages/agent-delivery/src/local-endpoint.js +4 -48
- package/dist/packages/agent-delivery/src/pi-client.js +0 -2
- package/dist/packages/agent-delivery/src/types.d.ts +3 -37
- package/dist/plugins/paseo/shared/card-format.d.ts +6 -0
- package/dist/plugins/paseo/shared/card-format.js +38 -0
- package/dist/plugins/paseo/shared/card-presentation.d.ts +3 -1
- package/dist/plugins/paseo/shared/card-presentation.js +3 -1
- package/dist/presentation.d.ts +2 -20
- package/dist/presentation.js +11 -46
- package/dist/sqlite-square.js +5 -6
- package/dist/square-facade.d.ts +3 -12
- package/dist/square-posting.js +1 -1
- package/dist/square-tools.d.ts +0 -11
- package/dist/square-tools.js +33 -119
- package/dist/square-values.d.ts +1 -1
- package/dist/square-values.js +1 -1
- package/dist/time.d.ts +1 -0
- package/dist/time.js +10 -0
- package/dist/views.d.ts +1 -1
- package/dist/views.js +2 -2
- package/dist/wake-transports.d.ts +1 -1
- package/dist/wake-transports.js +1 -1
- package/guides/catch-cold-path-optimization.md +1 -1
- package/guides/claude-native.md +37 -7
- package/guides/delivery-primitives.md +2 -1
- package/guides/mcp.md +3 -3
- package/guides/pi-native-delivery.md +10 -2
- package/guides/pi-tools.md +1 -3
- package/guides/row-storage-design.md +1 -1
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +3 -2
- package/plugins/claude/README.md +9 -0
- package/plugins/claude/hooks/hooks.json +1 -9
- package/plugins/claude/hooks/register.js +178 -0
- package/plugins/claude/skills/square/SKILL.md +2 -2
- package/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/plugins/paseo/OVERVIEW.md +1 -1
- package/plugins/paseo/README.md +20 -23
- package/plugins/paseo/client/markdown.tsx +88 -95
- package/plugins/paseo/client/palette.ts +37 -12
- package/plugins/paseo/client/square-message.tsx +52 -76
- package/plugins/paseo/client/transform.ts +4 -6
- package/plugins/paseo/shared/card-format.ts +37 -0
- package/plugins/paseo/shared/card-presentation.ts +6 -2
- package/plugins/paseo/shared/message.ts +1 -6
- package/plugins/pi/square-pi.js +69 -50
- package/skills/square/SKILL.md +2 -2
- package/dist/claude-boundary-state.d.ts +0 -20
- package/dist/claude-boundary-state.js +0 -84
- package/dist/claude-hook.d.ts +0 -2
- package/dist/claude-hook.js +0 -232
- package/dist/packages/agent-delivery/src/claude-auth.d.ts +0 -13
- package/dist/packages/agent-delivery/src/claude-auth.js +0 -75
- package/dist/packages/agent-delivery/src/claude-native.d.ts +0 -30
- package/dist/packages/agent-delivery/src/claude-native.js +0 -75
- package/dist/packages/agent-delivery/src/claude.d.ts +0 -5
- package/dist/packages/agent-delivery/src/claude.js +0 -66
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { deadline } from './deadline.js';
|
|
3
|
-
import { DeliveryError } from './errors.js';
|
|
4
|
-
import { connectLocal, LocalEndpointError, parseLocalEndpoint, writeFrames } from './local-endpoint.js';
|
|
5
|
-
import { resolveClaudeToken } from './claude-auth.js';
|
|
6
|
-
const detail = (code) => code === 'aborted' ? 'Native inbox write aborted.'
|
|
7
|
-
: code === 'timeout' ? 'Native inbox write deadline elapsed.'
|
|
8
|
-
: code === 'authentication_failed' ? 'Claude authentication failed.'
|
|
9
|
-
: 'Native inbox endpoint unavailable.';
|
|
10
|
-
/** Submit once. Written means local bytes only, never native admission or consumption. */
|
|
11
|
-
export async function writeClaudeNative(target, text, control) {
|
|
12
|
-
const remaining = control?.deadline - Date.now();
|
|
13
|
-
let endpoint;
|
|
14
|
-
try {
|
|
15
|
-
endpoint = parseLocalEndpoint(target?.endpoint);
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
return { outcome: 'unavailable', code: 'invalid_arguments', message: 'Invalid native inbox arguments.' };
|
|
19
|
-
}
|
|
20
|
-
if (!target || typeof target.sessionId !== 'string' || !target.sessionId.trim() ||
|
|
21
|
-
typeof text !== 'string' || !text.length || !control ||
|
|
22
|
-
!Number.isFinite(control.deadline) || control.deadline <= 0 || remaining > 2_147_483_647 ||
|
|
23
|
-
(control.signal !== undefined && !(control.signal instanceof AbortSignal))) {
|
|
24
|
-
return { outcome: 'unavailable', code: 'invalid_arguments', message: 'Invalid native inbox arguments.' };
|
|
25
|
-
}
|
|
26
|
-
if (control.signal?.aborted)
|
|
27
|
-
return { outcome: 'unavailable', code: 'aborted', message: detail('aborted') };
|
|
28
|
-
if (remaining <= 0)
|
|
29
|
-
return { outcome: 'unavailable', code: 'timeout', message: detail('timeout') };
|
|
30
|
-
const scope = deadline(control.deadline - Date.now(), control.signal);
|
|
31
|
-
let socket;
|
|
32
|
-
try {
|
|
33
|
-
scope.check();
|
|
34
|
-
const token = await scope.wait(resolveClaudeToken({ endpoint, token: target.token, claudeHome: target.claudeHome, env: target.env, platform: target.platform }, scope.signal));
|
|
35
|
-
const messageId = target.messageId ?? randomUUID();
|
|
36
|
-
const frames = [
|
|
37
|
-
...(token === undefined ? [] : [{ type: 'auth', token }]),
|
|
38
|
-
// Claude's SDK custody events echo uuid, not the peer-protocol msg_id.
|
|
39
|
-
{ msgV: 1, msg_id: messageId, uuid: messageId, type: 'user', session_id: target.sessionId, message: { role: 'user', content: text }, priority: 'next' },
|
|
40
|
-
];
|
|
41
|
-
scope.check();
|
|
42
|
-
if (Date.now() >= control.deadline)
|
|
43
|
-
throw new LocalEndpointError('timeout');
|
|
44
|
-
socket = await connectLocal(endpoint, { signal: scope.signal });
|
|
45
|
-
scope.check();
|
|
46
|
-
if (Date.now() >= control.deadline)
|
|
47
|
-
throw new LocalEndpointError('timeout');
|
|
48
|
-
if (control.beforeSend && !await scope.wait(control.beforeSend()))
|
|
49
|
-
return { outcome: 'unavailable', code: 'aborted', message: 'Native inbox write suppressed.' };
|
|
50
|
-
scope.check();
|
|
51
|
-
if (Date.now() >= control.deadline)
|
|
52
|
-
throw new LocalEndpointError('timeout');
|
|
53
|
-
// A receiver that never drains must not hold the caller past its deadline.
|
|
54
|
-
await scope.wait(writeFrames(socket, frames));
|
|
55
|
-
scope.check();
|
|
56
|
-
return { outcome: 'written' };
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
const local = error instanceof LocalEndpointError ? error : undefined;
|
|
60
|
-
const code = scope.code ?? (error instanceof DeliveryError ? error.code : local?.code);
|
|
61
|
-
if (code === 'authentication_failed') {
|
|
62
|
-
return { outcome: 'unavailable', code, message: detail(code) };
|
|
63
|
-
}
|
|
64
|
-
if (code === 'aborted' || code === 'timeout') {
|
|
65
|
-
return { outcome: socket ? 'unknown' : 'unavailable', code, message: detail(code) };
|
|
66
|
-
}
|
|
67
|
-
if (socket)
|
|
68
|
-
return { outcome: 'unknown', code: 'transport', message: 'Native inbox write unconfirmed.' };
|
|
69
|
-
return { outcome: 'unavailable', code: 'endpoint_unavailable', message: detail('unavailable') };
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
socket?.destroy();
|
|
73
|
-
scope.close();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ClaudeConnectOptions, ClaudeDeliveryResult, ClaudeSendTextOptions, ClaudeTarget } from './types.js';
|
|
2
|
-
/** Resolve an explicitly identified existing Claude native inbox; never discovers or starts one. */
|
|
3
|
-
export declare function connectExisting(options: ClaudeConnectOptions): Promise<ClaudeTarget>;
|
|
4
|
-
/** Write once to Claude's next native boundary; local write is never native admission. */
|
|
5
|
-
export declare function sendText(target: ClaudeTarget, text: string, options?: ClaudeSendTextOptions): Promise<ClaudeDeliveryResult>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { deadline, validSignal, validTimeout } from './deadline.js';
|
|
3
|
-
import { ConnectionError, DeliveryError } from './errors.js';
|
|
4
|
-
import { isIdentity, isRecord } from './guards.js';
|
|
5
|
-
import { parseLocalEndpoint } from './local-endpoint.js';
|
|
6
|
-
import { writeClaudeNative } from './claude-native.js';
|
|
7
|
-
import { resolveClaudeToken } from './claude-auth.js';
|
|
8
|
-
const coordinates = new WeakMap();
|
|
9
|
-
/** Resolve an explicitly identified existing Claude native inbox; never discovers or starts one. */
|
|
10
|
-
export async function connectExisting(options) {
|
|
11
|
-
if (!isRecord(options) || options.harness !== 'claude' || !isIdentity(options.sessionId) ||
|
|
12
|
-
typeof options.endpoint !== 'string' || options.endpoint.includes('\0') ||
|
|
13
|
-
!validTimeout(options.timeoutMs) || !validSignal(options.signal))
|
|
14
|
-
throw new ConnectionError('invalid_arguments');
|
|
15
|
-
let endpoint;
|
|
16
|
-
try {
|
|
17
|
-
endpoint = parseLocalEndpoint(options.endpoint);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
throw new ConnectionError('invalid_arguments');
|
|
21
|
-
}
|
|
22
|
-
if (!(process.platform === 'darwin' || process.platform === 'linux' || process.platform === 'win32'))
|
|
23
|
-
throw new ConnectionError('unsupported_platform');
|
|
24
|
-
if (process.platform === 'win32' ? endpoint.kind !== 'pipe' : endpoint.kind !== 'unix')
|
|
25
|
-
throw new ConnectionError('invalid_arguments');
|
|
26
|
-
const scope = deadline(options.timeoutMs, options.signal);
|
|
27
|
-
try {
|
|
28
|
-
scope.check();
|
|
29
|
-
// The ambient environment and platform are the only auth coordinates here.
|
|
30
|
-
const token = await scope.wait(resolveClaudeToken({ endpoint, token: options.token, claudeHome: options.claudeHome }, scope.signal));
|
|
31
|
-
scope.check();
|
|
32
|
-
const target = Object.freeze({ harness: 'claude', sessionId: options.sessionId });
|
|
33
|
-
coordinates.set(target, { endpoint: options.endpoint, token, claudeHome: options.claudeHome });
|
|
34
|
-
return target;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (scope.code !== undefined)
|
|
38
|
-
throw new ConnectionError(scope.code);
|
|
39
|
-
if (error instanceof ConnectionError)
|
|
40
|
-
throw error;
|
|
41
|
-
if (error instanceof DeliveryError)
|
|
42
|
-
throw new ConnectionError(error.code);
|
|
43
|
-
throw new ConnectionError('invalid_response');
|
|
44
|
-
}
|
|
45
|
-
finally {
|
|
46
|
-
scope.close();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/** Write once to Claude's next native boundary; local write is never native admission. */
|
|
50
|
-
export async function sendText(target, text, options = {}) {
|
|
51
|
-
const coordinate = isRecord(target) ? coordinates.get(target) : undefined;
|
|
52
|
-
if (!coordinate || target.harness !== 'claude' || !isIdentity(target.sessionId) || typeof text !== 'string' || !text.length || !isRecord(options) ||
|
|
53
|
-
(options.delivery !== undefined && options.delivery !== 'steer') || options.inputId !== undefined ||
|
|
54
|
-
!validTimeout(options.timeoutMs) || !validSignal(options.signal))
|
|
55
|
-
throw new TypeError('Invalid Claude sendText arguments.');
|
|
56
|
-
const messageId = randomUUID();
|
|
57
|
-
const result = await writeClaudeNative({ ...coordinate, sessionId: target.sessionId, messageId }, text, { deadline: Date.now() + (options.timeoutMs ?? 5_000), signal: options.signal });
|
|
58
|
-
const attempt = { harness: 'claude', sessionId: target.sessionId };
|
|
59
|
-
if (result.outcome === 'written')
|
|
60
|
-
return { ...attempt, state: 'written', messageId };
|
|
61
|
-
if (result.outcome === 'unknown')
|
|
62
|
-
return { ...attempt, state: 'unknown', code: result.code };
|
|
63
|
-
if (result.code === 'invalid_arguments')
|
|
64
|
-
throw new TypeError('Invalid Claude sendText arguments.');
|
|
65
|
-
return { ...attempt, state: 'unavailable', code: result.code };
|
|
66
|
-
}
|