@qlairoslabs/acp-client 0.10.1 → 0.11.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/CONSUMER_GUIDE.md +252 -0
- package/README.md +0 -3
- package/package.json +1 -1
- package/src/agent/adoption/config.ts +57 -0
- package/src/agent/adoption/index.ts +8 -0
- package/src/agent/adoption/provider-session-delete.ts +27 -0
- package/src/agent/adoption/provider-sessions.ts +73 -0
- package/src/agent/adoption/recap.ts +15 -0
- package/src/agent/adoption/replay.ts +84 -0
- package/src/agent/config.ts +182 -0
- package/src/agent/conversation-manager.ts +1006 -0
- package/src/agent/manager-settings.ts +46 -0
- package/src/agent/persisted-lifecycle.ts +309 -0
- package/src/agent/persistence-policy/index.ts +8 -0
- package/src/agent/persistence-policy/resolver.ts +118 -0
- package/src/agent/persistence-policy/types.ts +50 -0
- package/src/agent/record-capture.ts +243 -0
- package/src/agent-conversation-contracts.ts +11 -0
- package/src/agent-conversation-errors.ts +24 -0
- package/src/agent-conversation-owner.ts +7 -0
- package/src/agent-conversation-queue.ts +23 -0
- package/src/agent-session.ts +236 -66
- package/src/agent.ts +63 -1223
- package/src/audit/config.ts +29 -0
- package/src/audit/index.ts +1 -0
- package/src/checkpointing/contracts.ts +2 -0
- package/src/checkpointing/persistence/sqlite-repository.ts +13 -0
- package/src/checkpointing/strategy.ts +11 -5
- package/src/client.ts +25 -2
- package/src/controller.ts +3 -0
- package/src/index.ts +24 -0
- package/src/internal-inference/contracts.ts +23 -0
- package/src/internal-inference/coordination/manager.ts +22 -8
- package/src/persistence/backend.ts +17 -0
- package/src/persistence/sqlite-backend.ts +30 -4
- package/src/persistence/sqlite-provider-sessions.ts +35 -0
- package/src/persistence/sqlite-schema.ts +13 -3
- package/src/steering/combine.ts +56 -0
- package/src/steering/contracts.ts +84 -0
- package/src/steering/controller.ts +205 -0
- package/src/steering/index.ts +14 -0
- package/src/transport/acp-transport.ts +11 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type * as schema from "@agentclientprotocol/sdk";
|
|
2
|
+
import type { AgentConversationId, AgentSessionId } from "../agent-ids.ts";
|
|
3
|
+
import type { AgentAdapterRegistration } from "../agent-adapter-registry.ts";
|
|
4
|
+
import type { AgentConversation, AgentConversationConfig } from "../agent-session.ts";
|
|
5
|
+
import type { AgentMode } from "../controller.ts";
|
|
6
|
+
import type { AgentIdentityRuntime, IdentityConsistency } from "../identity.ts";
|
|
7
|
+
import type { CheckpointBackedIdentityConfig } from "../identity/checkpoint-backed.ts";
|
|
8
|
+
import type {
|
|
9
|
+
AgentConversationSummary,
|
|
10
|
+
ConversationListOptions,
|
|
11
|
+
ConversationPage,
|
|
12
|
+
ConversationPreviewPage,
|
|
13
|
+
ConversationRecordCaptureConfig,
|
|
14
|
+
MessageRecord,
|
|
15
|
+
MeteringRecordRetention,
|
|
16
|
+
ParticipantRef,
|
|
17
|
+
PersistenceBackend,
|
|
18
|
+
PersistenceExtension,
|
|
19
|
+
} from "../persistence/backend.ts";
|
|
20
|
+
import type { AgentAuditLogConfig } from "../audit/index.ts";
|
|
21
|
+
import type { InternalInferenceConfig } from "../internal-inference/config.ts";
|
|
22
|
+
import type { InternalInferenceStrategy } from "../internal-inference/contracts.ts";
|
|
23
|
+
import type {
|
|
24
|
+
ConversationCheckpointingConfig,
|
|
25
|
+
ConversationRecoveryProgress,
|
|
26
|
+
ConversationRecoveryResult,
|
|
27
|
+
} from "../checkpointing/index.ts";
|
|
28
|
+
import type { AppendAssistantMessageInput } from "../out-of-band-messages.ts";
|
|
29
|
+
import type { ConversationPersistenceResolver } from "./persistence-policy/index.ts";
|
|
30
|
+
import type { AdoptProviderSessionConfig, ListProviderSessionsOptions, ProviderSessionSummary } from "./adoption/index.ts";
|
|
31
|
+
|
|
32
|
+
export type AgentPersistenceConfig =
|
|
33
|
+
| {
|
|
34
|
+
readonly kind: "sqlite";
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly metadata?: string;
|
|
37
|
+
readonly busyTimeoutMs?: number;
|
|
38
|
+
readonly extensions?: readonly PersistenceExtension[];
|
|
39
|
+
readonly allowUnsafeWalVersion?: boolean;
|
|
40
|
+
}
|
|
41
|
+
| { readonly kind: "custom"; readonly backend: PersistenceBackend };
|
|
42
|
+
|
|
43
|
+
type OwnerControlledConversationKey =
|
|
44
|
+
| "adapter"
|
|
45
|
+
| "adapterId"
|
|
46
|
+
| "agentSessionId"
|
|
47
|
+
| "agentConversationId"
|
|
48
|
+
| "ownerAgentSessionId"
|
|
49
|
+
| "participants"
|
|
50
|
+
| "ownerLifecycle"
|
|
51
|
+
| "providerSession"
|
|
52
|
+
| "persistence"
|
|
53
|
+
| "transcriptPath"
|
|
54
|
+
| "transcriptDir"
|
|
55
|
+
| "sessions";
|
|
56
|
+
|
|
57
|
+
export type AgentConversationRuntimeDefaults = Omit<
|
|
58
|
+
AgentConversationConfig,
|
|
59
|
+
OwnerControlledConversationKey
|
|
60
|
+
>;
|
|
61
|
+
|
|
62
|
+
export interface AgentConfig {
|
|
63
|
+
readonly id?: AgentSessionId;
|
|
64
|
+
readonly persistence: AgentPersistenceConfig;
|
|
65
|
+
readonly adapters: Readonly<Record<string, import("../adapters.ts").Adapter>>
|
|
66
|
+
| readonly AgentAdapterRegistration[];
|
|
67
|
+
readonly defaultAdapterId?: string;
|
|
68
|
+
readonly identity?: AgentIdentityRuntime | CheckpointBackedIdentityConfig;
|
|
69
|
+
readonly identityConsistency?: IdentityConsistency;
|
|
70
|
+
readonly identityTimeoutMs?: number;
|
|
71
|
+
readonly capture?: ConversationRecordCaptureConfig;
|
|
72
|
+
readonly conversationDefaults?: AgentConversationRuntimeDefaults;
|
|
73
|
+
/** Bounded metering state is always persisted; this controls detailed local history. */
|
|
74
|
+
readonly meteringPersistence?: {
|
|
75
|
+
readonly meteringRecords?: MeteringRecordRetention;
|
|
76
|
+
};
|
|
77
|
+
readonly internalInference?: InternalInferenceConfig & {
|
|
78
|
+
readonly strategies?: readonly InternalInferenceStrategy[];
|
|
79
|
+
};
|
|
80
|
+
readonly checkpointing?: ConversationCheckpointingConfig;
|
|
81
|
+
readonly auditLog?: false | AgentAuditLogConfig;
|
|
82
|
+
/**
|
|
83
|
+
* Chooses, per conversation, what it persists differently from the Agent defaults. Synchronous,
|
|
84
|
+
* side-effect free and stable for a given conversation; see `ConversationPersistenceResolver`.
|
|
85
|
+
*/
|
|
86
|
+
readonly conversationPersistence?: ConversationPersistenceResolver;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface CreateAgentConversationConfig {
|
|
90
|
+
readonly id?: AgentConversationId;
|
|
91
|
+
readonly adapterId?: string;
|
|
92
|
+
readonly mode?: AgentMode;
|
|
93
|
+
readonly participants?: readonly ParticipantRef[];
|
|
94
|
+
readonly title?: string;
|
|
95
|
+
readonly metadata?: string;
|
|
96
|
+
readonly mcpServers?: schema.McpServer[];
|
|
97
|
+
readonly runtime?: AgentConversationRuntimeDefaults;
|
|
98
|
+
/**
|
|
99
|
+
* Create the conversation around an existing provider session and load it, instead of starting a new
|
|
100
|
+
* one. Requires message capture `content` or `raw` for this conversation.
|
|
101
|
+
*/
|
|
102
|
+
readonly adopt?: AdoptProviderSessionConfig;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface OpenAgentConversationConfig {
|
|
106
|
+
readonly adapterId?: string;
|
|
107
|
+
readonly mode?: AgentMode;
|
|
108
|
+
readonly mcpServers?: schema.McpServer[];
|
|
109
|
+
readonly runtime?: AgentConversationRuntimeDefaults;
|
|
110
|
+
readonly onRecoveryProgress?: (event: ConversationRecoveryProgress) => void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface DeleteConversationOptions {
|
|
114
|
+
/** When it was deleted. Default now. */
|
|
115
|
+
readonly deletedAt?: string;
|
|
116
|
+
/**
|
|
117
|
+
* `"best-effort"` also asks the provider to delete the conversation's active session (`session/delete`);
|
|
118
|
+
* `"no"` (the default) leaves it alone. Not every provider offers it; the result says what happened.
|
|
119
|
+
*/
|
|
120
|
+
readonly providerSession?: "best-effort" | "no";
|
|
121
|
+
/** Also delete the conversation's recovery checkpoints. */
|
|
122
|
+
readonly checkpoints?: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface DeleteConversationResult {
|
|
126
|
+
/** `true` if the provider deleted its session, `"unsupported"` if it cannot, `false` if not asked or it failed. */
|
|
127
|
+
readonly providerDeleted: boolean | "unsupported";
|
|
128
|
+
readonly checkpointsDeleted: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ClearTranscriptOptions {
|
|
132
|
+
/** Also delete the conversation's recovery checkpoints, which summarize the records being deleted. */
|
|
133
|
+
readonly checkpoints?: boolean;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface ClearTranscriptResult {
|
|
137
|
+
readonly recordsDeleted: number;
|
|
138
|
+
readonly checkpointsDeleted: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface OpenOwnedAgentConversationResult {
|
|
142
|
+
readonly conversation: AgentConversation;
|
|
143
|
+
readonly providerSession: "already_open" | "loaded" | "new" | "recovered";
|
|
144
|
+
readonly recovery?: ConversationRecoveryResult;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface AgentConversationManager {
|
|
148
|
+
create(config?: CreateAgentConversationConfig): Promise<AgentConversation>;
|
|
149
|
+
open(
|
|
150
|
+
id: AgentConversationId,
|
|
151
|
+
config?: OpenAgentConversationConfig,
|
|
152
|
+
): Promise<OpenOwnedAgentConversationResult>;
|
|
153
|
+
get(id: AgentConversationId): Promise<AgentConversationSummary | null>;
|
|
154
|
+
list(options?: ConversationListOptions): Promise<ConversationPage>;
|
|
155
|
+
/**
|
|
156
|
+
* The sessions the provider holds (`session/list`), for choosing one to adopt with `create({ adopt })`.
|
|
157
|
+
* Starts the harness for the call. Each session says which conversation already owns it, if any.
|
|
158
|
+
*/
|
|
159
|
+
listProviderSessions(options?: ListProviderSessionsOptions): Promise<readonly ProviderSessionSummary[]>;
|
|
160
|
+
listPreviews(options?: ConversationListOptions): Promise<ConversationPreviewPage>;
|
|
161
|
+
/**
|
|
162
|
+
* Delete a conversation (a soft delete: the records stay, and the conversation stops being listed and frees
|
|
163
|
+
* its provider session). A string is the deletion time, as before. Returns what else was done.
|
|
164
|
+
*/
|
|
165
|
+
delete(id: AgentConversationId, options?: string | DeleteConversationOptions): Promise<DeleteConversationResult>;
|
|
166
|
+
/**
|
|
167
|
+
* Physically delete the stored records of a conversation (messages, tool calls, and the rest), keeping the
|
|
168
|
+
* conversation, its participants and provider session. This is a local deletion, not forgetting: audit
|
|
169
|
+
* entries already written, checkpoint summaries delivered to other conversations, and the provider's own
|
|
170
|
+
* session are not touched.
|
|
171
|
+
*/
|
|
172
|
+
clearTranscript(id: AgentConversationId, options?: ClearTranscriptOptions): Promise<ClearTranscriptResult>;
|
|
173
|
+
/**
|
|
174
|
+
* Append a completed assistant message the provider did not produce, without a turn or a
|
|
175
|
+
* live provider session. It is published on `agent.events`, and the conversation's next
|
|
176
|
+
* turn shows it to the provider ahead of the user's text.
|
|
177
|
+
*/
|
|
178
|
+
appendAssistantMessage(
|
|
179
|
+
id: AgentConversationId,
|
|
180
|
+
input: AppendAssistantMessageInput,
|
|
181
|
+
): Promise<MessageRecord>;
|
|
182
|
+
}
|