@canonmsg/agent-sdk 12.0.0 → 12.2.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 +97 -7
- package/dist/chunks/chunk-HITMISWV.js +4897 -0
- package/dist/chunks/{chunk-FPQFTTND.js → chunk-J63YVAKA.js} +1627 -1099
- package/dist/chunks/{chunk-OLJ7H4E2.js → chunk-O5C3ZGI4.js} +6363 -7011
- package/dist/chunks/{mls-crypto-NZDNSPAO.js → mls-crypto-ITVGUEP7.js} +3 -3
- package/dist/cli.js +403 -30
- package/dist/drivers/claude.d.ts +8 -2
- package/dist/drivers/codex.d.ts +11 -2
- package/dist/drivers/connector.d.ts +34 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +26 -4
- package/dist/internal/backend-contracts/artifactActions.d.ts +0 -151
- package/dist/internal/backend-contracts/clientFloor.d.ts +52 -0
- package/dist/internal/backend-contracts/communication.d.ts +15 -0
- package/dist/internal/backend-contracts/connectorRelay.d.ts +179 -0
- package/dist/internal/backend-contracts/endpoint.d.ts +17 -0
- package/dist/internal/backend-contracts/endpointContentPolicy.d.ts +15 -4
- package/dist/internal/backend-contracts/index.d.ts +7 -1
- package/dist/internal/backend-contracts/media-url.d.ts +14 -0
- package/dist/internal/backend-contracts/message.d.ts +1 -1
- package/dist/internal/backend-contracts/mlsDevApplication.d.ts +90 -2
- package/dist/internal/backend-contracts/mlsDevCredential.d.ts +5 -2
- package/dist/internal/backend-contracts/mlsDevDeviceCustody.d.ts +2 -1
- package/dist/internal/backend-contracts/mlsDevEnrollment.d.ts +6 -2
- package/dist/internal/backend-contracts/mlsDevFeedReceipt.d.ts +43 -0
- package/dist/internal/backend-contracts/mlsDevGroup.d.ts +129 -5
- package/dist/internal/backend-contracts/mlsDevGroupFeed.d.ts +6 -2
- package/dist/internal/backend-contracts/mlsDevInteraction.d.ts +159 -0
- package/dist/internal/backend-contracts/mlsEnvironment.d.ts +35 -0
- package/dist/internal/backend-contracts/mlsPrincipalAlias.d.ts +26 -0
- package/dist/internal/backend-contracts/runtimeCardFields.d.ts +0 -4
- package/dist/internal/backend-contracts/upload-mime-types.d.ts +17 -0
- package/dist/internal/backend-contracts/verbContract.d.ts +23 -19
- package/dist/internal/backend-contracts/verbSchemas.d.ts +38 -29
- package/dist/internal/core/agent-profiles.d.ts +0 -4
- package/dist/internal/core/approval-format.d.ts +1 -5
- package/dist/internal/core/approval-types.d.ts +1 -2
- package/dist/internal/core/client.d.ts +3 -152
- package/dist/internal/core/constants.d.ts +0 -3
- package/dist/internal/core/endpoint-client.d.ts +14 -1
- package/dist/internal/core/execution-environment-mode.d.ts +0 -2
- package/dist/internal/core/gifs.d.ts +0 -6
- package/dist/internal/core/host-runtime.d.ts +2 -206
- package/dist/internal/core/index.d.ts +22 -63
- package/dist/internal/core/registration.d.ts +1 -17
- package/dist/internal/core/retry.d.ts +0 -9
- package/dist/internal/core/rtdb-rest.d.ts +0 -4
- package/dist/internal/core/runtime-cards.d.ts +0 -45
- package/dist/internal/core/runtime-descriptor.d.ts +1 -60
- package/dist/internal/core/runtime-presentation.d.ts +1 -27
- package/dist/internal/core/runtime-request-manager.d.ts +0 -1
- package/dist/internal/core/self-context.d.ts +0 -39
- package/dist/internal/core/silent-turn.d.ts +1 -38
- package/dist/internal/core/turn-protocol.d.ts +0 -5
- package/dist/internal/core/turn-verbosity.d.ts +5 -23
- package/dist/internal/core/types.d.ts +0 -292
- package/dist/internal/endpoint/engine.d.ts +31 -1
- package/dist/internal/endpoint/index.d.ts +1 -1
- package/dist/internal/endpoint/media.d.ts +5 -0
- package/dist/internal/endpoint/mls-crypto.d.ts +12 -5
- package/dist/internal/endpoint/mls-dev-client.d.ts +9 -1
- package/dist/internal/endpoint/mls-dev-device.d.ts +2 -0
- package/dist/internal/endpoint/mls-dev-groups.d.ts +65 -5
- package/dist/internal/endpoint/mls-dev-interactions.d.ts +99 -0
- package/dist/internal/endpoint/mls-dev-key-package-service.d.ts +13 -0
- package/dist/internal/endpoint/mls-dev-key-packages.d.ts +23 -3
- package/dist/internal/endpoint/mls-dev-text.d.ts +67 -0
- package/dist/internal/endpoint/mls-dev-transport.d.ts +2 -1
- package/dist/internal/endpoint/node-mls-custody-protocol.d.ts +5 -0
- package/dist/internal/endpoint/transport.d.ts +6 -1
- package/dist/media.js +2 -2
- package/dist/runner/errands.d.ts +118 -0
- package/dist/runner/mls.d.ts +97 -0
- package/dist/runner/relay.d.ts +87 -0
- package/dist/runner/runner.d.ts +61 -0
- package/dist/runner/types.d.ts +51 -4
- package/package.json +1 -1
- package/dist/chunks/chunk-6VK4UZHJ.js +0 -2806
- package/dist/internal/backend-contracts/workSessions.d.ts +0 -205
- package/dist/internal/core/agent-resolver.d.ts +0 -49
- package/dist/internal/core/agent-session.d.ts +0 -12
- package/dist/internal/core/artifacts.d.ts +0 -262
- package/dist/internal/core/attached-native-session.d.ts +0 -174
- package/dist/internal/core/attached-session-file-store.d.ts +0 -3
- package/dist/internal/core/control-poller.d.ts +0 -221
- package/dist/internal/core/exclusive-json-file-store.d.ts +0 -7
- package/dist/internal/core/execution-environment.d.ts +0 -55
- package/dist/internal/core/group-context.d.ts +0 -25
- package/dist/internal/core/inbound-frame.d.ts +0 -64
- package/dist/internal/core/local-runtime-catalog.d.ts +0 -131
- package/dist/internal/core/message-format.d.ts +0 -13
- package/dist/internal/core/native-session-interaction.d.ts +0 -44
- package/dist/internal/core/provenance.d.ts +0 -31
- package/dist/internal/core/registration-cli.d.ts +0 -40
- package/dist/internal/core/stream.d.ts +0 -77
- package/dist/internal/core/turn-output-controller.d.ts +0 -69
- package/dist/internal/core/typing-status-publisher.d.ts +0 -14
- package/dist/internal/core/work-session-provider.d.ts +0 -29
- package/dist/internal/core/workspace-discovery.d.ts +0 -17
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { AgentClientType, ExecutionEnvironmentMode } from './types.js';
|
|
2
|
-
import type { WorkSessionSettings } from '../backend-contracts/index.js';
|
|
3
|
-
export type LocalRuntimeKind = AgentClientType | 'sdk';
|
|
4
|
-
export type LocalRuntimeStatus = 'running' | 'offline' | 'stale' | 'manual' | 'embedded';
|
|
5
|
-
export type LocalRuntimeReviveCapability = 'revivable' | 'manual' | 'embedded' | 'missing-profile';
|
|
6
|
-
export interface LocalRuntimeSessionState {
|
|
7
|
-
conversationId: string;
|
|
8
|
-
workspaceId?: string;
|
|
9
|
-
baseCwd: string;
|
|
10
|
-
executionMode?: ExecutionEnvironmentMode;
|
|
11
|
-
codexPolicyFingerprint?: string;
|
|
12
|
-
/** Identifies fingerprints created from deployer-owned local runtime policy. */
|
|
13
|
-
codexPolicyFingerprintFormat?: 'local-v1';
|
|
14
|
-
/**
|
|
15
|
-
* Confirmed owner setup, saved before the first native turn. Runtime-neutral
|
|
16
|
-
* despite its name: every managed coding host (Codex, Claude Code) stores its
|
|
17
|
-
* setup here. The key keeps its original name so existing records and older
|
|
18
|
-
* hosts stay compatible.
|
|
19
|
-
*/
|
|
20
|
-
codexManagedSetup?: {
|
|
21
|
-
requestId: string;
|
|
22
|
-
settings: WorkSessionSettings;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Explicit local reset fences older native session mappings (any resume
|
|
26
|
-
* field) from adoption. Runtime-neutral; see `codexManagedSetup` on the name.
|
|
27
|
-
*/
|
|
28
|
-
codexThreadResetAt?: string;
|
|
29
|
-
/** Local ownership fence; older records without these fields remain importable. */
|
|
30
|
-
ownerId?: string;
|
|
31
|
-
ownershipVersion?: number;
|
|
32
|
-
threadId?: string;
|
|
33
|
-
claudeSessionId?: string;
|
|
34
|
-
hermesSessionId?: string;
|
|
35
|
-
lastInboundMessageId?: string;
|
|
36
|
-
updatedAt: string;
|
|
37
|
-
}
|
|
38
|
-
export interface LocalRuntimeCatalogEntry {
|
|
39
|
-
id: string;
|
|
40
|
-
runtime: LocalRuntimeKind;
|
|
41
|
-
profile: string | null;
|
|
42
|
-
agentId?: string;
|
|
43
|
-
agentName?: string;
|
|
44
|
-
cwd: string;
|
|
45
|
-
baseCwd?: string;
|
|
46
|
-
workspaceRoots?: string[];
|
|
47
|
-
workspaces?: string[];
|
|
48
|
-
launchCommand: string[];
|
|
49
|
-
pid?: number;
|
|
50
|
-
status: LocalRuntimeStatus;
|
|
51
|
-
reviveCapability: LocalRuntimeReviveCapability;
|
|
52
|
-
surfaceMode?: 'host' | 'channel' | 'embedded';
|
|
53
|
-
lastStartedAt?: string;
|
|
54
|
-
lastHeartbeatAt?: string;
|
|
55
|
-
lastStoppedAt?: string;
|
|
56
|
-
lastAuthError?: string;
|
|
57
|
-
lastError?: string;
|
|
58
|
-
sessions?: Record<string, LocalRuntimeSessionState>;
|
|
59
|
-
}
|
|
60
|
-
export type LocalRuntimeResumeField = 'threadId' | 'claudeSessionId' | 'hermesSessionId';
|
|
61
|
-
export type LocalRuntimeSessionResolution = {
|
|
62
|
-
status: 'new';
|
|
63
|
-
} | {
|
|
64
|
-
status: 'exact' | 'adopted';
|
|
65
|
-
state: LocalRuntimeSessionState;
|
|
66
|
-
} | {
|
|
67
|
-
status: 'configuration_required';
|
|
68
|
-
reason: 'ambiguous_mapping' | 'invalid_mapping_timestamp' | 'workspace_unavailable' | 'execution_mode_unavailable';
|
|
69
|
-
message: string;
|
|
70
|
-
};
|
|
71
|
-
export declare const RUNTIMES_DIR: string;
|
|
72
|
-
export declare function buildLocalRuntimeId(input: {
|
|
73
|
-
runtime: LocalRuntimeKind;
|
|
74
|
-
profile?: string | null;
|
|
75
|
-
cwd: string;
|
|
76
|
-
launchCommand?: string[];
|
|
77
|
-
}): string;
|
|
78
|
-
export declare function readLocalRuntimeEntry(id: string): LocalRuntimeCatalogEntry | null;
|
|
79
|
-
export declare function upsertLocalRuntimeEntry(entry: LocalRuntimeCatalogEntry): LocalRuntimeCatalogEntry;
|
|
80
|
-
export declare function heartbeatLocalRuntimeEntry(id: string, patch?: Partial<LocalRuntimeCatalogEntry>): LocalRuntimeCatalogEntry | null;
|
|
81
|
-
export declare function markLocalRuntimeStopped(id: string, patch?: Partial<LocalRuntimeCatalogEntry>): LocalRuntimeCatalogEntry | null;
|
|
82
|
-
export declare function listLocalRuntimeEntries(options?: {
|
|
83
|
-
runtime?: LocalRuntimeKind;
|
|
84
|
-
}): LocalRuntimeCatalogEntry[];
|
|
85
|
-
export declare function loadRuntimeSessionState(runtimeId: string, input: {
|
|
86
|
-
conversationId: string;
|
|
87
|
-
baseCwd: string;
|
|
88
|
-
executionMode?: ExecutionEnvironmentMode;
|
|
89
|
-
workspaceId?: string;
|
|
90
|
-
}): LocalRuntimeSessionState | null;
|
|
91
|
-
/**
|
|
92
|
-
* Resolve the durable local thread/session for a Canon conversation.
|
|
93
|
-
*
|
|
94
|
-
* The current tuple always wins. A changed local default may otherwise point
|
|
95
|
-
* the host at a fresh tuple and accidentally fork a conversation's runtime
|
|
96
|
-
* history, so the unique newest resumable tuple may be adopted when the host
|
|
97
|
-
* can still recreate its workspace and execution mode. Legacy runtime IDs are
|
|
98
|
-
* considered only for the same local agent/profile/surface, and conflicting
|
|
99
|
-
* historical mappings fail closed instead of donating an arbitrary thread.
|
|
100
|
-
*/
|
|
101
|
-
export declare function resolveLocalRuntimeSessionState(runtimeId: string, input: {
|
|
102
|
-
conversationId: string;
|
|
103
|
-
baseCwd: string;
|
|
104
|
-
executionMode?: ExecutionEnvironmentMode;
|
|
105
|
-
workspaceId?: string;
|
|
106
|
-
resumeField: LocalRuntimeResumeField;
|
|
107
|
-
configuredBaseCwds: readonly string[];
|
|
108
|
-
availableExecutionModes: readonly ExecutionEnvironmentMode[];
|
|
109
|
-
}): LocalRuntimeSessionResolution;
|
|
110
|
-
export declare function saveRuntimeSessionState(runtimeId: string, input: Omit<LocalRuntimeSessionState, 'updatedAt'>): LocalRuntimeSessionState;
|
|
111
|
-
/**
|
|
112
|
-
* Atomically discard a conversation's native session IDs (any runtime) while
|
|
113
|
-
* retaining its confirmed setup, ownership and inbound cursor, and fence older
|
|
114
|
-
* mappings from being adopted again.
|
|
115
|
-
*/
|
|
116
|
-
export declare function resetRuntimeSessionState(runtimeId: string, input: {
|
|
117
|
-
conversationId: string;
|
|
118
|
-
baseCwd: string;
|
|
119
|
-
executionMode: ExecutionEnvironmentMode;
|
|
120
|
-
}): LocalRuntimeSessionState;
|
|
121
|
-
/** @deprecated Runtime-neutral now; use {@link resetRuntimeSessionState}. */
|
|
122
|
-
export declare const resetCodexRuntimeSessionState: typeof resetRuntimeSessionState;
|
|
123
|
-
export declare function clearRuntimeSessionState(runtimeId: string, input: {
|
|
124
|
-
conversationId: string;
|
|
125
|
-
baseCwd?: string;
|
|
126
|
-
executionMode?: ExecutionEnvironmentMode;
|
|
127
|
-
workspaceId?: string;
|
|
128
|
-
preserveInboundCursor?: boolean;
|
|
129
|
-
preserveCodexManagedSetup?: boolean;
|
|
130
|
-
}): void;
|
|
131
|
-
export declare function describeProfileLock(profile: string): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CanonMessage } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Project a CanonMessage to a single text representation suitable as a
|
|
4
|
-
* baseline for plugins that feed messages to an LLM as plain text.
|
|
5
|
-
*
|
|
6
|
-
* Plugins that compose richer prompts (placeholders, capability hints,
|
|
7
|
-
* native vision input) layer on top of this — the goal here is only to
|
|
8
|
-
* guarantee that no contentType is ever silently dropped to an empty
|
|
9
|
-
* string. Adding a new contentType to CanonMessage and forgetting to
|
|
10
|
-
* handle it here surfaces in this file's tests, not as a silent
|
|
11
|
-
* regression in every consumer plugin.
|
|
12
|
-
*/
|
|
13
|
-
export declare function formatCanonMessageAsText(message: Pick<CanonMessage, 'contentType' | 'text' | 'attachments' | 'contactCard' | 'interaction'>): string;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { ApprovalNativeRequestMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalRisk } from './approval-types.js';
|
|
2
|
-
import type { CanonUnifiedDiff } from './types.js';
|
|
3
|
-
import type { RuntimeInputRequestPayload } from './runtime-request-manager.js';
|
|
4
|
-
import type { RuntimeInputAnswers } from './runtime-cards.js';
|
|
5
|
-
interface NativeInteractionIdentity {
|
|
6
|
-
/** Provider-scoped request identity, used to correlate cancellation and replies. */
|
|
7
|
-
nativeRequestId: string;
|
|
8
|
-
nativeSessionId: string;
|
|
9
|
-
turnId?: string;
|
|
10
|
-
}
|
|
11
|
-
export type NativeSessionInteractionRequest = NativeInteractionIdentity & ({
|
|
12
|
-
kind: 'approval';
|
|
13
|
-
approval: {
|
|
14
|
-
toolName: string;
|
|
15
|
-
toolInput: Record<string, unknown>;
|
|
16
|
-
toolSummary: string;
|
|
17
|
-
category?: ApprovalRequestCategory;
|
|
18
|
-
risk?: ApprovalRisk;
|
|
19
|
-
riskLevel?: 'normal' | 'destructive';
|
|
20
|
-
native?: ApprovalNativeRequestMetadata;
|
|
21
|
-
details?: ApprovalRequestDetail[];
|
|
22
|
-
diff?: CanonUnifiedDiff;
|
|
23
|
-
};
|
|
24
|
-
} | {
|
|
25
|
-
kind: 'input';
|
|
26
|
-
input: Omit<RuntimeInputRequestPayload, 'responseUserId' | 'turnId'>;
|
|
27
|
-
});
|
|
28
|
-
export type NativeSessionInteractionResult = {
|
|
29
|
-
kind: 'approval';
|
|
30
|
-
decision: 'allow' | 'deny';
|
|
31
|
-
} | {
|
|
32
|
-
kind: 'input';
|
|
33
|
-
answers: RuntimeInputAnswers;
|
|
34
|
-
} | {
|
|
35
|
-
kind: 'cancelled';
|
|
36
|
-
};
|
|
37
|
-
/** The host owns the Canon audience, owner responder, request IDs and deadlines. */
|
|
38
|
-
export interface NativeSessionInteractionBridge {
|
|
39
|
-
/** Abort when a native client answers first, the observer closes, or the request is cleared. */
|
|
40
|
-
request(request: NativeSessionInteractionRequest, options: {
|
|
41
|
-
signal: AbortSignal;
|
|
42
|
-
}): Promise<NativeSessionInteractionResult>;
|
|
43
|
-
}
|
|
44
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { CanonConversation, CanonMessage, CanonRuntimeProvenance } from './types.js';
|
|
2
|
-
import type { CanonSelfContext } from './self-context.js';
|
|
3
|
-
export declare function buildRuntimeProvenance(input: {
|
|
4
|
-
conversationId: string;
|
|
5
|
-
conversationType?: CanonConversation['type'] | 'unknown' | string | null;
|
|
6
|
-
memberCount?: number | null;
|
|
7
|
-
senderId: string;
|
|
8
|
-
senderName?: string | null;
|
|
9
|
-
senderType?: CanonMessage['senderType'] | string | null;
|
|
10
|
-
isOwner?: boolean | null;
|
|
11
|
-
agentId?: string | null;
|
|
12
|
-
mentions?: readonly string[] | null;
|
|
13
|
-
mentionedAgent?: boolean | null;
|
|
14
|
-
activeSelfContextId?: string | null;
|
|
15
|
-
selfContexts?: readonly CanonSelfContext[] | null;
|
|
16
|
-
}): CanonRuntimeProvenance;
|
|
17
|
-
export declare function resolveRuntimeProvenance(input: {
|
|
18
|
-
provenance?: CanonRuntimeProvenance | null;
|
|
19
|
-
conversationId: string;
|
|
20
|
-
conversationType?: CanonConversation['type'] | 'unknown' | string | null;
|
|
21
|
-
memberCount?: number | null;
|
|
22
|
-
senderId: string;
|
|
23
|
-
senderName?: string | null;
|
|
24
|
-
senderType?: CanonMessage['senderType'] | string | null;
|
|
25
|
-
isOwner?: boolean | null;
|
|
26
|
-
agentId?: string | null;
|
|
27
|
-
mentions?: readonly string[] | null;
|
|
28
|
-
mentionedAgent?: boolean | null;
|
|
29
|
-
activeSelfContextId?: string | null;
|
|
30
|
-
selfContexts?: readonly CanonSelfContext[] | null;
|
|
31
|
-
}): CanonRuntimeProvenance;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type AgentOriginDeclaration } from '../backend-contracts/index.js';
|
|
2
|
-
import type { AgentClientType } from './types.js';
|
|
3
|
-
export interface RegistrationCliOptions {
|
|
4
|
-
/**
|
|
5
|
-
* `import.meta.url` of the plugin's own CLI entry module. Required so
|
|
6
|
-
* direct-execution detection and `--version` resolve against the plugin
|
|
7
|
-
* package, not @canonmsg/core.
|
|
8
|
-
*/
|
|
9
|
-
moduleUrl: string;
|
|
10
|
-
clientType: AgentClientType;
|
|
11
|
-
/** Optional self-reported public source; callers may override it with CLI flags. */
|
|
12
|
-
origin?: AgentOriginDeclaration;
|
|
13
|
-
/** Published bin name, e.g. `canon-register`. */
|
|
14
|
-
cliName: string;
|
|
15
|
-
/** Host bin the operator starts after approval, e.g. `canon-claude`. */
|
|
16
|
-
hostBinName: string;
|
|
17
|
-
developerInfo: string;
|
|
18
|
-
help: string;
|
|
19
|
-
/** Full usage line printed when a required flag is missing. */
|
|
20
|
-
usage: string;
|
|
21
|
-
/** Noun used in the "Registering <label> ..." progress line. */
|
|
22
|
-
registeringLabel: string;
|
|
23
|
-
/**
|
|
24
|
-
* Optional host-specific instructions printed after approval. When omitted,
|
|
25
|
-
* Canon emits the conventional local host-binary startup guidance.
|
|
26
|
-
*/
|
|
27
|
-
approvedInstructions?: (profileName: string) => readonly string[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Shared orchestration for the per-plugin registration CLIs
|
|
31
|
-
* (`canon-register`, `canon-codex-register`). Every string that differs
|
|
32
|
-
* between plugins is a parameter so each CLI's stdout/stderr stays exactly
|
|
33
|
-
* what it was before consolidation.
|
|
34
|
-
*/
|
|
35
|
-
export declare function runRegistrationCli(options: RegistrationCliOptions): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Entry-point wrapper: runs {@link runRegistrationCli} under the shared
|
|
38
|
-
* `runCli` harness (direct-execution guard, `--help` / `--version`).
|
|
39
|
-
*/
|
|
40
|
-
export declare function registerRegistrationCli(options: RegistrationCliOptions): void;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { CanonEndpoint } from './endpoint-client.js';
|
|
2
|
-
import type { AgentContext, ContactAddedPayload, ContactRemovedPayload, ConversationUpdatedPayload, MessageCreatedPayload, MessageUpdatedPayload, TypingPayload, PresencePayload, RuntimeUpdatedPayload, RuntimeControlEventPayload, TurnUpdatedPayload, ParticipationSuppressedPayload, VoiceSessionEventPayload } from './types.js';
|
|
3
|
-
export interface CanonStreamErrorPayload {
|
|
4
|
-
code?: string;
|
|
5
|
-
message?: string;
|
|
6
|
-
retryAfterMs?: number;
|
|
7
|
-
activeConnections?: number;
|
|
8
|
-
maxConnections?: number;
|
|
9
|
-
[key: string]: unknown;
|
|
10
|
-
}
|
|
11
|
-
export interface ReplayExpiredPayload {
|
|
12
|
-
/** Oldest event id still available in the server's replay buffer, if any. */
|
|
13
|
-
lastAvailableId?: string | null;
|
|
14
|
-
message?: string;
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
}
|
|
17
|
-
export declare class CanonStreamError extends Error {
|
|
18
|
-
readonly code?: string;
|
|
19
|
-
readonly retryAfterMs?: number;
|
|
20
|
-
readonly payload: CanonStreamErrorPayload;
|
|
21
|
-
constructor(payload: CanonStreamErrorPayload, fallbackMessage: string);
|
|
22
|
-
}
|
|
23
|
-
export type StreamHandler = {
|
|
24
|
-
onMessage: (payload: MessageCreatedPayload) => void;
|
|
25
|
-
onMessageUpdated?: (payload: MessageUpdatedPayload) => void;
|
|
26
|
-
onAgentContext?: (ctx: AgentContext) => void;
|
|
27
|
-
onContactAdded?: (payload: ContactAddedPayload) => void;
|
|
28
|
-
onContactRemoved?: (payload: ContactRemovedPayload) => void;
|
|
29
|
-
onTyping?: (data: TypingPayload) => void;
|
|
30
|
-
onPresence?: (data: PresencePayload) => void;
|
|
31
|
-
onRuntimeUpdated?: (payload: RuntimeUpdatedPayload) => void;
|
|
32
|
-
onTurnUpdated?: (payload: TurnUpdatedPayload) => void;
|
|
33
|
-
/** Observe-only: the participation gate suppressed a turn for this agent. */
|
|
34
|
-
onParticipationSuppressed?: (payload: ParticipationSuppressedPayload) => void;
|
|
35
|
-
onRuntimeControl?: (payload: RuntimeControlEventPayload) => void;
|
|
36
|
-
onVoiceSessionStarted?: (payload: VoiceSessionEventPayload) => void;
|
|
37
|
-
onVoiceSessionEnded?: (payload: VoiceSessionEventPayload) => void;
|
|
38
|
-
onMessageDeleted?: (payload: {
|
|
39
|
-
conversationId: string;
|
|
40
|
-
messageId: string;
|
|
41
|
-
}) => void;
|
|
42
|
-
onConversationUpdated?: (payload: ConversationUpdatedPayload) => void;
|
|
43
|
-
onConnected?: () => void;
|
|
44
|
-
onDisconnected?: () => void;
|
|
45
|
-
/**
|
|
46
|
-
* Fired when the server reports the replay window expired (`replay.expired`):
|
|
47
|
-
* the reconnect cursor was evicted, so events in the gap were NOT replayed
|
|
48
|
-
* and must be recovered out-of-band (e.g. via the REST API). The transport
|
|
49
|
-
* stays policy-free — it only clears its cursor and surfaces the expiry.
|
|
50
|
-
*
|
|
51
|
-
* When this handler is provided it REPLACES the synthetic
|
|
52
|
-
* `Replay expired — some messages may have been missed` error on `onError`;
|
|
53
|
-
* raw consumers that only register `onError` keep the existing behavior.
|
|
54
|
-
*/
|
|
55
|
-
onReplayExpired?: (payload: ReplayExpiredPayload) => void;
|
|
56
|
-
onError?: (error: Error) => void;
|
|
57
|
-
};
|
|
58
|
-
/** Typed agent event projection; the endpoint owns authentication, SSE and reconnect. */
|
|
59
|
-
export declare class CanonStream {
|
|
60
|
-
private readonly endpoint;
|
|
61
|
-
private readonly agentId;
|
|
62
|
-
private readonly handler;
|
|
63
|
-
private unsubscribe?;
|
|
64
|
-
private releaseRecovery?;
|
|
65
|
-
private running;
|
|
66
|
-
private generation;
|
|
67
|
-
private resolveStopped?;
|
|
68
|
-
constructor(options: {
|
|
69
|
-
endpoint: CanonEndpoint;
|
|
70
|
-
agentId: string;
|
|
71
|
-
handler: StreamHandler;
|
|
72
|
-
});
|
|
73
|
-
start(): Promise<void>;
|
|
74
|
-
private forwardPlaintextMessage;
|
|
75
|
-
stop(): void;
|
|
76
|
-
isRunning(): boolean;
|
|
77
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { StreamingStatus, TurnOutputBlock, TurnOutputBlockKind, TurnOutputBlockStatus } from './types.js';
|
|
2
|
-
export type TurnOutputMode = 'delta' | 'block' | 'snapshot' | 'status';
|
|
3
|
-
export interface TurnOutputSnapshot {
|
|
4
|
-
turnId: string;
|
|
5
|
-
messageId: string;
|
|
6
|
-
text: string;
|
|
7
|
-
status: StreamingStatus;
|
|
8
|
-
blocks?: TurnOutputBlock[];
|
|
9
|
-
}
|
|
10
|
-
export interface TurnOutputBlockInput {
|
|
11
|
-
id: string;
|
|
12
|
-
kind: TurnOutputBlockKind;
|
|
13
|
-
status?: TurnOutputBlockStatus;
|
|
14
|
-
sequence?: number;
|
|
15
|
-
title?: string;
|
|
16
|
-
text?: string;
|
|
17
|
-
summary?: string;
|
|
18
|
-
detail?: string;
|
|
19
|
-
}
|
|
20
|
-
export interface BuildBoundedTurnTrailOptions {
|
|
21
|
-
maxBlocks?: number;
|
|
22
|
-
maxMetadataBytes?: number;
|
|
23
|
-
}
|
|
24
|
-
export interface TurnOutputControllerOptions {
|
|
25
|
-
turnId: string;
|
|
26
|
-
mode?: TurnOutputMode;
|
|
27
|
-
throttleMs?: number;
|
|
28
|
-
blockSeparator?: string;
|
|
29
|
-
writeSnapshot: (snapshot: TurnOutputSnapshot) => void | Promise<void>;
|
|
30
|
-
clearSnapshot: () => void | Promise<void>;
|
|
31
|
-
schedule?: typeof setTimeout;
|
|
32
|
-
cancel?: typeof clearTimeout;
|
|
33
|
-
}
|
|
34
|
-
export interface TurnOutputController {
|
|
35
|
-
readonly turnId: string;
|
|
36
|
-
readonly mode: TurnOutputMode;
|
|
37
|
-
getText(): string;
|
|
38
|
-
getStatus(): StreamingStatus;
|
|
39
|
-
getBlocks(): TurnOutputBlock[];
|
|
40
|
-
getFinalTrail(): TurnOutputBlock[];
|
|
41
|
-
startThinking(text?: string): Promise<void>;
|
|
42
|
-
startStreaming(text?: string): Promise<void>;
|
|
43
|
-
appendDelta(delta: string): void;
|
|
44
|
-
appendBlock(block: string): void;
|
|
45
|
-
appendTextSegmentDelta(id: string, delta: string, patch?: Partial<Omit<TurnOutputBlockInput, 'id' | 'kind' | 'sequence' | 'text'>>): void;
|
|
46
|
-
replaceTextSegmentSnapshot(id: string, text: string, patch?: Partial<Omit<TurnOutputBlockInput, 'id' | 'kind' | 'sequence' | 'text'>>): void;
|
|
47
|
-
replaceSnapshot(text: string, status?: StreamingStatus): Promise<void>;
|
|
48
|
-
setStatus(status: StreamingStatus, text?: string): Promise<void>;
|
|
49
|
-
addBlock(block: TurnOutputBlockInput): Promise<TurnOutputBlock>;
|
|
50
|
-
updateBlock(id: string, patch: Partial<Omit<TurnOutputBlockInput, 'id' | 'sequence'>>): Promise<TurnOutputBlock | null>;
|
|
51
|
-
completeBlock(id: string, patch?: Partial<Omit<TurnOutputBlockInput, 'id' | 'sequence' | 'status'>>): Promise<TurnOutputBlock | null>;
|
|
52
|
-
failBlock(id: string, patch?: Partial<Omit<TurnOutputBlockInput, 'id' | 'sequence' | 'status'>>): Promise<TurnOutputBlock | null>;
|
|
53
|
-
flush(status?: StreamingStatus): Promise<void>;
|
|
54
|
-
waitingInput(): Promise<void>;
|
|
55
|
-
interrupt(): Promise<void>;
|
|
56
|
-
clear(): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Deliberate silence: blank the node (text '' and an EXPLICIT empty blocks
|
|
59
|
-
* array) and then delete it, so onStreamingCleared sees empty content and
|
|
60
|
-
* skips the salvage fallback. The empty array is load-bearing: merge writers
|
|
61
|
-
* (POST /streaming, OpenClaw PATCH) leave stale blocks behind when the key
|
|
62
|
-
* is absent, and the trigger then synthesizes salvage text from block titles.
|
|
63
|
-
*/
|
|
64
|
-
blankAndClear(): Promise<void>;
|
|
65
|
-
}
|
|
66
|
-
export declare const DEFAULT_TURN_TRAIL_MAX_BLOCKS = 20;
|
|
67
|
-
export declare const DEFAULT_TURN_TRAIL_METADATA_BUDGET_BYTES = 2500;
|
|
68
|
-
export declare function buildBoundedTurnTrail(blocks: readonly TurnOutputBlock[], options?: BuildBoundedTurnTrailOptions): TurnOutputBlock[];
|
|
69
|
-
export declare function createTurnOutputController(options: TurnOutputControllerOptions): TurnOutputController;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TypingPayload } from './types.js';
|
|
2
|
-
export type TypingPresenceStatus = TypingPayload['status'];
|
|
3
|
-
export interface TypingStatusPublisherOptions {
|
|
4
|
-
setTyping: (conversationId: string, typing: boolean, status?: TypingPresenceStatus) => Promise<void> | void;
|
|
5
|
-
keepaliveMs?: number;
|
|
6
|
-
schedule?: typeof setInterval;
|
|
7
|
-
cancel?: typeof clearInterval;
|
|
8
|
-
}
|
|
9
|
-
export interface TypingStatusPublisher {
|
|
10
|
-
start(conversationId: string, status?: TypingPresenceStatus): Promise<void>;
|
|
11
|
-
clear(conversationId: string): Promise<void>;
|
|
12
|
-
dispose(conversationId?: string): void;
|
|
13
|
-
}
|
|
14
|
-
export declare function createTypingStatusPublisher(options: TypingStatusPublisherOptions): TypingStatusPublisher;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { WorkSessionCatalog, WorkSessionDetailFields, WorkSessionSelection, WorkSessionSettings } from '../backend-contracts/index.js';
|
|
2
|
-
import type { AttachedNativeSessionAdapter } from './attached-native-session.js';
|
|
3
|
-
import type { NativeSessionInteractionBridge } from './native-session-interaction.js';
|
|
4
|
-
export interface NativeWorkSessionCreateContext {
|
|
5
|
-
requestId: string;
|
|
6
|
-
conversationId: string;
|
|
7
|
-
agentId: string;
|
|
8
|
-
}
|
|
9
|
-
export interface NativeWorkSessionCreated {
|
|
10
|
-
nativeSessionId: string;
|
|
11
|
-
settings: WorkSessionSettings;
|
|
12
|
-
}
|
|
13
|
-
/** A lost acknowledgement is not permission to create another native session. */
|
|
14
|
-
export declare class NativeWorkSessionCreateError extends Error {
|
|
15
|
-
readonly outcome: 'not_created' | 'uncertain';
|
|
16
|
-
constructor(message: string, outcome: 'not_created' | 'uncertain', options?: ErrorOptions);
|
|
17
|
-
}
|
|
18
|
-
/** Provider-only operations; Canon admission, bindings and transport belong to the SDK host. */
|
|
19
|
-
export interface NativeWorkSessionProvider {
|
|
20
|
-
catalog(): Promise<WorkSessionCatalog>;
|
|
21
|
-
create(selection: Extract<WorkSessionSelection, {
|
|
22
|
-
mode: 'create';
|
|
23
|
-
}>, context: NativeWorkSessionCreateContext): Promise<NativeWorkSessionCreated>;
|
|
24
|
-
open(nativeSessionId: string, interactionBridge?: NativeSessionInteractionBridge): Promise<AttachedNativeSessionAdapter>;
|
|
25
|
-
/** Private, read-only runtime observations. Opening details must not resume the native thread. */
|
|
26
|
-
describe?(nativeSessionId: string, settings: WorkSessionSettings): Promise<WorkSessionDetailFields>;
|
|
27
|
-
/** Close owned connections. Never delete native sessions or their working directories. */
|
|
28
|
-
close(): Promise<void>;
|
|
29
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type ConfiguredWorkspaceOption } from './execution-environment.js';
|
|
2
|
-
import type { CanonWorkspaceRootMetadata } from './types.js';
|
|
3
|
-
export interface ConfiguredWorkspaceRoot extends CanonWorkspaceRootMetadata {
|
|
4
|
-
cwd: string;
|
|
5
|
-
}
|
|
6
|
-
export interface WorkspaceDiscoveryResult {
|
|
7
|
-
workspaceOptions: ConfiguredWorkspaceOption[];
|
|
8
|
-
workspaceRoots: ConfiguredWorkspaceRoot[];
|
|
9
|
-
warnings: string[];
|
|
10
|
-
}
|
|
11
|
-
export declare function buildWorkspaceRootId(workspaceRoot: string): string;
|
|
12
|
-
export declare function buildPublicWorkspaceRoots(roots: ReadonlyArray<ConfiguredWorkspaceRoot>): CanonWorkspaceRootMetadata[];
|
|
13
|
-
export declare function buildConfiguredWorkspaceOptionsWithRoots(input: {
|
|
14
|
-
primaryCwd: string;
|
|
15
|
-
configuredWorkspaces?: string[];
|
|
16
|
-
workspaceRoots?: string[];
|
|
17
|
-
}): WorkspaceDiscoveryResult;
|