@canonmsg/agent-sdk 11.2.0 → 12.0.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 +171 -536
- package/dist/chunks/chunk-6VK4UZHJ.js +2806 -0
- package/dist/chunks/chunk-FPQFTTND.js +4899 -0
- package/dist/chunks/chunk-OLJ7H4E2.js +14705 -0
- package/dist/chunks/mls-crypto-NZDNSPAO.js +10 -0
- package/dist/cli.js +198 -0
- package/dist/drivers/claude.d.ts +36 -0
- package/dist/drivers/code.d.ts +18 -0
- package/dist/drivers/codex.d.ts +37 -0
- package/dist/index.d.ts +12 -25
- package/dist/index.js +69 -13
- package/dist/internal/backend-contracts/agentBehaviorPolicy.d.ts +122 -0
- package/dist/internal/backend-contracts/agentDirectory.d.ts +32 -0
- package/dist/internal/backend-contracts/agentOrigin.d.ts +23 -0
- package/dist/internal/backend-contracts/agentSearch.d.ts +17 -0
- package/dist/internal/backend-contracts/api-origins.generated.d.ts +4 -0
- package/dist/internal/backend-contracts/apiErrors.d.ts +1 -0
- package/dist/internal/backend-contracts/artifactActions.d.ts +159 -0
- package/dist/internal/backend-contracts/artifacts.d.ts +386 -0
- package/dist/internal/backend-contracts/communication.d.ts +131 -0
- package/dist/internal/backend-contracts/conversationMembership.d.ts +28 -0
- package/dist/internal/backend-contracts/deliveryObservation.d.ts +23 -0
- package/dist/internal/backend-contracts/diffRedaction.d.ts +6 -0
- package/dist/internal/backend-contracts/endpoint-unread.d.ts +4 -0
- package/dist/internal/backend-contracts/endpoint.d.ts +103 -0
- package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +37 -0
- package/dist/internal/backend-contracts/environment.d.ts +20 -0
- package/dist/internal/backend-contracts/externalInbound.d.ts +24 -0
- package/dist/internal/backend-contracts/firestoreValues.d.ts +9 -0
- package/dist/internal/backend-contracts/index.d.ts +48 -0
- package/dist/internal/backend-contracts/media-url.d.ts +6 -0
- package/dist/internal/backend-contracts/media.d.ts +51 -0
- package/dist/internal/backend-contracts/mediaDelivery.d.ts +46 -0
- package/dist/internal/backend-contracts/mediaTransferProtocol.d.ts +17 -0
- package/dist/internal/backend-contracts/membershipChange.d.ts +21 -0
- package/dist/internal/backend-contracts/message.d.ts +86 -0
- package/dist/internal/backend-contracts/messageText.d.ts +6 -0
- package/dist/internal/backend-contracts/mlsDevApplication.d.ts +73 -0
- package/dist/internal/backend-contracts/mlsDevCredential.d.ts +75 -0
- package/dist/internal/backend-contracts/mlsDevCredentialReconciliation.d.ts +45 -0
- package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +51 -0
- package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +74 -0
- package/dist/internal/backend-contracts/mlsDevGroup.d.ts +197 -0
- package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +47 -0
- package/dist/internal/backend-contracts/mlsDevKeyPackage.d.ts +42 -0
- package/dist/internal/backend-contracts/mlsDevKeyPackages.d.ts +55 -0
- package/dist/internal/backend-contracts/moderation.d.ts +7 -0
- package/dist/internal/backend-contracts/plaintextProcessors.d.ts +63 -0
- package/dist/internal/backend-contracts/preparedContent.d.ts +54 -0
- package/dist/internal/backend-contracts/replyAuthority.d.ts +14 -0
- package/dist/internal/backend-contracts/runtimeCardFields.d.ts +66 -0
- package/dist/internal/backend-contracts/runtimeCardStorage.d.ts +3 -0
- package/dist/internal/backend-contracts/runtimeDescriptor.d.ts +88 -0
- package/dist/internal/backend-contracts/selfContext.d.ts +9 -0
- package/dist/internal/backend-contracts/turnProtocol.d.ts +43 -0
- package/dist/internal/backend-contracts/verbContract.d.ts +848 -0
- package/dist/internal/backend-contracts/verbSchemas.d.ts +1707 -0
- package/dist/internal/backend-contracts/verbWire.d.ts +493 -0
- package/dist/internal/backend-contracts/webAuth.d.ts +8 -0
- package/dist/internal/backend-contracts/workSessions.d.ts +205 -0
- package/dist/internal/core/agent-profiles.d.ts +69 -0
- package/dist/internal/core/agent-resolver.d.ts +49 -0
- package/dist/internal/core/agent-session.d.ts +12 -0
- package/dist/internal/core/approval-format.d.ts +26 -0
- package/dist/internal/core/approval-manager.d.ts +43 -0
- package/dist/internal/core/approval-types.d.ts +74 -0
- package/dist/internal/core/artifacts.d.ts +262 -0
- package/dist/internal/core/attached-native-session.d.ts +174 -0
- package/dist/internal/core/attached-session-file-store.d.ts +3 -0
- package/dist/internal/core/base-url.d.ts +1 -0
- package/dist/internal/core/cli-metadata.d.ts +13 -0
- package/dist/internal/core/client.d.ts +486 -0
- package/dist/internal/core/completed-output-journal.d.ts +39 -0
- package/dist/internal/core/constants.d.ts +4 -0
- package/dist/internal/core/control-poller.d.ts +221 -0
- package/dist/internal/core/endpoint-client.d.ts +43 -0
- package/dist/internal/core/exclusive-json-file-store.d.ts +7 -0
- package/dist/internal/core/execution-environment-mode.d.ts +8 -0
- package/dist/internal/core/execution-environment.d.ts +55 -0
- package/dist/internal/core/gifs.d.ts +35 -0
- package/dist/internal/core/group-context.d.ts +25 -0
- package/dist/internal/core/host-runtime.d.ts +257 -0
- package/dist/internal/core/inbound-frame.d.ts +64 -0
- package/dist/internal/core/index.d.ts +107 -0
- package/dist/internal/core/local-runtime-catalog.d.ts +131 -0
- package/dist/internal/core/message-format.d.ts +13 -0
- package/dist/internal/core/native-session-interaction.d.ts +44 -0
- package/dist/internal/core/node-media.d.ts +6 -0
- package/dist/internal/core/policy.d.ts +2 -0
- package/dist/internal/core/provenance.d.ts +31 -0
- package/dist/internal/core/registration-cli.d.ts +40 -0
- package/dist/internal/core/registration-profile.d.ts +10 -0
- package/dist/internal/core/registration-session.d.ts +55 -0
- package/dist/internal/core/registration.d.ts +21 -0
- package/dist/internal/core/retry.d.ts +122 -0
- package/dist/internal/core/rtdb-rest.d.ts +145 -0
- package/dist/internal/core/runtime-cards.d.ts +331 -0
- package/dist/internal/core/runtime-descriptor.d.ts +75 -0
- package/dist/internal/core/runtime-endpoints.d.ts +26 -0
- package/dist/internal/core/runtime-heartbeat.d.ts +29 -0
- package/dist/internal/core/runtime-presentation.d.ts +35 -0
- package/dist/internal/core/runtime-request-manager.d.ts +284 -0
- package/dist/internal/core/runtime-state-publisher.d.ts +42 -0
- package/dist/internal/core/self-context.d.ts +61 -0
- package/dist/internal/core/silent-turn.d.ts +86 -0
- package/dist/internal/core/stream.d.ts +77 -0
- package/dist/internal/core/turn-output-controller.d.ts +69 -0
- package/dist/internal/core/turn-protocol.d.ts +33 -0
- package/dist/internal/core/turn-verbosity.d.ts +97 -0
- package/dist/internal/core/types.d.ts +1075 -0
- package/dist/internal/core/typing-status-publisher.d.ts +14 -0
- package/dist/internal/core/unified-diff.d.ts +35 -0
- package/dist/internal/core/work-session-provider.d.ts +29 -0
- package/dist/internal/core/workspace-discovery.d.ts +17 -0
- package/dist/internal/endpoint/artifact-images.d.ts +60 -0
- package/dist/internal/endpoint/artifact-reducer.d.ts +35 -0
- package/dist/internal/endpoint/artifact-views.d.ts +113 -0
- package/dist/internal/endpoint/artifacts.d.ts +75 -0
- package/dist/internal/endpoint/delivery.d.ts +47 -0
- package/dist/internal/endpoint/engine.d.ts +219 -0
- package/dist/internal/endpoint/ephemeral.d.ts +8 -0
- package/dist/internal/endpoint/events.d.ts +32 -0
- package/dist/internal/endpoint/external-inbound.d.ts +36 -0
- package/dist/internal/endpoint/handoff.d.ts +50 -0
- package/dist/internal/endpoint/history.d.ts +22 -0
- package/dist/internal/endpoint/image-generation-errors.d.ts +2 -0
- package/dist/internal/endpoint/inbound.d.ts +29 -0
- package/dist/internal/endpoint/index.d.ts +32 -0
- package/dist/internal/endpoint/media.d.ts +172 -0
- package/dist/internal/endpoint/migration.d.ts +50 -0
- package/dist/internal/endpoint/mls-crypto.d.ts +25 -0
- package/dist/internal/endpoint/mls-dev-client.d.ts +44 -0
- package/dist/internal/endpoint/mls-dev-device.d.ts +67 -0
- package/dist/internal/endpoint/mls-dev-groups.d.ts +114 -0
- package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +33 -0
- package/dist/internal/endpoint/mls-dev-key-packages.d.ts +42 -0
- package/dist/internal/endpoint/mls-dev-transport.d.ts +37 -0
- package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +24 -0
- package/dist/internal/endpoint/node-mls-custody.d.ts +15 -0
- package/dist/internal/endpoint/node.d.ts +7 -0
- package/dist/internal/endpoint/observe-query.d.ts +17 -0
- package/dist/internal/endpoint/portable-node-mls-custody.d.ts +23 -0
- package/dist/internal/endpoint/queue.d.ts +22 -0
- package/dist/internal/endpoint/recovery.d.ts +27 -0
- package/dist/internal/endpoint/retention.d.ts +7 -0
- package/dist/internal/endpoint/store.d.ts +22 -0
- package/dist/internal/endpoint/sync.d.ts +33 -0
- package/dist/internal/endpoint/transient-publisher.d.ts +8 -0
- package/dist/internal/endpoint/transport.d.ts +58 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.js +42 -541
- package/dist/runner/runner.d.ts +37 -0
- package/dist/runner/types.d.ts +168 -0
- package/package.json +18 -5
- package/dist/attached-session.d.ts +0 -58
- package/dist/attached-session.js +0 -638
- package/dist/bounded-file-read.d.ts +0 -14
- package/dist/bounded-file-read.js +0 -34
- package/dist/canon-agent.d.ts +0 -238
- package/dist/canon-agent.js +0 -2534
- package/dist/debouncer.d.ts +0 -18
- package/dist/debouncer.js +0 -133
- package/dist/inbound-handoff.d.ts +0 -6
- package/dist/inbound-handoff.js +0 -17
- package/dist/managed-session-host.d.ts +0 -27
- package/dist/managed-session-host.js +0 -195
- package/dist/managed-session-setup.d.ts +0 -99
- package/dist/managed-session-setup.js +0 -234
- package/dist/realtime.d.ts +0 -62
- package/dist/realtime.js +0 -193
- package/dist/runtime-card.d.ts +0 -48
- package/dist/runtime-card.js +0 -64
- package/dist/session-manager.d.ts +0 -77
- package/dist/session-manager.js +0 -285
- package/dist/turn-streaming-request.d.ts +0 -17
- package/dist/turn-streaming-request.js +0 -22
- package/dist/turn-verbosity-option.d.ts +0 -33
- package/dist/turn-verbosity-option.js +0 -23
- package/dist/types.d.ts +0 -387
- package/dist/types.js +0 -1
- package/dist/work-session-coordination.d.ts +0 -21
- package/dist/work-session-coordination.js +0 -53
- package/dist/work-session-host.d.ts +0 -31
- package/dist/work-session-host.js +0 -617
- package/dist/work-session-interactions.d.ts +0 -12
- package/dist/work-session-interactions.js +0 -173
- package/dist/work-session-state.d.ts +0 -36
- package/dist/work-session-state.js +0 -62
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/** Private owner/operator workflow. None of this catalog belongs in public runtime descriptors. */
|
|
2
|
+
export declare const WORK_SESSION_SCHEMA: "canon.work-sessions.v1";
|
|
3
|
+
export declare const WORK_SESSION_LEASE_MS = 90000;
|
|
4
|
+
export declare const WORK_SESSION_REQUEST_TTL_MS: number;
|
|
5
|
+
export interface WorkSessionChoice {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkSessionModelChoice extends WorkSessionChoice {
|
|
11
|
+
reasoningEfforts?: WorkSessionChoice[];
|
|
12
|
+
defaultReasoningEffort?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkSessionSettings {
|
|
15
|
+
projectId?: string;
|
|
16
|
+
modelId?: string;
|
|
17
|
+
reasoningEffort?: string;
|
|
18
|
+
permissionMode?: string;
|
|
19
|
+
executionMode?: string;
|
|
20
|
+
}
|
|
21
|
+
export type WorkSessionSelection = ({
|
|
22
|
+
mode: 'create';
|
|
23
|
+
projectId: string;
|
|
24
|
+
} & Omit<WorkSessionSettings, 'projectId'>) | ({
|
|
25
|
+
mode: 'configure';
|
|
26
|
+
projectId: string;
|
|
27
|
+
} & Omit<WorkSessionSettings, 'projectId'>) | {
|
|
28
|
+
mode: 'attach';
|
|
29
|
+
sessionId: string;
|
|
30
|
+
};
|
|
31
|
+
export interface WorkSessionLoadedSession {
|
|
32
|
+
id: string;
|
|
33
|
+
title: string;
|
|
34
|
+
status: 'idle' | 'running';
|
|
35
|
+
settings: WorkSessionSettings;
|
|
36
|
+
projectLabel?: string;
|
|
37
|
+
modelLabel?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface WorkSessionCatalog {
|
|
40
|
+
revision: string;
|
|
41
|
+
provider: string;
|
|
42
|
+
canCreate: boolean;
|
|
43
|
+
canAttach: boolean;
|
|
44
|
+
projects: WorkSessionChoice[];
|
|
45
|
+
models?: WorkSessionModelChoice[];
|
|
46
|
+
reasoningEfforts?: WorkSessionChoice[];
|
|
47
|
+
permissionModes?: WorkSessionChoice[];
|
|
48
|
+
executionModes?: WorkSessionChoice[];
|
|
49
|
+
defaults?: WorkSessionSettings;
|
|
50
|
+
sessions: WorkSessionLoadedSession[];
|
|
51
|
+
/** Opt-in extension. Older runtimes may still create or attach native sessions. */
|
|
52
|
+
managedSetup?: {
|
|
53
|
+
version: 1;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface WorkSessionRuntimeIdentity {
|
|
57
|
+
hostId: string;
|
|
58
|
+
runtimeEpoch: string;
|
|
59
|
+
}
|
|
60
|
+
export interface WorkSessionRuntimeLease extends WorkSessionRuntimeIdentity {
|
|
61
|
+
/** Agent-only fencing credential. Never expose in the owner catalog or request status. */
|
|
62
|
+
leaseToken: string;
|
|
63
|
+
expiresAt: number;
|
|
64
|
+
}
|
|
65
|
+
export interface WorkSessionRuntimeRegistration extends WorkSessionRuntimeIdentity {
|
|
66
|
+
displayName: string;
|
|
67
|
+
catalog: WorkSessionCatalog;
|
|
68
|
+
}
|
|
69
|
+
interface WorkSessionBindingBase {
|
|
70
|
+
workSessionId: string;
|
|
71
|
+
conversationId: string;
|
|
72
|
+
hostId: string;
|
|
73
|
+
provider: string;
|
|
74
|
+
settings: WorkSessionSettings;
|
|
75
|
+
createdAt: number;
|
|
76
|
+
}
|
|
77
|
+
export type WorkSessionBinding = (WorkSessionBindingBase & {
|
|
78
|
+
kind?: 'native';
|
|
79
|
+
nativeSessionId: string;
|
|
80
|
+
}) | (WorkSessionBindingBase & {
|
|
81
|
+
kind: 'managed';
|
|
82
|
+
nativeSessionId?: never;
|
|
83
|
+
});
|
|
84
|
+
export interface WorkSessionRuntimeState {
|
|
85
|
+
ownerId: string;
|
|
86
|
+
lease: WorkSessionRuntimeLease;
|
|
87
|
+
bindings: WorkSessionBinding[];
|
|
88
|
+
}
|
|
89
|
+
export interface WorkSessionCatalogResult {
|
|
90
|
+
status: 'available' | 'offline' | 'unavailable';
|
|
91
|
+
agentId: string;
|
|
92
|
+
hostId?: string;
|
|
93
|
+
runtimeEpoch?: string;
|
|
94
|
+
displayName?: string;
|
|
95
|
+
expiresAt?: number;
|
|
96
|
+
catalog?: WorkSessionCatalog;
|
|
97
|
+
bindings: WorkSessionBinding[];
|
|
98
|
+
}
|
|
99
|
+
export interface RequestWorkSessionInput extends WorkSessionRuntimeIdentity {
|
|
100
|
+
agentId: string;
|
|
101
|
+
conversationId: string;
|
|
102
|
+
requestId: string;
|
|
103
|
+
catalogRevision: string;
|
|
104
|
+
selection: WorkSessionSelection;
|
|
105
|
+
}
|
|
106
|
+
export type WorkSessionRequestStatus = 'pending' | 'claimed' | 'attached' | 'configured' | 'failed' | 'uncertain' | 'expired';
|
|
107
|
+
export interface WorkSessionRequest extends RequestWorkSessionInput {
|
|
108
|
+
schema: typeof WORK_SESSION_SCHEMA;
|
|
109
|
+
requestedBy: string;
|
|
110
|
+
status: WorkSessionRequestStatus;
|
|
111
|
+
createdAt: number;
|
|
112
|
+
updatedAt: number;
|
|
113
|
+
expiresAt: number;
|
|
114
|
+
binding?: WorkSessionBinding;
|
|
115
|
+
error?: {
|
|
116
|
+
code: string;
|
|
117
|
+
message: string;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export type WorkSessionCompletion = {
|
|
121
|
+
status: 'attached';
|
|
122
|
+
nativeSessionId: string;
|
|
123
|
+
settings: WorkSessionSettings;
|
|
124
|
+
} | {
|
|
125
|
+
status: 'configured';
|
|
126
|
+
settings: WorkSessionSettings;
|
|
127
|
+
} | {
|
|
128
|
+
status: 'failed' | 'uncertain';
|
|
129
|
+
error: {
|
|
130
|
+
code: string;
|
|
131
|
+
message: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export type WorkSessionRuntimeAuth = Pick<WorkSessionRuntimeLease, 'hostId' | 'runtimeEpoch' | 'leaseToken'>;
|
|
135
|
+
export interface WorkSessionClaimInput extends WorkSessionRuntimeAuth {
|
|
136
|
+
requestId?: string;
|
|
137
|
+
}
|
|
138
|
+
export interface WorkSessionClaimResult {
|
|
139
|
+
request: WorkSessionRequest | null;
|
|
140
|
+
/** Previously claimed: reconcile the durable host journal, never blindly execute again. */
|
|
141
|
+
replayed: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface CompleteWorkSessionInput extends WorkSessionRuntimeAuth {
|
|
144
|
+
requestId: string;
|
|
145
|
+
result: WorkSessionCompletion;
|
|
146
|
+
}
|
|
147
|
+
export interface WorkSessionHeartbeatInput extends WorkSessionRuntimeAuth {
|
|
148
|
+
catalog?: WorkSessionCatalog;
|
|
149
|
+
}
|
|
150
|
+
export interface ReleaseWorkSessionBindingInput extends WorkSessionRuntimeAuth {
|
|
151
|
+
conversationId: string;
|
|
152
|
+
workSessionId: string;
|
|
153
|
+
}
|
|
154
|
+
export interface ResolveWorkSessionRequestInput {
|
|
155
|
+
agentId: string;
|
|
156
|
+
requestId: string;
|
|
157
|
+
}
|
|
158
|
+
export interface GetWorkSessionRequestInput {
|
|
159
|
+
agentId: string;
|
|
160
|
+
/** Exactly one selector. Conversation lookup recovers the latest operation after reload. */
|
|
161
|
+
requestId?: string;
|
|
162
|
+
conversationId?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface GetWorkSessionDetailsInput {
|
|
165
|
+
agentId: string;
|
|
166
|
+
conversationId: string;
|
|
167
|
+
}
|
|
168
|
+
export type WorkSessionDetailField = keyof WorkSessionSettings | 'projectLabel' | 'workingDirectory' | 'branch' | 'worktreePath' | 'sandbox' | 'approvalPolicy' | 'nativeThreadBehavior';
|
|
169
|
+
export interface WorkSessionDetailValue {
|
|
170
|
+
value: string;
|
|
171
|
+
provenance: 'configured' | 'observed';
|
|
172
|
+
}
|
|
173
|
+
export type WorkSessionDetailFields = Partial<Record<WorkSessionDetailField, WorkSessionDetailValue>>;
|
|
174
|
+
/** Host supplied private facts. The server stamps reportedAt and checks the current lease and membership. */
|
|
175
|
+
export interface WorkSessionReportInput extends WorkSessionRuntimeAuth {
|
|
176
|
+
conversationId: string;
|
|
177
|
+
workSessionId?: string;
|
|
178
|
+
setupState?: 'configured' | 'attached';
|
|
179
|
+
fields: WorkSessionDetailFields;
|
|
180
|
+
}
|
|
181
|
+
export interface WorkSessionDetailsResult {
|
|
182
|
+
status: 'available' | 'offline' | 'unavailable';
|
|
183
|
+
agentId: string;
|
|
184
|
+
conversationId: string;
|
|
185
|
+
setupState: 'unconfigured' | 'pending' | 'configured' | 'attached' | 'failed' | 'uncertain';
|
|
186
|
+
hostId?: string;
|
|
187
|
+
displayName?: string;
|
|
188
|
+
expiresAt?: number;
|
|
189
|
+
binding?: WorkSessionBinding;
|
|
190
|
+
selection?: WorkSessionSelection;
|
|
191
|
+
fields: WorkSessionDetailFields;
|
|
192
|
+
reportedAt?: number;
|
|
193
|
+
}
|
|
194
|
+
export declare function workSessionId(value: unknown, label?: string): string;
|
|
195
|
+
export declare function parseWorkSessionSettings(value: unknown): WorkSessionSettings;
|
|
196
|
+
export declare function parseWorkSessionCatalog(value: unknown): WorkSessionCatalog;
|
|
197
|
+
export declare function parseWorkSessionSelection(value: unknown): WorkSessionSelection;
|
|
198
|
+
export declare function assertWorkSessionSelectionAvailable(selection: WorkSessionSelection, catalog: WorkSessionCatalog): void;
|
|
199
|
+
export declare function parseWorkSessionRuntimeRegistration(value: unknown): WorkSessionRuntimeRegistration;
|
|
200
|
+
export declare function parseWorkSessionRuntimeAuth(value: unknown, extraKeys?: string[]): WorkSessionRuntimeAuth;
|
|
201
|
+
export declare function parseRequestWorkSessionInput(value: unknown): RequestWorkSessionInput;
|
|
202
|
+
export declare function parseWorkSessionCompletion(value: unknown): WorkSessionCompletion;
|
|
203
|
+
export declare function parseWorkSessionDetailFields(value: unknown): WorkSessionDetailFields;
|
|
204
|
+
export declare function parseWorkSessionReportInput(value: unknown): WorkSessionReportInput;
|
|
205
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared agent profile management — loading, locking, and resolution.
|
|
3
|
+
* Used by both host.ts and server.ts.
|
|
4
|
+
*/
|
|
5
|
+
import type { CanonEnvironmentId } from '../backend-contracts/index.js';
|
|
6
|
+
import type { AgentClientType } from './types.js';
|
|
7
|
+
import { type CanonRuntimeConnectionOptions } from './runtime-endpoints.js';
|
|
8
|
+
export interface AgentProfileInput {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
agentName: string;
|
|
12
|
+
registeredAt: string;
|
|
13
|
+
environmentId: CanonEnvironmentId;
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
streamUrl: string;
|
|
16
|
+
rtdbUrl: string;
|
|
17
|
+
firebaseApiKey: string;
|
|
18
|
+
clientType?: AgentClientType;
|
|
19
|
+
runtimeId?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentProfile extends AgentProfileInput {
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
streamUrl: string;
|
|
24
|
+
rtdbUrl: string;
|
|
25
|
+
firebaseApiKey: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ProfileLockHandle {
|
|
28
|
+
profile: string;
|
|
29
|
+
pid: number;
|
|
30
|
+
token: string;
|
|
31
|
+
release(): void;
|
|
32
|
+
}
|
|
33
|
+
export declare const CANON_DIR: string;
|
|
34
|
+
export declare const AGENTS_PATH: string;
|
|
35
|
+
export declare const LOCKS_DIR: string;
|
|
36
|
+
export declare const PENDING_REGISTRATIONS_PATH: string;
|
|
37
|
+
/** `home` names the Canon home explicitly; without it, CANON_HOME as read at import applies. */
|
|
38
|
+
export declare function loadProfiles(home?: string): Record<string, AgentProfile>;
|
|
39
|
+
export declare function saveProfiles(profiles: Record<string, AgentProfile>, home?: string): void;
|
|
40
|
+
export declare function upsertAgentProfile(name: string, profile: AgentProfileInput): Record<string, AgentProfile>;
|
|
41
|
+
export declare function isProcessAlive(pid: number): boolean;
|
|
42
|
+
export declare function isProfileLocked(profile: string, home?: string): {
|
|
43
|
+
locked: boolean;
|
|
44
|
+
pid?: number;
|
|
45
|
+
};
|
|
46
|
+
export declare function acquireLock(profile: string, home?: string): ProfileLockHandle;
|
|
47
|
+
export declare function releaseLock(profile: string, token?: string, home?: string): void;
|
|
48
|
+
export interface PendingRegistration {
|
|
49
|
+
profile: string;
|
|
50
|
+
clientType?: AgentClientType;
|
|
51
|
+
localRegistrationId: string;
|
|
52
|
+
environmentId: CanonEnvironmentId;
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
streamUrl: string;
|
|
55
|
+
rtdbUrl: string;
|
|
56
|
+
firebaseApiKey: string;
|
|
57
|
+
requestId?: string;
|
|
58
|
+
pollToken?: string;
|
|
59
|
+
ownerPhone?: string;
|
|
60
|
+
requestedAgentId?: string;
|
|
61
|
+
credentialAgentId?: string;
|
|
62
|
+
createdAt: string;
|
|
63
|
+
updatedAt: string;
|
|
64
|
+
}
|
|
65
|
+
export declare function loadPendingRegistrations(): Record<string, PendingRegistration>;
|
|
66
|
+
export declare function savePendingRegistrations(pending: Record<string, PendingRegistration>): void;
|
|
67
|
+
export declare function getOrCreatePendingRegistration(profile: string, clientType?: AgentClientType, connectionOptions?: CanonRuntimeConnectionOptions): PendingRegistration;
|
|
68
|
+
export declare function updatePendingRegistration(profile: string, patch: Partial<Pick<PendingRegistration, 'requestId' | 'pollToken' | 'clientType'>>): PendingRegistration;
|
|
69
|
+
export declare function clearPendingRegistration(profile: string): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified agent resolution — resolves Canon agent credentials from
|
|
3
|
+
* environment variables or ~/.canon/agents.json profiles.
|
|
4
|
+
*
|
|
5
|
+
* Used by the Claude Code plugin (host.ts, server.ts) and available
|
|
6
|
+
* for any future agent integration.
|
|
7
|
+
*
|
|
8
|
+
* Resolution order:
|
|
9
|
+
* 1. CANON_API_KEY env var (highest priority, no lock)
|
|
10
|
+
* 2. CANON_AGENT env var (named profile with lock)
|
|
11
|
+
* 3. Auto-select from profiles (first unlocked, with lock)
|
|
12
|
+
*/
|
|
13
|
+
import { type ProfileLockHandle } from './agent-profiles.js';
|
|
14
|
+
import type { CanonEnvironmentId } from '../backend-contracts/index.js';
|
|
15
|
+
import type { AgentClientType } from './types.js';
|
|
16
|
+
export interface ResolvedAgent {
|
|
17
|
+
apiKey: string;
|
|
18
|
+
agentId?: string;
|
|
19
|
+
profile: string | null;
|
|
20
|
+
agentName?: string;
|
|
21
|
+
clientType?: AgentClientType;
|
|
22
|
+
environmentId: CanonEnvironmentId;
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
streamUrl: string;
|
|
25
|
+
rtdbUrl: string;
|
|
26
|
+
firebaseApiKey: string;
|
|
27
|
+
lockHandle?: ProfileLockHandle;
|
|
28
|
+
}
|
|
29
|
+
export declare function verifyResolvedAgentEnvironment(resolved: ResolvedAgent): Promise<void>;
|
|
30
|
+
/** Get the currently locked profile name (for cleanup on shutdown). */
|
|
31
|
+
export declare function getActiveProfile(): string | null;
|
|
32
|
+
export declare function getActiveProfileLock(): ProfileLockHandle | null;
|
|
33
|
+
export declare function resolveCanonProfile(name: string, opts?: {
|
|
34
|
+
logPrefix?: string;
|
|
35
|
+
lock?: boolean;
|
|
36
|
+
expectedClientType?: AgentClientType;
|
|
37
|
+
}): ResolvedAgent;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve Canon agent credentials.
|
|
40
|
+
*
|
|
41
|
+
* @param opts.logPrefix - Log prefix for console messages (default: '[canon]')
|
|
42
|
+
* @returns Resolved agent with API key, optional agentId, and profile name
|
|
43
|
+
* @throws Error if no agent can be resolved
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveCanonAgent(opts?: {
|
|
46
|
+
logPrefix?: string;
|
|
47
|
+
expectedClientType?: AgentClientType;
|
|
48
|
+
lock?: boolean;
|
|
49
|
+
}): ResolvedAgent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentRuntime, AgentSessionSnapshot, SessionState } from './types.js';
|
|
2
|
+
import type { TurnState } from './turn-protocol.js';
|
|
3
|
+
export interface BuildAgentSessionSnapshotInput {
|
|
4
|
+
conversationId: string;
|
|
5
|
+
agentId: string;
|
|
6
|
+
runtime?: AgentRuntime | null;
|
|
7
|
+
sessionState?: SessionState | null;
|
|
8
|
+
turnState?: TurnState | null;
|
|
9
|
+
lastHeartbeatAt?: number | null;
|
|
10
|
+
updatedAt?: number | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function buildAgentSessionSnapshot(input: BuildAgentSessionSnapshotInput): AgentSessionSnapshot;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRequestMetadata, ApprovalNativeRequestMetadata, ApprovalRisk, ApprovalReplyMetadata, SessionRule } from './approval-types.js';
|
|
2
|
+
import type { CanonUnifiedDiff } from './types.js';
|
|
3
|
+
export declare function generateApprovalId(): string;
|
|
4
|
+
export declare function redactSecrets(text: string, patterns: string[]): string;
|
|
5
|
+
export declare function buildApprovalRequest(approvalId: string, toolName: string, toolInput: Record<string, unknown>, opts: {
|
|
6
|
+
riskLevel?: 'normal' | 'destructive';
|
|
7
|
+
risk?: ApprovalRisk;
|
|
8
|
+
category?: ApprovalRequestCategory;
|
|
9
|
+
responseUserId?: string;
|
|
10
|
+
runtimeId?: string;
|
|
11
|
+
turnId?: string;
|
|
12
|
+
native?: ApprovalNativeRequestMetadata;
|
|
13
|
+
toolSummary?: string;
|
|
14
|
+
details?: ApprovalRequestDetail[];
|
|
15
|
+
diff?: CanonUnifiedDiff;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
redactPatterns?: string[];
|
|
18
|
+
}): {
|
|
19
|
+
text: string;
|
|
20
|
+
metadata: ApprovalRequestMetadata;
|
|
21
|
+
};
|
|
22
|
+
export declare function buildApprovalReply(approvalId: string, decision: 'allow' | 'deny', sessionRule?: SessionRule): {
|
|
23
|
+
text: string;
|
|
24
|
+
metadata: ApprovalReplyMetadata;
|
|
25
|
+
};
|
|
26
|
+
export declare function buildApprovalOutcome(approvalId: string, toolName: string, toolSummary: string, decision: 'allow' | 'deny', reason: 'replied' | 'timeout' | 'session-rule'): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CanonClient } from './client.js';
|
|
2
|
+
import type { CanonUnifiedDiff } from './types.js';
|
|
3
|
+
import type { ApprovalConfig, ApprovalNativeRequestMetadata, ApprovalResult, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRisk } from './approval-types.js';
|
|
4
|
+
import { RuntimeRequestManager, type RuntimeRequestOptions } from './runtime-request-manager.js';
|
|
5
|
+
interface ApprovalRequestOpts {
|
|
6
|
+
riskLevel?: 'normal' | 'destructive';
|
|
7
|
+
risk?: ApprovalRisk;
|
|
8
|
+
category?: ApprovalRequestCategory;
|
|
9
|
+
runtimeId?: string;
|
|
10
|
+
turnId?: string;
|
|
11
|
+
native?: ApprovalNativeRequestMetadata;
|
|
12
|
+
toolSummary?: string;
|
|
13
|
+
details?: ApprovalRequestDetail[];
|
|
14
|
+
/** File-change preview rendered inline on the approval card (size-disciplined automatically). */
|
|
15
|
+
diff?: CanonUnifiedDiff;
|
|
16
|
+
ignoreSessionRules?: boolean;
|
|
17
|
+
allowSessionRule?: boolean;
|
|
18
|
+
/** Human conversation member who triggered this turn and should answer. */
|
|
19
|
+
responseUserId?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Platform-agnostic approval protocol for Canon.
|
|
23
|
+
*
|
|
24
|
+
* Now a thin `RuntimeRequestManager` subclass: the pending map, deadline timers,
|
|
25
|
+
* the hybrid poll-plus-push loop, and cancellation live in the generalized
|
|
26
|
+
* engine; approval-specific behaviour (session-rule fast path, redacted request
|
|
27
|
+
* metadata, owner-authored outcome messages, and session-rule storage) is
|
|
28
|
+
* expressed as a single `KindDescriptor`. Behaviour is preserved verbatim.
|
|
29
|
+
*/
|
|
30
|
+
export declare class ApprovalManager extends RuntimeRequestManager {
|
|
31
|
+
private config;
|
|
32
|
+
constructor(client: CanonClient, agentId: string, ownerId: string, config?: Partial<ApprovalConfig>);
|
|
33
|
+
/**
|
|
34
|
+
* Request approval for a tool call.
|
|
35
|
+
*
|
|
36
|
+
* 1. Checks session rules — may resolve immediately.
|
|
37
|
+
* 2. Sends a message with approval card metadata.
|
|
38
|
+
* 3. Waits for the owner's reply (or timeout).
|
|
39
|
+
*/
|
|
40
|
+
requestApproval(conversationId: string, toolName: string, toolInput: Record<string, unknown>, opts?: ApprovalRequestOpts, runtimeOptions?: RuntimeRequestOptions): Promise<ApprovalResult>;
|
|
41
|
+
private buildApprovalDescriptor;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type VerbNativeMetadata } from '../backend-contracts/index.js';
|
|
2
|
+
import type { CanonUnifiedDiff } from './types.js';
|
|
3
|
+
export interface ApprovalRequestMetadata {
|
|
4
|
+
type: 'approval_request';
|
|
5
|
+
approvalId: string;
|
|
6
|
+
/** Canon user who should answer this card. UI hint only; reply APIs still enforce authorization. */
|
|
7
|
+
responseUserId?: string;
|
|
8
|
+
toolName: string;
|
|
9
|
+
/** Pre-computed, redacted summary — raw toolInput is never stored */
|
|
10
|
+
toolSummary: string;
|
|
11
|
+
/** Broad action family for richer Canon approval cards. */
|
|
12
|
+
category?: ApprovalRequestCategory;
|
|
13
|
+
/** Preferred v2 risk signal. `riskLevel` remains for older clients. */
|
|
14
|
+
risk?: ApprovalRisk;
|
|
15
|
+
riskLevel?: 'normal' | 'destructive';
|
|
16
|
+
runtimeId?: string;
|
|
17
|
+
turnId?: string;
|
|
18
|
+
/** Native runtime correlation handle. Canon stores this opaquely for plugins/SDK bridges. */
|
|
19
|
+
native?: ApprovalNativeRequestMetadata;
|
|
20
|
+
/** Redacted, normalized details. Raw tool input must not be stored here. */
|
|
21
|
+
details?: ApprovalRequestDetail[];
|
|
22
|
+
/**
|
|
23
|
+
* File-change preview for file approvals — full unified diff so the owner
|
|
24
|
+
* can review the change inline before approving, like native habitats.
|
|
25
|
+
* Size-disciplined via truncateUnifiedDiff.
|
|
26
|
+
*/
|
|
27
|
+
diff?: CanonUnifiedDiff;
|
|
28
|
+
/** Whether the responder may create a rule that applies to later turns. */
|
|
29
|
+
allowSessionRule?: boolean;
|
|
30
|
+
expiresAt: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ApprovalOutcomeMetadata {
|
|
33
|
+
type: 'approval_outcome';
|
|
34
|
+
approvalId?: string;
|
|
35
|
+
decision?: 'allow' | 'deny';
|
|
36
|
+
reason?: 'replied' | 'timeout' | 'session-rule';
|
|
37
|
+
}
|
|
38
|
+
export interface ApprovalReplyMetadata {
|
|
39
|
+
type: 'approval_reply';
|
|
40
|
+
approvalId: string;
|
|
41
|
+
decision: 'allow' | 'deny';
|
|
42
|
+
sessionRule?: SessionRule;
|
|
43
|
+
}
|
|
44
|
+
export type ApprovalRequestCategory = 'command' | 'file' | 'network' | 'browser' | 'mcp' | 'plugin' | 'canon' | 'tool';
|
|
45
|
+
export type ApprovalRisk = 'low' | 'normal' | 'high' | 'destructive';
|
|
46
|
+
export interface ApprovalRequestDetail {
|
|
47
|
+
label: string;
|
|
48
|
+
value: string;
|
|
49
|
+
monospace?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export type ApprovalNativeRequestMetadata = VerbNativeMetadata;
|
|
52
|
+
export interface SessionRule {
|
|
53
|
+
type: 'approve-all' | 'approve-tool' | 'deny-tool';
|
|
54
|
+
/** Tool name pattern (regex) — only for approve-tool/deny-tool */
|
|
55
|
+
toolPattern?: string;
|
|
56
|
+
/** When this rule expires (ISO 8601), null = session lifetime */
|
|
57
|
+
expiresAt?: string | null;
|
|
58
|
+
}
|
|
59
|
+
export interface ApprovalResult {
|
|
60
|
+
decision: 'allow' | 'deny';
|
|
61
|
+
sessionRule?: SessionRule;
|
|
62
|
+
/** Canon-authenticated human who submitted this decision. */
|
|
63
|
+
respondedBy?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ApprovalConfig {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
timeoutSeconds: number;
|
|
68
|
+
defaultOnTimeout: 'deny' | 'ask';
|
|
69
|
+
redactPatterns: string[];
|
|
70
|
+
}
|
|
71
|
+
export declare const DEFAULT_APPROVAL_CONFIG: ApprovalConfig;
|
|
72
|
+
export declare function parseSessionRule(value: unknown): SessionRule | null;
|
|
73
|
+
export declare function parseApprovalReplyMetadata(value: unknown): ApprovalReplyMetadata | null;
|
|
74
|
+
export declare function parseApprovalRequestMetadata(value: unknown): ApprovalRequestMetadata | null;
|