@canonmsg/core 0.17.1 → 0.18.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/dist/browser.d.ts +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/rtdb-rest.d.ts +14 -1
- package/dist/rtdb-rest.js +45 -0
- package/dist/runtime-descriptor.d.ts +2 -1
- package/dist/runtime-descriptor.js +1 -0
- package/dist/runtime-state-publisher.d.ts +9 -1
- package/dist/runtime-state-publisher.js +63 -1
- package/dist/types.d.ts +59 -2
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AGENT_CAPABILITIES, CLAUDE_PERMISSION_MODE_OPTIONS, } from './types.js';
|
|
2
2
|
export { resolveCanonBaseUrl } from './base-url.js';
|
|
3
3
|
export { DEFAULT_BASE_URL, DEFAULT_STREAM_URL, DEFAULT_RTDB_URL, FIREBASE_WEB_API_KEY } from './constants.js';
|
|
4
|
-
export type { AddMemberResult, AgentCapabilities, AgentClientType, AgentSessionSnapshot, AgentRuntime, CanonControlAvailability, CanonControlDescriptor, CanonControlLiveBehavior, CanonControlSelectionPolicy, CanonControlValue, CanonContact, CanonContactRequest, CanonContactRequestStatus, CanonResolveAdmissionResult, ContactAddedPayload, ContactApprovedPayload, ContactRemovedPayload, ContactRequestPayload, ContactSource, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, CanonStreamEvent, CreateContactRequestResult, MediaAttachment, MediaAttachmentKind, ModelOption, PermissionModeOption, CanonRuntimeDescriptor, CanonRuntimeActionAvailability, CanonRuntimeActionCategory, CanonRuntimeActionDescriptor, CanonRuntimeActionDispatch, CanonRuntimeActionPlacement, CanonRuntimeDetailTier, CanonRuntimeExecutionMetadata, CanonRuntimeInventory, CanonRuntimeInventoryEntry, CanonRuntimeStreamingMode, CanonRuntimeStatusItem, CanonRuntimeSurfaceMode, CanonWorkspaceRootMetadata, RuntimeUpdatedPayload, RuntimeInfoPayload, RuntimeControlError, RuntimeControlState, RuntimeControlValueSource, ResolvedAdmission, SessionConfig, TurnUpdatedPayload, WorkspaceOption, WorkspaceOptionSource, } from './types.js';
|
|
4
|
+
export type { AddMemberResult, AgentCapabilities, AgentClientType, AgentSessionSnapshot, AgentRuntime, CanonControlAvailability, CanonControlDescriptor, CanonControlLiveBehavior, CanonControlSelectionPolicy, CanonControlValue, CanonContact, CanonContactRequest, CanonContactRequestStatus, CanonResolveAdmissionResult, ContactAddedPayload, ContactApprovedPayload, ContactRemovedPayload, ContactRequestPayload, ContactSource, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, CanonStreamEvent, CreateContactRequestResult, MediaAttachment, MediaAttachmentKind, ModelOption, PermissionModeOption, CanonRuntimeDescriptor, CanonRuntimeActionAvailability, CanonRuntimeActionCategory, CanonRuntimeActionDescriptor, CanonRuntimeActionDispatch, CanonRuntimeActionPlacement, CanonRuntimeCommandArgumentChoice, CanonRuntimeCommandArgumentDescriptor, CanonRuntimeCommandArgumentKind, CanonRuntimeCommandDescriptor, CanonRuntimeDetailTier, CanonRuntimeExecutionMetadata, CanonRuntimeActivityItem, CanonRuntimeActivityKind, CanonRuntimeActivityStatus, CanonRuntimeFact, CanonRuntimeFactGroup, CanonRuntimeInventory, CanonRuntimeInventoryEntry, CanonRuntimePrimitiveId, CanonRuntimeStreamingMode, CanonRuntimeStatusItem, CanonRuntimeSurfaceMode, CanonWorkspaceRootMetadata, RuntimeUpdatedPayload, RuntimeInfoPayload, RuntimeControlError, RuntimeControlState, RuntimeControlValueSource, ResolvedAdmission, SessionConfig, TurnUpdatedPayload, WorkspaceOption, WorkspaceOptionSource, } from './types.js';
|
|
5
5
|
export { EXECUTION_ENVIRONMENT_MODES, isExecutionEnvironmentMode, } from './execution-environment-mode.js';
|
|
6
6
|
export type { ExecutionEnvironmentMode } from './execution-environment-mode.js';
|
|
7
7
|
export type { CanonSelfContext, CanonSelfContextType, SelfContextPromptRenderOptions, SendContextualMessageOptions, SendContextualMessageResult, SendContextualSelfContextInput, } from './self-context.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AGENT_CAPABILITIES, CLAUDE_PERMISSION_MODE_OPTIONS, } from './types.js';
|
|
2
|
-
export type { AddMemberResult, AgentCapabilities, AgentClientType, CanonControlAvailability, CanonControlDescriptor, CanonControlLiveBehavior, CanonControlSelectionPolicy, CanonControlValue, CanonContact, CanonContactRequest, CanonContactRequestStatus, CanonGroupContext, CanonGroupContextMode, CanonKnownRecentParticipant, CanonMembershipChange, CanonResolveAdmissionResult, ConversationUpdatedPayload, ContactAddedPayload, ContactApprovedPayload, ContactCardPayload, ContactRemovedPayload, ContactRequestPayload, ContactSource, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, CanonMessage, CanonConversation, CanonMessagesPage, CreateContactRequestResult, AgentContext, CanonStreamEvent, AgentSessionSnapshot, ResolvedAdmission, MediaAttachment, MediaAttachmentKind, MessageCreatedPayload, TypingPayload, PresencePayload, RuntimeUpdatedPayload, TurnUpdatedPayload, SendMessageOptions, CreateConversationOptions, RegistrationInput, RegistrationResult, RegistrationStatus, StreamingStatus, SetStreamingOptions, SessionControl, SessionState, SessionConfig, AgentRuntime, CanonRuntimeDescriptor, CanonRuntimeActionAvailability, CanonRuntimeActionCategory, CanonRuntimeActionDescriptor, CanonRuntimeActionDispatch, CanonRuntimeActionPlacement, CanonRuntimeDetailTier, CanonRuntimeExecutionMetadata, CanonRuntimeInventory, CanonRuntimeInventoryEntry, CanonRuntimeStreamingMode, CanonRuntimeStatusItem, CanonRuntimeSurfaceMode, CanonWorkspaceRootMetadata, ModelOption, PermissionModeOption, RuntimeInfoPayload, RuntimeControlError, RuntimeControlState, RuntimeControlValueSource, WorkspaceOption, WorkspaceOptionSource, } from './types.js';
|
|
2
|
+
export type { AddMemberResult, AgentCapabilities, AgentClientType, CanonControlAvailability, CanonControlDescriptor, CanonControlLiveBehavior, CanonControlSelectionPolicy, CanonControlValue, CanonContact, CanonContactRequest, CanonContactRequestStatus, CanonGroupContext, CanonGroupContextMode, CanonKnownRecentParticipant, CanonMembershipChange, CanonResolveAdmissionResult, ConversationUpdatedPayload, ContactAddedPayload, ContactApprovedPayload, ContactCardPayload, ContactRemovedPayload, ContactRequestPayload, ContactSource, ResolvedAdmissionState, ResolvedAdmissionTargetSummary, ResolvedTargetAdmissionPayload, CanonMessage, CanonConversation, CanonMessagesPage, CreateContactRequestResult, AgentContext, CanonStreamEvent, AgentSessionSnapshot, ResolvedAdmission, MediaAttachment, MediaAttachmentKind, MessageCreatedPayload, TypingPayload, PresencePayload, RuntimeUpdatedPayload, TurnUpdatedPayload, SendMessageOptions, CreateConversationOptions, RegistrationInput, RegistrationResult, RegistrationStatus, StreamingStatus, SetStreamingOptions, SessionControl, SessionState, SessionConfig, AgentRuntime, CanonRuntimeDescriptor, CanonRuntimeActionAvailability, CanonRuntimeActionCategory, CanonRuntimeActionDescriptor, CanonRuntimeActionDispatch, CanonRuntimeActionPlacement, CanonRuntimeCommandArgumentChoice, CanonRuntimeCommandArgumentDescriptor, CanonRuntimeCommandArgumentKind, CanonRuntimeCommandDescriptor, CanonRuntimeDetailTier, CanonRuntimeExecutionMetadata, CanonRuntimeActivityItem, CanonRuntimeActivityKind, CanonRuntimeActivityStatus, CanonRuntimeFact, CanonRuntimeFactGroup, CanonRuntimeInventory, CanonRuntimeInventoryEntry, CanonRuntimePrimitiveId, CanonRuntimeStreamingMode, CanonRuntimeStatusItem, CanonRuntimeSurfaceMode, CanonWorkspaceRootMetadata, ModelOption, PermissionModeOption, RuntimeInfoPayload, RuntimeControlError, RuntimeControlState, RuntimeControlValueSource, WorkspaceOption, WorkspaceOptionSource, } from './types.js';
|
|
3
3
|
export type { CanonSelfContext, CanonSelfContextType, SelfContextPromptRenderOptions, SendContextualMessageOptions, SendContextualMessageResult, SendContextualSelfContextInput, } from './self-context.js';
|
|
4
4
|
export { buildSelfContextPromptLines, normalizeSelfContexts, resolveMessageActiveSelfContextId, selectActiveSelfContexts, } from './self-context.js';
|
|
5
5
|
export { buildConfiguredWorkspaceOptionsWithRoots, buildPublicWorkspaceRoots, buildWorkspaceRootId, discoverWorkspaceProjects, } from './workspace-discovery.js';
|
|
@@ -30,13 +30,13 @@ export { RUNTIMES_DIR, buildLocalRuntimeId, clearRuntimeSessionState, describePr
|
|
|
30
30
|
export type { LocalRuntimeCatalogEntry, LocalRuntimeKind, LocalRuntimeReviveCapability, LocalRuntimeSessionState, LocalRuntimeStatus, } from './local-runtime-catalog.js';
|
|
31
31
|
export { buildConfiguredWorkspaceOptions, buildConversationEnvironmentKey, buildConversationWorktreeSpec, buildPublicWorkspaceOptions, buildWorkspaceOptionId, EXECUTION_ENVIRONMENT_MODES, isEnabledFlag, isExecutionEnvironmentMode, normalizeOptionalString, readSessionWorkspaceConfig, resolveConfiguredWorkspaceCwd, ExecutionEnvironmentError, prepareConversationEnvironment, releaseConversationEnvironment, } from './execution-environment.js';
|
|
32
32
|
export type { ConfiguredWorkspaceOption, ExecutionEnvironmentMode, PreparedExecutionEnvironment, SessionWorkspaceConfig, } from './execution-environment.js';
|
|
33
|
-
export { initRTDBAuth, rtdbWrite, rtdbRead, patchAgentSessionSnapshot, patchRuntimeInfo, writeRuntimeInfo, clearRuntimeInfo, writeSessionState, clearSessionState, writeTurnState, clearTurnState, } from './rtdb-rest.js';
|
|
34
|
-
export type { AgentSessionSnapshotPatch, RTDBClientHandle, RuntimeInfoPayloadData, SessionStatePayload, TurnStatePayload, } from './rtdb-rest.js';
|
|
33
|
+
export { initRTDBAuth, rtdbWrite, rtdbRead, patchAgentSessionSnapshot, patchRuntimeInfo, readRuntimeActivity, writeRuntimeActivity, removeRuntimeActivityItem, clearRuntimeActivity, writeRuntimeInfo, clearRuntimeInfo, writeSessionState, clearSessionState, writeTurnState, clearTurnState, } from './rtdb-rest.js';
|
|
34
|
+
export type { AgentSessionSnapshotPatch, RTDBClientHandle, RuntimeActivityPayloadData, RuntimeInfoPayloadData, SessionStatePayload, TurnStatePayload, } from './rtdb-rest.js';
|
|
35
35
|
export { buildCanonHostPrompt, buildHydratedInboundContext, createConversationMetadataLoader, loadHostSessionConfig, publishHostAgentRuntime, publishHostSessionSnapshots, readHostSessionConfig, renderCanonHostInboundContent, resolveHostWorkspaceCwd, } from './host-runtime.js';
|
|
36
36
|
export type { HostInboundParticipantContext, } from './host-runtime.js';
|
|
37
37
|
export { buildCanonGroupContext, buildCanonKnownRecentParticipants, buildCompactGroupContextLines, diffCanonMemberIds, } from './group-context.js';
|
|
38
38
|
export { createRuntimeStatePublisher, } from './runtime-state-publisher.js';
|
|
39
|
-
export type { RuntimeStatePublisher, RuntimeStatePublisherOptions, RuntimeStreamingPayload, } from './runtime-state-publisher.js';
|
|
39
|
+
export type { RuntimeStatePublisher, RuntimeStatePublisherOptions, RuntimeStreamingPayload, ClearRuntimeActivityOptions, } from './runtime-state-publisher.js';
|
|
40
40
|
export { formatCanonMessageAsText } from './message-format.js';
|
|
41
41
|
export { reachOutToCanonContact } from './reach-out.js';
|
|
42
42
|
export type { CanonReachOutClient, CanonReachOutOptions, CanonReachOutResult, } from './reach-out.js';
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,7 @@ export { RUNTIMES_DIR, buildLocalRuntimeId, clearRuntimeSessionState, describePr
|
|
|
29
29
|
// Execution environments for host-mode coding sessions
|
|
30
30
|
export { buildConfiguredWorkspaceOptions, buildConversationEnvironmentKey, buildConversationWorktreeSpec, buildPublicWorkspaceOptions, buildWorkspaceOptionId, EXECUTION_ENVIRONMENT_MODES, isEnabledFlag, isExecutionEnvironmentMode, normalizeOptionalString, readSessionWorkspaceConfig, resolveConfiguredWorkspaceCwd, ExecutionEnvironmentError, prepareConversationEnvironment, releaseConversationEnvironment, } from './execution-environment.js';
|
|
31
31
|
// RTDB REST helpers (token exchange, session state, generic read/write)
|
|
32
|
-
export { initRTDBAuth, rtdbWrite, rtdbRead, patchAgentSessionSnapshot, patchRuntimeInfo, writeRuntimeInfo, clearRuntimeInfo, writeSessionState, clearSessionState, writeTurnState, clearTurnState, } from './rtdb-rest.js';
|
|
32
|
+
export { initRTDBAuth, rtdbWrite, rtdbRead, patchAgentSessionSnapshot, patchRuntimeInfo, readRuntimeActivity, writeRuntimeActivity, removeRuntimeActivityItem, clearRuntimeActivity, writeRuntimeInfo, clearRuntimeInfo, writeSessionState, clearSessionState, writeTurnState, clearTurnState, } from './rtdb-rest.js';
|
|
33
33
|
// Runtime host plumbing
|
|
34
34
|
export { buildCanonHostPrompt, buildHydratedInboundContext, createConversationMetadataLoader, loadHostSessionConfig, publishHostAgentRuntime, publishHostSessionSnapshots, readHostSessionConfig, renderCanonHostInboundContent, resolveHostWorkspaceCwd, } from './host-runtime.js';
|
|
35
35
|
export { buildCanonGroupContext, buildCanonKnownRecentParticipants, buildCompactGroupContextLines, diffCanonMemberIds, } from './group-context.js';
|
package/dist/rtdb-rest.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { CanonClient } from './client.js';
|
|
9
9
|
import type { DeliveryIntent, RuntimeCapabilities, TurnLifecycleState } from './turn-protocol.js';
|
|
10
|
-
import type { CanonControlValue, ModelOption, RuntimeControlError, RuntimeControlState, RuntimeInfoPayload } from './types.js';
|
|
10
|
+
import type { CanonControlValue, CanonRuntimeActivityItem, ModelOption, RuntimeControlError, RuntimeControlState, RuntimeInfoPayload } from './types.js';
|
|
11
11
|
export interface SessionStatePayload {
|
|
12
12
|
lastError?: string;
|
|
13
13
|
model?: string;
|
|
@@ -101,6 +101,11 @@ export interface RuntimeInfoPayloadData extends Omit<RuntimeInfoPayload, 'update
|
|
|
101
101
|
'.sv': 'timestamp';
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
+
export interface RuntimeActivityPayloadData extends Omit<CanonRuntimeActivityItem, 'updatedAt'> {
|
|
105
|
+
updatedAt: number | {
|
|
106
|
+
'.sv': 'timestamp';
|
|
107
|
+
};
|
|
108
|
+
}
|
|
104
109
|
interface RTDBAuthOptions {
|
|
105
110
|
rtdbUrl?: string;
|
|
106
111
|
firebaseApiKey?: string;
|
|
@@ -118,6 +123,10 @@ export interface RTDBClientHandle {
|
|
|
118
123
|
writeRuntimeInfo(conversationId: string, agentId: string, payload: Omit<RuntimeInfoPayload, 'updatedAt'>): Promise<void>;
|
|
119
124
|
patchRuntimeInfo(conversationId: string, agentId: string, payload: Partial<Omit<RuntimeInfoPayload, 'updatedAt'>>): Promise<void>;
|
|
120
125
|
clearRuntimeInfo(conversationId: string, agentId: string): Promise<void>;
|
|
126
|
+
readRuntimeActivity(conversationId: string, agentId: string): Promise<Record<string, CanonRuntimeActivityItem>>;
|
|
127
|
+
writeRuntimeActivity(conversationId: string, agentId: string, item: CanonRuntimeActivityItem): Promise<void>;
|
|
128
|
+
removeRuntimeActivityItem(conversationId: string, agentId: string, itemId: string): Promise<void>;
|
|
129
|
+
clearRuntimeActivity(conversationId: string, agentId: string): Promise<void>;
|
|
121
130
|
}
|
|
122
131
|
/**
|
|
123
132
|
* Initializes the default RTDB helper and returns a scoped client for callers
|
|
@@ -143,4 +152,8 @@ export declare function patchAgentSessionSnapshot(conversationId: string, agentI
|
|
|
143
152
|
export declare function writeRuntimeInfo(conversationId: string, agentId: string, payload: Omit<RuntimeInfoPayload, 'updatedAt'>): Promise<void>;
|
|
144
153
|
export declare function patchRuntimeInfo(conversationId: string, agentId: string, payload: Partial<Omit<RuntimeInfoPayload, 'updatedAt'>>): Promise<void>;
|
|
145
154
|
export declare function clearRuntimeInfo(conversationId: string, agentId: string): Promise<void>;
|
|
155
|
+
export declare function readRuntimeActivity(conversationId: string, agentId: string): Promise<Record<string, CanonRuntimeActivityItem>>;
|
|
156
|
+
export declare function writeRuntimeActivity(conversationId: string, agentId: string, item: CanonRuntimeActivityItem): Promise<void>;
|
|
157
|
+
export declare function removeRuntimeActivityItem(conversationId: string, agentId: string, itemId: string): Promise<void>;
|
|
158
|
+
export declare function clearRuntimeActivity(conversationId: string, agentId: string): Promise<void>;
|
|
146
159
|
export {};
|
package/dist/rtdb-rest.js
CHANGED
|
@@ -21,6 +21,16 @@ function buildAgentSessionPath(conversationId, agentId) {
|
|
|
21
21
|
function buildRuntimeInfoPath(conversationId, agentId) {
|
|
22
22
|
return `/runtime-info/${conversationId}/${agentId}`;
|
|
23
23
|
}
|
|
24
|
+
function buildRuntimeActivityPath(conversationId, agentId) {
|
|
25
|
+
return `/runtime-activity/${conversationId}/${agentId}`;
|
|
26
|
+
}
|
|
27
|
+
function runtimeActivityItemKey(itemId) {
|
|
28
|
+
const normalized = itemId.trim().replace(/[.#$\[\]\/]/g, '_');
|
|
29
|
+
return normalized || 'item';
|
|
30
|
+
}
|
|
31
|
+
function buildRuntimeActivityItemPath(conversationId, agentId, itemId) {
|
|
32
|
+
return `${buildRuntimeActivityPath(conversationId, agentId)}/${runtimeActivityItemKey(itemId)}`;
|
|
33
|
+
}
|
|
24
34
|
function createRTDBClientHandle(client, options) {
|
|
25
35
|
const rtdbBase = normalizeRTDBBase(options?.rtdbUrl || DEFAULT_RTDB_BASE);
|
|
26
36
|
const firebaseApiKey = options?.firebaseApiKey || DEFAULT_FIREBASE_API_KEY;
|
|
@@ -247,6 +257,25 @@ function createRTDBClientHandle(client, options) {
|
|
|
247
257
|
async function clearRuntimeInfoImpl(conversationId, agentId) {
|
|
248
258
|
await remove(buildRuntimeInfoPath(conversationId, agentId));
|
|
249
259
|
}
|
|
260
|
+
async function readRuntimeActivityImpl(conversationId, agentId) {
|
|
261
|
+
const raw = await read(buildRuntimeActivityPath(conversationId, agentId));
|
|
262
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
263
|
+
return {};
|
|
264
|
+
}
|
|
265
|
+
return raw;
|
|
266
|
+
}
|
|
267
|
+
async function writeRuntimeActivityImpl(conversationId, agentId, item) {
|
|
268
|
+
await write(buildRuntimeActivityItemPath(conversationId, agentId, item.id), {
|
|
269
|
+
...item,
|
|
270
|
+
updatedAt: item.updatedAt || { '.sv': 'timestamp' },
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
async function removeRuntimeActivityItemImpl(conversationId, agentId, itemId) {
|
|
274
|
+
await remove(buildRuntimeActivityItemPath(conversationId, agentId, itemId));
|
|
275
|
+
}
|
|
276
|
+
async function clearRuntimeActivityImpl(conversationId, agentId) {
|
|
277
|
+
await remove(buildRuntimeActivityPath(conversationId, agentId));
|
|
278
|
+
}
|
|
250
279
|
return {
|
|
251
280
|
read,
|
|
252
281
|
write,
|
|
@@ -260,6 +289,10 @@ function createRTDBClientHandle(client, options) {
|
|
|
260
289
|
writeRuntimeInfo: writeRuntimeInfoImpl,
|
|
261
290
|
patchRuntimeInfo: patchRuntimeInfoImpl,
|
|
262
291
|
clearRuntimeInfo: clearRuntimeInfoImpl,
|
|
292
|
+
readRuntimeActivity: readRuntimeActivityImpl,
|
|
293
|
+
writeRuntimeActivity: writeRuntimeActivityImpl,
|
|
294
|
+
removeRuntimeActivityItem: removeRuntimeActivityItemImpl,
|
|
295
|
+
clearRuntimeActivity: clearRuntimeActivityImpl,
|
|
263
296
|
};
|
|
264
297
|
}
|
|
265
298
|
/**
|
|
@@ -314,3 +347,15 @@ export async function patchRuntimeInfo(conversationId, agentId, payload) {
|
|
|
314
347
|
export async function clearRuntimeInfo(conversationId, agentId) {
|
|
315
348
|
await getDefaultRTDBClient()?.clearRuntimeInfo(conversationId, agentId);
|
|
316
349
|
}
|
|
350
|
+
export async function readRuntimeActivity(conversationId, agentId) {
|
|
351
|
+
return getDefaultRTDBClient()?.readRuntimeActivity(conversationId, agentId) ?? {};
|
|
352
|
+
}
|
|
353
|
+
export async function writeRuntimeActivity(conversationId, agentId, item) {
|
|
354
|
+
await getDefaultRTDBClient()?.writeRuntimeActivity(conversationId, agentId, item);
|
|
355
|
+
}
|
|
356
|
+
export async function removeRuntimeActivityItem(conversationId, agentId, itemId) {
|
|
357
|
+
await getDefaultRTDBClient()?.removeRuntimeActivityItem(conversationId, agentId, itemId);
|
|
358
|
+
}
|
|
359
|
+
export async function clearRuntimeActivity(conversationId, agentId) {
|
|
360
|
+
await getDefaultRTDBClient()?.clearRuntimeActivity(conversationId, agentId);
|
|
361
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExecutionEnvironmentMode } from './execution-environment-mode.js';
|
|
2
|
-
import { type AgentClientType, type CanonControlDescriptor, type CanonRuntimeActionDescriptor, type CanonRuntimeDescriptor, type CanonRuntimeStreamingMode, type CanonWorkspaceRootMetadata, type ModelOption, type PermissionModeOption, type WorkspaceOption } from './types.js';
|
|
2
|
+
import { type AgentClientType, type CanonControlDescriptor, type CanonRuntimeActionDescriptor, type CanonRuntimeCommandDescriptor, type CanonRuntimeDescriptor, type CanonRuntimeStreamingMode, type CanonWorkspaceRootMetadata, type ModelOption, type PermissionModeOption, type WorkspaceOption } from './types.js';
|
|
3
3
|
import type { HostAdmissionActionCapabilities } from './turn-protocol.js';
|
|
4
4
|
export declare const CLAUDE_EFFORT_OPTIONS: readonly [{
|
|
5
5
|
readonly value: "low";
|
|
@@ -48,6 +48,7 @@ export declare function buildFirstPartyCodingRuntimeDescriptor(input: {
|
|
|
48
48
|
permissionModes?: ReadonlyArray<PermissionModeOption>;
|
|
49
49
|
defaultPermissionMode?: string | null;
|
|
50
50
|
actions?: ReadonlyArray<CanonRuntimeActionDescriptor>;
|
|
51
|
+
commands?: ReadonlyArray<CanonRuntimeCommandDescriptor>;
|
|
51
52
|
streamingTextMode: CanonRuntimeStreamingMode;
|
|
52
53
|
admissionActions?: HostAdmissionActionCapabilities;
|
|
53
54
|
}): CanonRuntimeDescriptor;
|
|
@@ -149,6 +149,7 @@ export function buildFirstPartyCodingRuntimeDescriptor(input) {
|
|
|
149
149
|
: []),
|
|
150
150
|
...(input.clientType === 'claude-code' ? [buildRuntimeEffortControl()] : []),
|
|
151
151
|
],
|
|
152
|
+
commands: input.commands,
|
|
152
153
|
actions: input.actions,
|
|
153
154
|
workspaceRoots: input.workspaceRoots,
|
|
154
155
|
supportsInterrupt: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentClientType, AgentRuntime, RuntimeInfoPayload } from './types.js';
|
|
1
|
+
import type { AgentClientType, AgentRuntime, CanonRuntimeActivityItem, RuntimeInfoPayload } from './types.js';
|
|
2
2
|
import { type AgentSessionSnapshotPatch, type RTDBClientHandle, type SessionStatePayload, type TurnStatePayload } from './rtdb-rest.js';
|
|
3
3
|
export interface RuntimeStatePublisherOptions {
|
|
4
4
|
agentId: string;
|
|
@@ -14,6 +14,12 @@ export interface RuntimeStreamingPayload {
|
|
|
14
14
|
'.sv': 'timestamp';
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
+
export interface ClearRuntimeActivityOptions {
|
|
18
|
+
itemIds?: ReadonlyArray<string>;
|
|
19
|
+
terminalOnly?: boolean;
|
|
20
|
+
olderThanMs?: number;
|
|
21
|
+
all?: boolean;
|
|
22
|
+
}
|
|
17
23
|
export interface RuntimeStatePublisher {
|
|
18
24
|
publishAgentRuntime(runtime: AgentRuntime): Promise<void>;
|
|
19
25
|
clearAgentRuntime(): Promise<void>;
|
|
@@ -25,6 +31,8 @@ export interface RuntimeStatePublisher {
|
|
|
25
31
|
writeRuntimeInfo(conversationId: string, payload: Omit<RuntimeInfoPayload, 'updatedAt'>): Promise<void>;
|
|
26
32
|
patchRuntimeInfo(conversationId: string, payload: Partial<Omit<RuntimeInfoPayload, 'updatedAt'>>): Promise<void>;
|
|
27
33
|
clearRuntimeInfo(conversationId: string): Promise<void>;
|
|
34
|
+
writeRuntimeActivity(conversationId: string, item: CanonRuntimeActivityItem): Promise<void>;
|
|
35
|
+
clearRuntimeActivity(conversationId: string, options?: ClearRuntimeActivityOptions): Promise<void>;
|
|
28
36
|
writeStreaming(conversationId: string, payload: RuntimeStreamingPayload): Promise<void>;
|
|
29
37
|
clearStreaming(conversationId: string): Promise<void>;
|
|
30
38
|
}
|
|
@@ -1,8 +1,39 @@
|
|
|
1
|
-
import { clearRuntimeInfo, clearSessionState, clearTurnState, patchAgentSessionSnapshot, patchRuntimeInfo, rtdbWrite, writeRuntimeInfo, writeSessionState, writeTurnState, } from './rtdb-rest.js';
|
|
1
|
+
import { clearRuntimeInfo, clearRuntimeActivity, clearSessionState, clearTurnState, patchAgentSessionSnapshot, patchRuntimeInfo, readRuntimeActivity, removeRuntimeActivityItem, rtdbWrite, writeRuntimeActivity, writeRuntimeInfo, writeSessionState, writeTurnState, } from './rtdb-rest.js';
|
|
2
2
|
const SERVER_TIMESTAMP = { '.sv': 'timestamp' };
|
|
3
|
+
const MAX_RUNTIME_ACTIVITY_ITEMS = 50;
|
|
4
|
+
const TERMINAL_RUNTIME_ACTIVITY_CLEAR_MS = 60_000;
|
|
5
|
+
const TERMINAL_RUNTIME_ACTIVITY_STATUSES = new Set(['completed', 'failed', 'blocked']);
|
|
6
|
+
function isTerminalRuntimeActivity(item) {
|
|
7
|
+
return TERMINAL_RUNTIME_ACTIVITY_STATUSES.has(item.status);
|
|
8
|
+
}
|
|
3
9
|
export function createRuntimeStatePublisher(options) {
|
|
4
10
|
const { agentId, clientType, hostMode, rtdb } = options;
|
|
5
11
|
const writePath = (path, data) => (rtdb ? rtdb.write(path, data) : rtdbWrite(path, data));
|
|
12
|
+
const readRuntimeActivityPath = (conversationId) => (rtdb
|
|
13
|
+
? rtdb.readRuntimeActivity(conversationId, agentId)
|
|
14
|
+
: readRuntimeActivity(conversationId, agentId));
|
|
15
|
+
const removeRuntimeActivityPath = (conversationId, itemId) => (rtdb
|
|
16
|
+
? rtdb.removeRuntimeActivityItem(conversationId, agentId, itemId)
|
|
17
|
+
: removeRuntimeActivityItem(conversationId, agentId, itemId));
|
|
18
|
+
const clearRuntimeActivityPath = (conversationId) => (rtdb
|
|
19
|
+
? rtdb.clearRuntimeActivity(conversationId, agentId)
|
|
20
|
+
: clearRuntimeActivity(conversationId, agentId));
|
|
21
|
+
async function pruneRuntimeActivity(conversationId) {
|
|
22
|
+
const itemsById = await readRuntimeActivityPath(conversationId).catch(() => ({}));
|
|
23
|
+
const items = Object.values(itemsById)
|
|
24
|
+
.filter((item) => Boolean(item?.id))
|
|
25
|
+
.sort((a, b) => (b.updatedAt ?? 0) - (a.updatedAt ?? 0));
|
|
26
|
+
const excess = items.slice(MAX_RUNTIME_ACTIVITY_ITEMS);
|
|
27
|
+
await Promise.all(excess.map((item) => removeRuntimeActivityPath(conversationId, item.id).catch(() => { })));
|
|
28
|
+
}
|
|
29
|
+
function scheduleTerminalRuntimeActivityClear(conversationId, item) {
|
|
30
|
+
if (!isTerminalRuntimeActivity(item))
|
|
31
|
+
return;
|
|
32
|
+
const timer = setTimeout(() => {
|
|
33
|
+
void removeRuntimeActivityPath(conversationId, item.id).catch(() => { });
|
|
34
|
+
}, TERMINAL_RUNTIME_ACTIVITY_CLEAR_MS);
|
|
35
|
+
timer.unref?.();
|
|
36
|
+
}
|
|
6
37
|
return {
|
|
7
38
|
async publishAgentRuntime(runtime) {
|
|
8
39
|
await writePath(`/agent-runtime/${agentId}`, {
|
|
@@ -55,6 +86,37 @@ export function createRuntimeStatePublisher(options) {
|
|
|
55
86
|
? rtdb.clearRuntimeInfo(conversationId, agentId)
|
|
56
87
|
: clearRuntimeInfo(conversationId, agentId));
|
|
57
88
|
},
|
|
89
|
+
async writeRuntimeActivity(conversationId, item) {
|
|
90
|
+
const normalized = {
|
|
91
|
+
...item,
|
|
92
|
+
updatedAt: item.updatedAt || Date.now(),
|
|
93
|
+
};
|
|
94
|
+
await (rtdb
|
|
95
|
+
? rtdb.writeRuntimeActivity(conversationId, agentId, normalized)
|
|
96
|
+
: writeRuntimeActivity(conversationId, agentId, normalized));
|
|
97
|
+
void pruneRuntimeActivity(conversationId).catch(() => { });
|
|
98
|
+
scheduleTerminalRuntimeActivityClear(conversationId, normalized);
|
|
99
|
+
},
|
|
100
|
+
async clearRuntimeActivity(conversationId, options = {}) {
|
|
101
|
+
if (options.all) {
|
|
102
|
+
await clearRuntimeActivityPath(conversationId);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (options.itemIds?.length) {
|
|
106
|
+
await Promise.all(options.itemIds.map((itemId) => removeRuntimeActivityPath(conversationId, itemId)));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const olderThanMs = options.olderThanMs ?? 0;
|
|
110
|
+
const cutoff = olderThanMs > 0 ? Date.now() - olderThanMs : Number.POSITIVE_INFINITY;
|
|
111
|
+
const terminalOnly = options.terminalOnly ?? true;
|
|
112
|
+
const itemsById = await readRuntimeActivityPath(conversationId).catch(() => ({}));
|
|
113
|
+
const removals = Object.values(itemsById)
|
|
114
|
+
.filter((item) => Boolean(item?.id))
|
|
115
|
+
.filter((item) => (!terminalOnly || isTerminalRuntimeActivity(item)))
|
|
116
|
+
.filter((item) => olderThanMs <= 0 || (item.updatedAt ?? 0) <= cutoff)
|
|
117
|
+
.map((item) => removeRuntimeActivityPath(conversationId, item.id));
|
|
118
|
+
await Promise.all(removals);
|
|
119
|
+
},
|
|
58
120
|
async writeStreaming(conversationId, payload) {
|
|
59
121
|
await writePath(`/streaming/${conversationId}/${agentId}`, {
|
|
60
122
|
...payload,
|
package/dist/types.d.ts
CHANGED
|
@@ -226,18 +226,40 @@ export type CanonControlSelectionPolicy = 'inherit' | 'required_explicit';
|
|
|
226
226
|
export type CanonRuntimeStreamingMode = 'none' | 'status' | 'snapshot' | 'block' | 'delta';
|
|
227
227
|
export type CanonRuntimeSurfaceMode = 'host' | 'channel' | 'limited_channel' | 'operator';
|
|
228
228
|
export type CanonRuntimeDetailTier = 'primary' | 'detail' | 'diagnostic';
|
|
229
|
+
export type CanonRuntimeFactGroup = 'connection' | 'route' | 'runtime' | 'model' | 'session' | 'account' | 'limits';
|
|
229
230
|
export type CanonRuntimeInventoryStatus = 'ready' | 'auth_needed' | 'unknown' | 'configured' | 'running' | 'error';
|
|
230
231
|
export type CanonRuntimeStatusTone = 'default' | 'success' | 'warning' | 'danger';
|
|
231
232
|
export type CanonRuntimeActionAvailability = 'idle' | 'busy' | 'busy_with_queue' | 'waiting_input' | 'always';
|
|
232
233
|
export type CanonRuntimeActionPlacement = 'composer_slash' | 'command_palette' | 'session_strip';
|
|
233
|
-
export type CanonRuntimeActionCategory = 'plan' | 'turn' | 'session' | 'details' | 'custom';
|
|
234
|
+
export type CanonRuntimeActionCategory = 'plan' | 'turn' | 'session' | 'runtime' | 'details' | 'custom';
|
|
235
|
+
export type CanonRuntimePrimitiveId = 'runtime.status' | 'runtime.reasoning.set' | 'runtime.verbosity.set' | 'runtime.usage' | 'context.compact' | 'session.new' | 'session.reset';
|
|
236
|
+
export type CanonRuntimeCommandArgumentKind = 'string' | 'enum' | 'boolean';
|
|
237
|
+
export interface CanonRuntimeCommandArgumentChoice {
|
|
238
|
+
value: string;
|
|
239
|
+
label: string;
|
|
240
|
+
description?: string;
|
|
241
|
+
}
|
|
242
|
+
export interface CanonRuntimeCommandArgumentDescriptor {
|
|
243
|
+
id: string;
|
|
244
|
+
label: string;
|
|
245
|
+
kind: CanonRuntimeCommandArgumentKind;
|
|
246
|
+
required?: boolean;
|
|
247
|
+
captureRemaining?: boolean;
|
|
248
|
+
choices?: ReadonlyArray<CanonRuntimeCommandArgumentChoice>;
|
|
249
|
+
}
|
|
234
250
|
export type CanonRuntimeActionDispatch = {
|
|
235
251
|
kind: 'control';
|
|
236
252
|
controlId: string;
|
|
237
|
-
value
|
|
253
|
+
value?: CanonControlValue;
|
|
238
254
|
} | {
|
|
239
255
|
kind: 'signal';
|
|
240
256
|
signal: 'interrupt' | 'stop_and_drop' | 'new_session';
|
|
257
|
+
} | {
|
|
258
|
+
kind: 'primitive';
|
|
259
|
+
primitive: CanonRuntimePrimitiveId;
|
|
260
|
+
} | {
|
|
261
|
+
kind: 'text_passthrough';
|
|
262
|
+
template: string;
|
|
241
263
|
} | {
|
|
242
264
|
kind: 'compose';
|
|
243
265
|
text: string;
|
|
@@ -249,6 +271,7 @@ export interface CanonRuntimeActionDescriptor {
|
|
|
249
271
|
id: string;
|
|
250
272
|
label: string;
|
|
251
273
|
description?: string;
|
|
274
|
+
primitive?: CanonRuntimePrimitiveId;
|
|
252
275
|
aliases?: ReadonlyArray<string>;
|
|
253
276
|
category?: CanonRuntimeActionCategory;
|
|
254
277
|
placements?: ReadonlyArray<CanonRuntimeActionPlacement>;
|
|
@@ -256,8 +279,13 @@ export interface CanonRuntimeActionDescriptor {
|
|
|
256
279
|
ownerOnly?: boolean;
|
|
257
280
|
disabledReason?: string | null;
|
|
258
281
|
trailingTextBehavior?: 'ignore' | 'send_as_prompt';
|
|
282
|
+
args?: ReadonlyArray<CanonRuntimeCommandArgumentDescriptor>;
|
|
259
283
|
dispatch: CanonRuntimeActionDispatch;
|
|
260
284
|
}
|
|
285
|
+
export interface CanonRuntimeCommandDescriptor extends CanonRuntimeActionDescriptor {
|
|
286
|
+
primitive?: CanonRuntimePrimitiveId;
|
|
287
|
+
args?: ReadonlyArray<CanonRuntimeCommandArgumentDescriptor>;
|
|
288
|
+
}
|
|
261
289
|
export interface CanonControlDescriptor {
|
|
262
290
|
id: string;
|
|
263
291
|
label: string;
|
|
@@ -271,6 +299,7 @@ export interface CanonControlDescriptor {
|
|
|
271
299
|
export interface CanonRuntimeDescriptor {
|
|
272
300
|
coreControls: ReadonlyArray<CanonControlDescriptor>;
|
|
273
301
|
runtimeControls?: ReadonlyArray<CanonControlDescriptor>;
|
|
302
|
+
commands?: ReadonlyArray<CanonRuntimeCommandDescriptor>;
|
|
274
303
|
actions?: ReadonlyArray<CanonRuntimeActionDescriptor>;
|
|
275
304
|
/**
|
|
276
305
|
* Optional setup-time local roots advertised by a runtime. These are
|
|
@@ -315,6 +344,32 @@ export interface CanonRuntimeStatusItem {
|
|
|
315
344
|
sensitive?: boolean;
|
|
316
345
|
source?: RuntimeControlValueSource;
|
|
317
346
|
}
|
|
347
|
+
export interface CanonRuntimeFact {
|
|
348
|
+
id: string;
|
|
349
|
+
label: string;
|
|
350
|
+
value: string;
|
|
351
|
+
group: CanonRuntimeFactGroup;
|
|
352
|
+
tier?: CanonRuntimeDetailTier;
|
|
353
|
+
tone?: 'neutral' | 'good' | 'warning' | 'danger';
|
|
354
|
+
copyable?: boolean;
|
|
355
|
+
updatedAt?: number;
|
|
356
|
+
}
|
|
357
|
+
export type CanonRuntimeActivityKind = 'run' | 'tool' | 'command_output' | 'plan' | 'approval' | 'artifact' | 'compaction' | 'status';
|
|
358
|
+
export type CanonRuntimeActivityStatus = 'running' | 'completed' | 'failed' | 'blocked' | 'pending';
|
|
359
|
+
export interface CanonRuntimeActivityItem {
|
|
360
|
+
id: string;
|
|
361
|
+
runId?: string;
|
|
362
|
+
kind: CanonRuntimeActivityKind;
|
|
363
|
+
title: string;
|
|
364
|
+
status: CanonRuntimeActivityStatus;
|
|
365
|
+
summary?: string;
|
|
366
|
+
detail?: string;
|
|
367
|
+
progressText?: string;
|
|
368
|
+
startedAt?: number;
|
|
369
|
+
updatedAt: number;
|
|
370
|
+
endedAt?: number;
|
|
371
|
+
actions?: ReadonlyArray<CanonRuntimeCommandDescriptor>;
|
|
372
|
+
}
|
|
318
373
|
export interface CanonRuntimeInventoryEntry {
|
|
319
374
|
id: string;
|
|
320
375
|
label: string;
|
|
@@ -331,6 +386,7 @@ export interface RuntimeInfoPayload {
|
|
|
331
386
|
descriptor: CanonRuntimeDescriptor;
|
|
332
387
|
surfaceMode?: CanonRuntimeSurfaceMode;
|
|
333
388
|
surfaceLabel?: string;
|
|
389
|
+
facts?: ReadonlyArray<CanonRuntimeFact>;
|
|
334
390
|
statusItems?: ReadonlyArray<CanonRuntimeStatusItem>;
|
|
335
391
|
inventories?: ReadonlyArray<CanonRuntimeInventory>;
|
|
336
392
|
execution?: CanonRuntimeExecutionMetadata | null;
|
|
@@ -618,6 +674,7 @@ export interface AgentSessionSnapshot {
|
|
|
618
674
|
runtimeControlErrors?: Record<string, RuntimeControlError> | null;
|
|
619
675
|
runtimeDescriptor?: CanonRuntimeDescriptor | null;
|
|
620
676
|
runtimeInfo?: RuntimeInfoPayload | null;
|
|
677
|
+
runtimeActivity?: Record<string, CanonRuntimeActivityItem> | ReadonlyArray<CanonRuntimeActivityItem> | null;
|
|
621
678
|
workspaceId?: string;
|
|
622
679
|
workspaceOptions?: WorkspaceOption[];
|
|
623
680
|
executionMode?: ExecutionEnvironmentMode;
|