@getpaseo/server 0.1.97-beta.3 → 0.1.98
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/server/server/agent/agent-manager.d.ts +11 -3
- package/dist/server/server/agent/agent-manager.js +95 -23
- package/dist/server/server/agent/agent-prompt.d.ts +1 -1
- package/dist/server/server/agent/agent-prompt.js +3 -10
- package/dist/server/server/agent/agent-response-loop.js +9 -3
- package/dist/server/server/agent/agent-sdk-types.d.ts +9 -3
- package/dist/server/server/agent/agent-storage.d.ts +20 -240
- package/dist/server/server/agent/agent-storage.js +6 -6
- package/dist/server/server/agent/create-agent/create.d.ts +2 -0
- package/dist/server/server/agent/create-agent/create.js +8 -7
- package/dist/server/server/agent/lifecycle-command.d.ts +15 -1
- package/dist/server/server/agent/lifecycle-command.js +9 -2
- package/dist/server/server/agent/mcp-server.js +263 -119
- package/dist/server/server/agent/mcp-shared.d.ts +35 -179
- package/dist/server/server/agent/provider-notices.d.ts +3 -0
- package/dist/server/server/agent/provider-notices.js +5 -0
- package/dist/server/server/agent/provider-registry.d.ts +2 -0
- package/dist/server/server/agent/provider-registry.js +10 -3
- package/dist/server/server/agent/provider-snapshot-manager.d.ts +3 -0
- package/dist/server/server/agent/provider-snapshot-manager.js +11 -2
- package/dist/server/server/agent/providers/claude/agent.js +257 -143
- package/dist/server/server/agent/providers/claude/models.js +7 -3
- package/dist/server/server/agent/providers/claude/project-dir.js +9 -6
- package/dist/server/server/agent/providers/claude/task-notification-tool-call.d.ts +2 -22
- package/dist/server/server/agent/providers/codex/app-server-transport.d.ts +8 -118
- package/dist/server/server/agent/providers/codex-app-server-agent.d.ts +4 -3
- package/dist/server/server/agent/providers/codex-app-server-agent.js +43 -1
- package/dist/server/server/agent/providers/copilot-acp-agent.js +4 -1
- package/dist/server/server/agent/providers/diagnostic-utils.d.ts +9 -0
- package/dist/server/server/agent/providers/diagnostic-utils.js +188 -0
- package/dist/server/server/agent/providers/generic-acp-agent.d.ts +1 -5
- package/dist/server/server/agent/providers/mock-slow-provider.js +1 -1
- package/dist/server/server/agent/providers/opencode/server-manager.d.ts +29 -2
- package/dist/server/server/agent/providers/opencode/server-manager.js +83 -17
- package/dist/server/server/agent/providers/opencode-agent.d.ts +2 -0
- package/dist/server/server/agent/providers/opencode-agent.js +14 -9
- package/dist/server/server/agent/providers/pi/agent.d.ts +1 -5
- package/dist/server/server/agent/providers/pi/agent.js +27 -14
- package/dist/server/server/agent/providers/tool-call-detail-primitives.d.ts +391 -1261
- package/dist/server/server/agent/providers/tool-call-detail-primitives.js +26 -16
- package/dist/server/server/bootstrap.d.ts +2 -0
- package/dist/server/server/bootstrap.js +32 -2
- package/dist/server/server/loop-service.d.ts +60 -359
- package/dist/server/server/managed-processes/managed-processes.d.ts +76 -0
- package/dist/server/server/managed-processes/managed-processes.js +326 -0
- package/dist/server/server/migrations/backfill-workspace-id.migration.js +10 -6
- package/dist/server/server/package-version.d.ts +1 -7
- package/dist/server/server/paseo-worktree-service.js +15 -1
- package/dist/server/server/persisted-config.d.ts +138 -1009
- package/dist/server/server/persisted-config.js +1 -1
- package/dist/server/server/pid-lock.d.ts +1 -15
- package/dist/server/server/resolve-worktree-creation-intent.d.ts +3 -0
- package/dist/server/server/resolve-worktree-creation-intent.js +3 -3
- package/dist/server/server/session.d.ts +18 -1
- package/dist/server/server/session.js +424 -64
- package/dist/server/server/speech/providers/local/sherpa/model-catalog.d.ts +2 -2
- package/dist/server/server/speech/providers/openai/runtime.js +3 -4
- package/dist/server/server/speech/speech-types.d.ts +9 -11
- package/dist/server/server/websocket-server.d.ts +1 -0
- package/dist/server/server/websocket-server.js +15 -0
- package/dist/server/server/workspace-archive-service.js +2 -3
- package/dist/server/server/workspace-directory.js +5 -5
- package/dist/server/server/workspace-reconciliation-service.js +2 -2
- package/dist/server/server/workspace-registry.d.ts +17 -48
- package/dist/server/server/workspace-registry.js +9 -0
- package/dist/server/server/worktree-core.d.ts +1 -0
- package/dist/server/server/worktree-core.js +5 -1
- package/dist/server/services/quota-fetcher/manifest.d.ts +4 -0
- package/dist/server/services/quota-fetcher/manifest.js +47 -0
- package/dist/server/services/quota-fetcher/provider.d.ts +17 -0
- package/dist/server/services/quota-fetcher/provider.js +2 -0
- package/dist/server/services/quota-fetcher/providers/claude.d.ts +26 -0
- package/dist/server/services/quota-fetcher/providers/claude.js +217 -0
- package/dist/server/services/quota-fetcher/providers/codex.d.ts +23 -0
- package/dist/server/services/quota-fetcher/providers/codex.js +211 -0
- package/dist/server/services/quota-fetcher/providers/copilot.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/copilot.js +75 -0
- package/dist/server/services/quota-fetcher/providers/cursor.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/cursor.js +123 -0
- package/dist/server/services/quota-fetcher/providers/grok.d.ts +18 -0
- package/dist/server/services/quota-fetcher/providers/grok.js +89 -0
- package/dist/server/services/quota-fetcher/providers/kimi.d.ts +20 -0
- package/dist/server/services/quota-fetcher/providers/kimi.js +89 -0
- package/dist/server/services/quota-fetcher/providers/zai.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/zai.js +58 -0
- package/dist/server/services/quota-fetcher/service.d.ts +28 -0
- package/dist/server/services/quota-fetcher/service.js +58 -0
- package/dist/server/services/quota-fetcher/usage.d.ts +22 -0
- package/dist/server/services/quota-fetcher/usage.js +49 -0
- package/dist/server/terminal/terminal-session-controller.d.ts +8 -0
- package/dist/server/terminal/terminal-session-controller.js +23 -3
- package/dist/server/utils/checkout-git.js +36 -76
- package/dist/server/utils/directory-suggestions.js +98 -2
- package/dist/server/utils/worktree-metadata.d.ts +7 -59
- package/dist/src/server/persisted-config.js +1 -1
- package/package.json +9 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AGENT_LIFECYCLE_STATUSES, type AgentLifecycleStatus } from "@getpaseo/protocol/agent-lifecycle";
|
|
2
2
|
import type { Logger } from "pino";
|
|
3
3
|
import type { TerminalManager } from "../../terminal/terminal-manager.js";
|
|
4
|
-
import { type AgentCapabilityFlags, type AgentClient, type AgentFeature, type AgentSlashCommand, type AgentMode, type AgentPermissionRequest, type AgentPermissionResponse, type AgentPermissionResult, type AgentPersistenceHandle, type AgentPromptInput, type AgentProvider, type AgentRunOptions, type AgentRunResult, type AgentSession, type AgentSessionConfig, type AgentStreamEvent, type AgentTimelineItem, type AgentUsage, type AgentRuntimeInfo, type ImportableProviderSession, type ListImportableSessionsOptions } from "./agent-sdk-types.js";
|
|
4
|
+
import { type AgentCapabilityFlags, type AgentClient, type AgentFeature, type AgentSlashCommand, type AgentMode, type AgentPermissionRequest, type AgentPermissionResponse, type AgentPermissionResult, type AgentPersistenceHandle, type AgentProviderNotice, type AgentPromptInput, type AgentProvider, type AgentRunOptions, type AgentRunResult, type AgentSession, type AgentSessionConfig, type AgentStreamEvent, type AgentTimelineItem, type AgentUsage, type AgentRuntimeInfo, type ImportableProviderSession, type ListImportableSessionsOptions } from "./agent-sdk-types.js";
|
|
5
5
|
import type { StoredAgentRecord, AgentStorage } from "./agent-storage.js";
|
|
6
6
|
import type { AgentTimelineFetchOptions, AgentTimelineFetchResult, AgentTimelineRow, AgentTimelineStore } from "./agent-timeline-store-types.js";
|
|
7
7
|
import { type ForegroundTurnWaiter } from "./foreground-run-state.js";
|
|
@@ -266,12 +266,19 @@ export declare class AgentManager {
|
|
|
266
266
|
private markRecordArchived;
|
|
267
267
|
private fireAgentArchived;
|
|
268
268
|
private dispatchArchivedStoredAgent;
|
|
269
|
-
setAgentMode(agentId: string, modeId: string): Promise<
|
|
269
|
+
setAgentMode(agentId: string, modeId: string): Promise<AgentProviderNotice | null>;
|
|
270
270
|
setAgentModel(agentId: string, modelId: string | null): Promise<void>;
|
|
271
|
-
setAgentThinkingOption(agentId: string, thinkingOptionId: string | null): Promise<
|
|
271
|
+
setAgentThinkingOption(agentId: string, thinkingOptionId: string | null): Promise<AgentProviderNotice | null>;
|
|
272
272
|
setAgentFeature(agentId: string, featureId: string, value: unknown): Promise<void>;
|
|
273
273
|
setTitle(agentId: string, title: string): Promise<void>;
|
|
274
274
|
setLabels(agentId: string, labels: Record<string, string>): Promise<void>;
|
|
275
|
+
private writeLabels;
|
|
276
|
+
private writeStoredMetadata;
|
|
277
|
+
detachAgent(agentId: string): Promise<{
|
|
278
|
+
record: StoredAgentRecord;
|
|
279
|
+
live: boolean;
|
|
280
|
+
previousParentAgentId: string | null;
|
|
281
|
+
}>;
|
|
275
282
|
notifyAgentState(agentId: string): void;
|
|
276
283
|
clearAgentAttention(agentId: string): Promise<void>;
|
|
277
284
|
archiveSnapshot(agentId: string, archivedAt: string): Promise<StoredAgentRecord>;
|
|
@@ -373,6 +380,7 @@ export declare class AgentManager {
|
|
|
373
380
|
private getConfiguredProviderIds;
|
|
374
381
|
private requireClient;
|
|
375
382
|
archiveNativeSessionBestEffort(provider: AgentProvider, persistence: AgentPersistenceHandle | null | undefined): Promise<void>;
|
|
383
|
+
private unarchiveNativeSession;
|
|
376
384
|
private requireAgent;
|
|
377
385
|
private requireSessionAgent;
|
|
378
386
|
}
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import { stat } from "node:fs/promises";
|
|
4
4
|
import { AGENT_LIFECYCLE_STATUSES, } from "@getpaseo/protocol/agent-lifecycle";
|
|
5
|
-
import { isDelegatedAgent, PARENT_AGENT_ID_LABEL } from "@getpaseo/protocol/agent-labels";
|
|
5
|
+
import { getParentAgentIdFromLabels, isDelegatedAgent, PARENT_AGENT_ID_LABEL, } from "@getpaseo/protocol/agent-labels";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { getAgentStreamEventTurnId, } from "./agent-sdk-types.js";
|
|
8
8
|
import { buildArchivedAgentRecord } from "./agent-archive.js";
|
|
@@ -82,7 +82,7 @@ function attachPersistenceCwd(handle, cwd) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
const BUSY_STATUSES = new Set(["initializing", "running"]);
|
|
85
|
-
const AgentIdSchema = z.
|
|
85
|
+
const AgentIdSchema = z.guid();
|
|
86
86
|
function isAgentBusy(status) {
|
|
87
87
|
return BUSY_STATUSES.has(status);
|
|
88
88
|
}
|
|
@@ -109,6 +109,18 @@ function validateAgentId(agentId, source) {
|
|
|
109
109
|
}
|
|
110
110
|
return result.data;
|
|
111
111
|
}
|
|
112
|
+
function applyLabelPatch(labels, patch) {
|
|
113
|
+
const nextLabels = { ...labels };
|
|
114
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
115
|
+
if (value === null) {
|
|
116
|
+
delete nextLabels[key];
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
nextLabels[key] = value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return nextLabels;
|
|
123
|
+
}
|
|
112
124
|
function buildExplicitTimelineSeedForRegister(now, options) {
|
|
113
125
|
const hasTimeline = Boolean(options?.timeline?.length);
|
|
114
126
|
const hasTimelineRows = Boolean(options?.timelineRows?.length);
|
|
@@ -676,9 +688,8 @@ export class AgentManager {
|
|
|
676
688
|
}
|
|
677
689
|
// Children created via the MCP `create_agent` tool carry the parent-agent-id
|
|
678
690
|
// label pointing back at the caller. Archiving the parent cascades to those
|
|
679
|
-
// children so subagent fleets don't outlive their orchestrator.
|
|
680
|
-
//
|
|
681
|
-
// for the accepted limitation.
|
|
691
|
+
// children so subagent fleets don't outlive their orchestrator. Detached
|
|
692
|
+
// handoff agents omit this label, so they stand outside the cascade.
|
|
682
693
|
async cascadeArchiveChildren(parentAgentId) {
|
|
683
694
|
const registry = this.registry;
|
|
684
695
|
if (!registry) {
|
|
@@ -768,7 +779,7 @@ export class AgentManager {
|
|
|
768
779
|
}
|
|
769
780
|
async setAgentMode(agentId, modeId) {
|
|
770
781
|
const agent = this.requireSessionAgent(agentId);
|
|
771
|
-
await agent.session.setMode(modeId);
|
|
782
|
+
const notice = (await agent.session.setMode(modeId)) ?? null;
|
|
772
783
|
const currentMode = (await agent.session.getCurrentMode()) ?? modeId;
|
|
773
784
|
agent.config.modeId = currentMode ?? undefined;
|
|
774
785
|
agent.currentModeId = currentMode;
|
|
@@ -778,6 +789,7 @@ export class AgentManager {
|
|
|
778
789
|
}
|
|
779
790
|
this.touchUpdatedAt(agent);
|
|
780
791
|
this.emitState(agent);
|
|
792
|
+
return notice;
|
|
781
793
|
}
|
|
782
794
|
async setAgentModel(agentId, modelId) {
|
|
783
795
|
const agent = this.requireSessionAgent(agentId);
|
|
@@ -797,8 +809,9 @@ export class AgentManager {
|
|
|
797
809
|
const normalizedThinkingOptionId = typeof thinkingOptionId === "string" && thinkingOptionId.trim().length > 0
|
|
798
810
|
? thinkingOptionId
|
|
799
811
|
: null;
|
|
812
|
+
let notice = null;
|
|
800
813
|
if (agent.session.setThinkingOption) {
|
|
801
|
-
await agent.session.setThinkingOption(normalizedThinkingOptionId);
|
|
814
|
+
notice = (await agent.session.setThinkingOption(normalizedThinkingOptionId)) ?? null;
|
|
802
815
|
}
|
|
803
816
|
agent.config.thinkingOptionId = normalizedThinkingOptionId ?? undefined;
|
|
804
817
|
if (agent.runtimeInfo) {
|
|
@@ -809,6 +822,7 @@ export class AgentManager {
|
|
|
809
822
|
}
|
|
810
823
|
this.touchUpdatedAt(agent);
|
|
811
824
|
this.emitState(agent);
|
|
825
|
+
return notice;
|
|
812
826
|
}
|
|
813
827
|
async setAgentFeature(agentId, featureId, value) {
|
|
814
828
|
const agent = this.requireAgent(agentId);
|
|
@@ -837,10 +851,68 @@ export class AgentManager {
|
|
|
837
851
|
}
|
|
838
852
|
async setLabels(agentId, labels) {
|
|
839
853
|
const agent = this.requireAgent(agentId);
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
this.
|
|
854
|
+
await this.writeLabels(agent.id, labels);
|
|
855
|
+
}
|
|
856
|
+
async writeLabels(agentId, patch) {
|
|
857
|
+
const liveAgent = this.agents.get(agentId);
|
|
858
|
+
if (liveAgent) {
|
|
859
|
+
liveAgent.labels = applyLabelPatch(liveAgent.labels, patch);
|
|
860
|
+
this.touchUpdatedAt(liveAgent);
|
|
861
|
+
await this.persistSnapshot(liveAgent);
|
|
862
|
+
this.emitState(liveAgent, { persist: false });
|
|
863
|
+
const record = this.registry ? await this.registry.get(agentId) : null;
|
|
864
|
+
return { record, live: true };
|
|
865
|
+
}
|
|
866
|
+
const nextRecord = await this.writeStoredMetadata(agentId, { labels: patch });
|
|
867
|
+
return { record: nextRecord, live: false };
|
|
868
|
+
}
|
|
869
|
+
async writeStoredMetadata(agentId, patch) {
|
|
870
|
+
const registry = this.requireRegistry();
|
|
871
|
+
const record = await registry.get(agentId);
|
|
872
|
+
if (!record) {
|
|
873
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
874
|
+
}
|
|
875
|
+
const nextRecord = {
|
|
876
|
+
...record,
|
|
877
|
+
...(patch.title ? { title: patch.title } : {}),
|
|
878
|
+
...(patch.labels ? { labels: applyLabelPatch(record.labels, patch.labels) } : {}),
|
|
879
|
+
updatedAt: this.nextStoredUpdatedAt(record),
|
|
880
|
+
};
|
|
881
|
+
await registry.upsert(nextRecord);
|
|
882
|
+
return nextRecord;
|
|
883
|
+
}
|
|
884
|
+
async detachAgent(agentId) {
|
|
885
|
+
const registry = this.requireRegistry();
|
|
886
|
+
const liveAgent = this.agents.get(agentId);
|
|
887
|
+
if (liveAgent) {
|
|
888
|
+
const previousParentAgentId = getParentAgentIdFromLabels(liveAgent.labels);
|
|
889
|
+
if (!previousParentAgentId) {
|
|
890
|
+
await this.persistSnapshot(liveAgent);
|
|
891
|
+
const record = await registry.get(agentId);
|
|
892
|
+
if (!record) {
|
|
893
|
+
throw new Error(`Agent not found in storage after detach: ${agentId}`);
|
|
894
|
+
}
|
|
895
|
+
return { record, live: true, previousParentAgentId: null };
|
|
896
|
+
}
|
|
897
|
+
const { record } = await this.writeLabels(agentId, { [PARENT_AGENT_ID_LABEL]: null });
|
|
898
|
+
if (!record) {
|
|
899
|
+
throw new Error(`Agent not found in storage after detach: ${agentId}`);
|
|
900
|
+
}
|
|
901
|
+
return { record, live: true, previousParentAgentId };
|
|
902
|
+
}
|
|
903
|
+
const record = await registry.get(agentId);
|
|
904
|
+
if (!record) {
|
|
905
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
906
|
+
}
|
|
907
|
+
const previousParentAgentId = getParentAgentIdFromLabels(record.labels);
|
|
908
|
+
if (!previousParentAgentId) {
|
|
909
|
+
return { record, live: false, previousParentAgentId: null };
|
|
910
|
+
}
|
|
911
|
+
const result = await this.writeLabels(agentId, { [PARENT_AGENT_ID_LABEL]: null });
|
|
912
|
+
if (!result.record) {
|
|
913
|
+
throw new Error(`Agent not found in storage after detach: ${agentId}`);
|
|
914
|
+
}
|
|
915
|
+
return { record: result.record, live: false, previousParentAgentId };
|
|
844
916
|
}
|
|
845
917
|
notifyAgentState(agentId) {
|
|
846
918
|
const agent = this.agents.get(agentId);
|
|
@@ -888,9 +960,11 @@ export class AgentManager {
|
|
|
888
960
|
if (!record || !record.archivedAt) {
|
|
889
961
|
return false;
|
|
890
962
|
}
|
|
963
|
+
await this.unarchiveNativeSession(record.provider, record.persistence);
|
|
891
964
|
await registry.upsert({
|
|
892
965
|
...record,
|
|
893
966
|
archivedAt: null,
|
|
967
|
+
updatedAt: new Date().toISOString(),
|
|
894
968
|
});
|
|
895
969
|
if (this.getAgent(agentId)) {
|
|
896
970
|
this.notifyAgentState(agentId);
|
|
@@ -914,21 +988,11 @@ export class AgentManager {
|
|
|
914
988
|
await this.setTitle(agentId, updates.title);
|
|
915
989
|
}
|
|
916
990
|
if (updates.labels) {
|
|
917
|
-
await this.
|
|
991
|
+
await this.writeLabels(agentId, updates.labels);
|
|
918
992
|
}
|
|
919
993
|
return;
|
|
920
994
|
}
|
|
921
|
-
|
|
922
|
-
const existing = await registry.get(agentId);
|
|
923
|
-
if (!existing) {
|
|
924
|
-
throw new Error(`Agent not found: ${agentId}`);
|
|
925
|
-
}
|
|
926
|
-
await registry.upsert({
|
|
927
|
-
...existing,
|
|
928
|
-
...(updates.title ? { title: updates.title } : {}),
|
|
929
|
-
...(updates.labels ? { labels: { ...existing.labels, ...updates.labels } } : {}),
|
|
930
|
-
updatedAt: this.nextStoredUpdatedAt(existing),
|
|
931
|
-
});
|
|
995
|
+
await this.writeStoredMetadata(agentId, updates);
|
|
932
996
|
}
|
|
933
997
|
async runAgent(agentId, prompt, options) {
|
|
934
998
|
const events = this.streamAgent(agentId, prompt, options);
|
|
@@ -2619,6 +2683,14 @@ export class AgentManager {
|
|
|
2619
2683
|
this.logger.warn({ error, provider, sessionId: persistence.sessionId }, "Failed to archive native session (best-effort)");
|
|
2620
2684
|
}
|
|
2621
2685
|
}
|
|
2686
|
+
async unarchiveNativeSession(provider, persistence) {
|
|
2687
|
+
if (!persistence)
|
|
2688
|
+
return;
|
|
2689
|
+
const client = this.clients.get(provider);
|
|
2690
|
+
if (!client?.unarchiveNativeSession)
|
|
2691
|
+
return;
|
|
2692
|
+
await client.unarchiveNativeSession(persistence);
|
|
2693
|
+
}
|
|
2622
2694
|
requireAgent(id) {
|
|
2623
2695
|
const normalizedId = validateAgentId(id, "requireAgent");
|
|
2624
2696
|
const agent = this.agents.get(normalizedId);
|
|
@@ -15,7 +15,7 @@ export declare function startAgentRun(agentManager: AgentRunController, agentId:
|
|
|
15
15
|
* Shared across Session (app/WS), MCP, and CLI so every surface that acts on
|
|
16
16
|
* an archived agent unarchives it the same way.
|
|
17
17
|
*/
|
|
18
|
-
export declare function unarchiveAgentState(
|
|
18
|
+
export declare function unarchiveAgentState(_agentStorage: AgentStorage, agentManager: AgentManager, agentId: string): Promise<boolean>;
|
|
19
19
|
/**
|
|
20
20
|
* Wrap a body in <paseo-system>…</paseo-system> so the receiving agent
|
|
21
21
|
* recognizes the prompt as system-injected context — not a user turn.
|
|
@@ -55,17 +55,10 @@ export function startAgentRun(agentManager, agentId, prompt, logger, options) {
|
|
|
55
55
|
* Shared across Session (app/WS), MCP, and CLI so every surface that acts on
|
|
56
56
|
* an archived agent unarchives it the same way.
|
|
57
57
|
*/
|
|
58
|
-
export async function unarchiveAgentState(
|
|
59
|
-
const
|
|
60
|
-
if (!
|
|
58
|
+
export async function unarchiveAgentState(_agentStorage, agentManager, agentId) {
|
|
59
|
+
const unarchived = await agentManager.unarchiveSnapshot(agentId);
|
|
60
|
+
if (!unarchived)
|
|
61
61
|
return false;
|
|
62
|
-
}
|
|
63
|
-
const updatedAt = new Date().toISOString();
|
|
64
|
-
await agentStorage.upsert({
|
|
65
|
-
...record,
|
|
66
|
-
archivedAt: null,
|
|
67
|
-
updatedAt,
|
|
68
|
-
});
|
|
69
62
|
agentManager.notifyAgentState(agentId);
|
|
70
63
|
return true;
|
|
71
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import Ajv from "ajv";
|
|
3
3
|
export class StructuredAgentResponseError extends Error {
|
|
4
4
|
constructor(message, options) {
|
|
@@ -32,8 +32,14 @@ function isZodSchema(value) {
|
|
|
32
32
|
return typeof value?.safeParse === "function";
|
|
33
33
|
}
|
|
34
34
|
function buildZodValidator(schema, schemaName) {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const jsonSchema = z.toJSONSchema(schema, {
|
|
36
|
+
target: "draft-07",
|
|
37
|
+
unrepresentable: "any",
|
|
38
|
+
io: "input",
|
|
39
|
+
});
|
|
40
|
+
if (typeof jsonSchema.title !== "string") {
|
|
41
|
+
jsonSchema.title = schemaName;
|
|
42
|
+
}
|
|
37
43
|
return {
|
|
38
44
|
jsonSchema,
|
|
39
45
|
validate: (value) => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Options as ClaudeAgentOptions } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import type { AgentProviderNotice } from "@getpaseo/protocol/agent-types";
|
|
2
3
|
import type { AgentAttachment } from "@getpaseo/protocol/messages";
|
|
4
|
+
export type { AgentProviderNotice };
|
|
3
5
|
export type AgentProvider = string;
|
|
4
6
|
export interface AgentMetadata {
|
|
5
7
|
[key: string]: unknown;
|
|
@@ -543,7 +545,7 @@ export interface AgentSession {
|
|
|
543
545
|
getRuntimeInfo(): Promise<AgentRuntimeInfo>;
|
|
544
546
|
getAvailableModes(): Promise<AgentMode[]>;
|
|
545
547
|
getCurrentMode(): Promise<string | null>;
|
|
546
|
-
setMode(modeId: string): Promise<void>;
|
|
548
|
+
setMode(modeId: string): Promise<void | AgentProviderNotice>;
|
|
547
549
|
getPendingPermissions(): AgentPermissionRequest[];
|
|
548
550
|
respondToPermission(requestId: string, response: AgentPermissionResponse): Promise<AgentPermissionResult | void>;
|
|
549
551
|
describePersistence(): AgentPersistenceHandle | null;
|
|
@@ -551,7 +553,7 @@ export interface AgentSession {
|
|
|
551
553
|
close(): Promise<void>;
|
|
552
554
|
listCommands?(): Promise<AgentSlashCommand[]>;
|
|
553
555
|
setModel?(modelId: string | null): Promise<void>;
|
|
554
|
-
setThinkingOption?(thinkingOptionId: string | null): Promise<void>;
|
|
556
|
+
setThinkingOption?(thinkingOptionId: string | null): Promise<void | AgentProviderNotice>;
|
|
555
557
|
setFeature?(featureId: string, value: unknown): Promise<void>;
|
|
556
558
|
revertConversation?(input: {
|
|
557
559
|
messageId: string;
|
|
@@ -610,6 +612,11 @@ export interface AgentClient {
|
|
|
610
612
|
* Called when Paseo archives an agent so the provider's own UI reflects the same state.
|
|
611
613
|
*/
|
|
612
614
|
archiveNativeSession?(handle: AgentPersistenceHandle): Promise<void>;
|
|
615
|
+
/**
|
|
616
|
+
* Unarchive a persisted session in the native provider.
|
|
617
|
+
* Called before Paseo clears its archived flag so provider resume can succeed.
|
|
618
|
+
*/
|
|
619
|
+
unarchiveNativeSession?(handle: AgentPersistenceHandle): Promise<void>;
|
|
613
620
|
/**
|
|
614
621
|
* Release any provider-owned resources held by this client (background
|
|
615
622
|
* processes, sockets, cached subprocesses, etc.). Called when the daemon
|
|
@@ -617,5 +624,4 @@ export interface AgentClient {
|
|
|
617
624
|
*/
|
|
618
625
|
shutdown?(): Promise<void>;
|
|
619
626
|
}
|
|
620
|
-
export {};
|
|
621
627
|
//# sourceMappingURL=agent-sdk-types.d.ts.map
|
|
@@ -13,7 +13,13 @@ declare const STORED_AGENT_SCHEMA: z.ZodObject<{
|
|
|
13
13
|
lastUserMessageAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
14
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
15
15
|
labels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
16
|
-
lastStatus: z.ZodDefault<z.ZodEnum<
|
|
16
|
+
lastStatus: z.ZodDefault<z.ZodEnum<{
|
|
17
|
+
error: "error";
|
|
18
|
+
initializing: "initializing";
|
|
19
|
+
idle: "idle";
|
|
20
|
+
running: "running";
|
|
21
|
+
closed: "closed";
|
|
22
|
+
}>>;
|
|
17
23
|
lastModeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
24
|
config: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
19
25
|
modeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -23,23 +29,7 @@ declare const STORED_AGENT_SCHEMA: z.ZodObject<{
|
|
|
23
29
|
extra: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
24
30
|
systemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
31
|
mcpServers: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
26
|
-
},
|
|
27
|
-
modeId?: string | null | undefined;
|
|
28
|
-
model?: string | null | undefined;
|
|
29
|
-
thinkingOptionId?: string | null | undefined;
|
|
30
|
-
featureValues?: Record<string, unknown> | null | undefined;
|
|
31
|
-
extra?: Record<string, any> | null | undefined;
|
|
32
|
-
systemPrompt?: string | null | undefined;
|
|
33
|
-
mcpServers?: Record<string, any> | null | undefined;
|
|
34
|
-
}, {
|
|
35
|
-
modeId?: string | null | undefined;
|
|
36
|
-
model?: string | null | undefined;
|
|
37
|
-
thinkingOptionId?: string | null | undefined;
|
|
38
|
-
featureValues?: Record<string, unknown> | null | undefined;
|
|
39
|
-
extra?: Record<string, any> | null | undefined;
|
|
40
|
-
systemPrompt?: string | null | undefined;
|
|
41
|
-
mcpServers?: Record<string, any> | null | undefined;
|
|
42
|
-
}>>>;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
43
33
|
runtimeInfo: z.ZodOptional<z.ZodObject<{
|
|
44
34
|
provider: z.ZodString;
|
|
45
35
|
sessionId: z.ZodNullable<z.ZodString>;
|
|
@@ -47,22 +37,8 @@ declare const STORED_AGENT_SCHEMA: z.ZodObject<{
|
|
|
47
37
|
thinkingOptionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
38
|
modeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
49
39
|
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
sessionId: string | null;
|
|
53
|
-
modeId?: string | null | undefined;
|
|
54
|
-
model?: string | null | undefined;
|
|
55
|
-
thinkingOptionId?: string | null | undefined;
|
|
56
|
-
extra?: Record<string, unknown> | undefined;
|
|
57
|
-
}, {
|
|
58
|
-
provider: string;
|
|
59
|
-
sessionId: string | null;
|
|
60
|
-
modeId?: string | null | undefined;
|
|
61
|
-
model?: string | null | undefined;
|
|
62
|
-
thinkingOptionId?: string | null | undefined;
|
|
63
|
-
extra?: Record<string, unknown> | undefined;
|
|
64
|
-
}>>;
|
|
65
|
-
features: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
features: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
66
42
|
type: z.ZodLiteral<"toggle">;
|
|
67
43
|
id: z.ZodString;
|
|
68
44
|
label: z.ZodString;
|
|
@@ -70,23 +46,7 @@ declare const STORED_AGENT_SCHEMA: z.ZodObject<{
|
|
|
70
46
|
tooltip: z.ZodOptional<z.ZodString>;
|
|
71
47
|
icon: z.ZodOptional<z.ZodString>;
|
|
72
48
|
value: z.ZodBoolean;
|
|
73
|
-
},
|
|
74
|
-
value: boolean;
|
|
75
|
-
type: "toggle";
|
|
76
|
-
id: string;
|
|
77
|
-
label: string;
|
|
78
|
-
description?: string | undefined;
|
|
79
|
-
icon?: string | undefined;
|
|
80
|
-
tooltip?: string | undefined;
|
|
81
|
-
}, {
|
|
82
|
-
value: boolean;
|
|
83
|
-
type: "toggle";
|
|
84
|
-
id: string;
|
|
85
|
-
label: string;
|
|
86
|
-
description?: string | undefined;
|
|
87
|
-
icon?: string | undefined;
|
|
88
|
-
tooltip?: string | undefined;
|
|
89
|
-
}>, z.ZodObject<{
|
|
49
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
90
50
|
type: z.ZodLiteral<"select">;
|
|
91
51
|
id: z.ZodString;
|
|
92
52
|
label: z.ZodString;
|
|
@@ -100,205 +60,25 @@ declare const STORED_AGENT_SCHEMA: z.ZodObject<{
|
|
|
100
60
|
description: z.ZodOptional<z.ZodString>;
|
|
101
61
|
isDefault: z.ZodOptional<z.ZodBoolean>;
|
|
102
62
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
label: string;
|
|
106
|
-
description?: string | undefined;
|
|
107
|
-
metadata?: Record<string, unknown> | undefined;
|
|
108
|
-
isDefault?: boolean | undefined;
|
|
109
|
-
}, {
|
|
110
|
-
id: string;
|
|
111
|
-
label: string;
|
|
112
|
-
description?: string | undefined;
|
|
113
|
-
metadata?: Record<string, unknown> | undefined;
|
|
114
|
-
isDefault?: boolean | undefined;
|
|
115
|
-
}>, "many">;
|
|
116
|
-
}, "strip", z.ZodTypeAny, {
|
|
117
|
-
value: string | null;
|
|
118
|
-
options: {
|
|
119
|
-
id: string;
|
|
120
|
-
label: string;
|
|
121
|
-
description?: string | undefined;
|
|
122
|
-
metadata?: Record<string, unknown> | undefined;
|
|
123
|
-
isDefault?: boolean | undefined;
|
|
124
|
-
}[];
|
|
125
|
-
type: "select";
|
|
126
|
-
id: string;
|
|
127
|
-
label: string;
|
|
128
|
-
description?: string | undefined;
|
|
129
|
-
icon?: string | undefined;
|
|
130
|
-
tooltip?: string | undefined;
|
|
131
|
-
}, {
|
|
132
|
-
value: string | null;
|
|
133
|
-
options: {
|
|
134
|
-
id: string;
|
|
135
|
-
label: string;
|
|
136
|
-
description?: string | undefined;
|
|
137
|
-
metadata?: Record<string, unknown> | undefined;
|
|
138
|
-
isDefault?: boolean | undefined;
|
|
139
|
-
}[];
|
|
140
|
-
type: "select";
|
|
141
|
-
id: string;
|
|
142
|
-
label: string;
|
|
143
|
-
description?: string | undefined;
|
|
144
|
-
icon?: string | undefined;
|
|
145
|
-
tooltip?: string | undefined;
|
|
146
|
-
}>]>, "many">>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>], "type">>>;
|
|
147
65
|
persistence: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
148
66
|
provider: z.ZodString;
|
|
149
67
|
sessionId: z.ZodString;
|
|
150
68
|
nativeHandle: z.ZodOptional<z.ZodAny>;
|
|
151
69
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
152
|
-
},
|
|
153
|
-
provider: string;
|
|
154
|
-
sessionId: string;
|
|
155
|
-
metadata?: Record<string, any> | undefined;
|
|
156
|
-
nativeHandle?: any;
|
|
157
|
-
}, {
|
|
158
|
-
provider: string;
|
|
159
|
-
sessionId: string;
|
|
160
|
-
metadata?: Record<string, any> | undefined;
|
|
161
|
-
nativeHandle?: any;
|
|
162
|
-
}>>>;
|
|
70
|
+
}, z.core.$strip>>>;
|
|
163
71
|
lastError: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
72
|
requiresAttention: z.ZodOptional<z.ZodBoolean>;
|
|
165
|
-
attentionReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<
|
|
73
|
+
attentionReason: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
74
|
+
finished: "finished";
|
|
75
|
+
error: "error";
|
|
76
|
+
permission: "permission";
|
|
77
|
+
}>>>;
|
|
166
78
|
attentionTimestamp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
167
79
|
internal: z.ZodOptional<z.ZodBoolean>;
|
|
168
80
|
archivedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
169
|
-
},
|
|
170
|
-
cwd: string;
|
|
171
|
-
id: string;
|
|
172
|
-
provider: string;
|
|
173
|
-
createdAt: string;
|
|
174
|
-
updatedAt: string;
|
|
175
|
-
labels: Record<string, string>;
|
|
176
|
-
lastStatus: "error" | "idle" | "running" | "initializing" | "closed";
|
|
177
|
-
workspaceId?: string | undefined;
|
|
178
|
-
internal?: boolean | undefined;
|
|
179
|
-
attentionReason?: "finished" | "error" | "permission" | null | undefined;
|
|
180
|
-
title?: string | null | undefined;
|
|
181
|
-
persistence?: {
|
|
182
|
-
provider: string;
|
|
183
|
-
sessionId: string;
|
|
184
|
-
metadata?: Record<string, any> | undefined;
|
|
185
|
-
nativeHandle?: any;
|
|
186
|
-
} | null | undefined;
|
|
187
|
-
lastActivityAt?: string | undefined;
|
|
188
|
-
lastUserMessageAt?: string | null | undefined;
|
|
189
|
-
lastModeId?: string | null | undefined;
|
|
190
|
-
config?: {
|
|
191
|
-
modeId?: string | null | undefined;
|
|
192
|
-
model?: string | null | undefined;
|
|
193
|
-
thinkingOptionId?: string | null | undefined;
|
|
194
|
-
featureValues?: Record<string, unknown> | null | undefined;
|
|
195
|
-
extra?: Record<string, any> | null | undefined;
|
|
196
|
-
systemPrompt?: string | null | undefined;
|
|
197
|
-
mcpServers?: Record<string, any> | null | undefined;
|
|
198
|
-
} | null | undefined;
|
|
199
|
-
runtimeInfo?: {
|
|
200
|
-
provider: string;
|
|
201
|
-
sessionId: string | null;
|
|
202
|
-
modeId?: string | null | undefined;
|
|
203
|
-
model?: string | null | undefined;
|
|
204
|
-
thinkingOptionId?: string | null | undefined;
|
|
205
|
-
extra?: Record<string, unknown> | undefined;
|
|
206
|
-
} | undefined;
|
|
207
|
-
features?: ({
|
|
208
|
-
value: boolean;
|
|
209
|
-
type: "toggle";
|
|
210
|
-
id: string;
|
|
211
|
-
label: string;
|
|
212
|
-
description?: string | undefined;
|
|
213
|
-
icon?: string | undefined;
|
|
214
|
-
tooltip?: string | undefined;
|
|
215
|
-
} | {
|
|
216
|
-
value: string | null;
|
|
217
|
-
options: {
|
|
218
|
-
id: string;
|
|
219
|
-
label: string;
|
|
220
|
-
description?: string | undefined;
|
|
221
|
-
metadata?: Record<string, unknown> | undefined;
|
|
222
|
-
isDefault?: boolean | undefined;
|
|
223
|
-
}[];
|
|
224
|
-
type: "select";
|
|
225
|
-
id: string;
|
|
226
|
-
label: string;
|
|
227
|
-
description?: string | undefined;
|
|
228
|
-
icon?: string | undefined;
|
|
229
|
-
tooltip?: string | undefined;
|
|
230
|
-
})[] | undefined;
|
|
231
|
-
lastError?: string | null | undefined;
|
|
232
|
-
requiresAttention?: boolean | undefined;
|
|
233
|
-
attentionTimestamp?: string | null | undefined;
|
|
234
|
-
archivedAt?: string | null | undefined;
|
|
235
|
-
}, {
|
|
236
|
-
cwd: string;
|
|
237
|
-
id: string;
|
|
238
|
-
provider: string;
|
|
239
|
-
createdAt: string;
|
|
240
|
-
updatedAt: string;
|
|
241
|
-
workspaceId?: string | undefined;
|
|
242
|
-
internal?: boolean | undefined;
|
|
243
|
-
attentionReason?: "finished" | "error" | "permission" | null | undefined;
|
|
244
|
-
title?: string | null | undefined;
|
|
245
|
-
persistence?: {
|
|
246
|
-
provider: string;
|
|
247
|
-
sessionId: string;
|
|
248
|
-
metadata?: Record<string, any> | undefined;
|
|
249
|
-
nativeHandle?: any;
|
|
250
|
-
} | null | undefined;
|
|
251
|
-
lastActivityAt?: string | undefined;
|
|
252
|
-
lastUserMessageAt?: string | null | undefined;
|
|
253
|
-
labels?: Record<string, string> | undefined;
|
|
254
|
-
lastStatus?: "error" | "idle" | "running" | "initializing" | "closed" | undefined;
|
|
255
|
-
lastModeId?: string | null | undefined;
|
|
256
|
-
config?: {
|
|
257
|
-
modeId?: string | null | undefined;
|
|
258
|
-
model?: string | null | undefined;
|
|
259
|
-
thinkingOptionId?: string | null | undefined;
|
|
260
|
-
featureValues?: Record<string, unknown> | null | undefined;
|
|
261
|
-
extra?: Record<string, any> | null | undefined;
|
|
262
|
-
systemPrompt?: string | null | undefined;
|
|
263
|
-
mcpServers?: Record<string, any> | null | undefined;
|
|
264
|
-
} | null | undefined;
|
|
265
|
-
runtimeInfo?: {
|
|
266
|
-
provider: string;
|
|
267
|
-
sessionId: string | null;
|
|
268
|
-
modeId?: string | null | undefined;
|
|
269
|
-
model?: string | null | undefined;
|
|
270
|
-
thinkingOptionId?: string | null | undefined;
|
|
271
|
-
extra?: Record<string, unknown> | undefined;
|
|
272
|
-
} | undefined;
|
|
273
|
-
features?: ({
|
|
274
|
-
value: boolean;
|
|
275
|
-
type: "toggle";
|
|
276
|
-
id: string;
|
|
277
|
-
label: string;
|
|
278
|
-
description?: string | undefined;
|
|
279
|
-
icon?: string | undefined;
|
|
280
|
-
tooltip?: string | undefined;
|
|
281
|
-
} | {
|
|
282
|
-
value: string | null;
|
|
283
|
-
options: {
|
|
284
|
-
id: string;
|
|
285
|
-
label: string;
|
|
286
|
-
description?: string | undefined;
|
|
287
|
-
metadata?: Record<string, unknown> | undefined;
|
|
288
|
-
isDefault?: boolean | undefined;
|
|
289
|
-
}[];
|
|
290
|
-
type: "select";
|
|
291
|
-
id: string;
|
|
292
|
-
label: string;
|
|
293
|
-
description?: string | undefined;
|
|
294
|
-
icon?: string | undefined;
|
|
295
|
-
tooltip?: string | undefined;
|
|
296
|
-
})[] | undefined;
|
|
297
|
-
lastError?: string | null | undefined;
|
|
298
|
-
requiresAttention?: boolean | undefined;
|
|
299
|
-
attentionTimestamp?: string | null | undefined;
|
|
300
|
-
archivedAt?: string | null | undefined;
|
|
301
|
-
}>;
|
|
81
|
+
}, z.core.$strip>;
|
|
302
82
|
export type SerializableAgentConfig = Pick<AgentSessionConfig, "modeId" | "model" | "thinkingOptionId" | "featureValues" | "extra" | "systemPrompt" | "mcpServers">;
|
|
303
83
|
export type StoredAgentRecord = z.infer<typeof STORED_AGENT_SCHEMA>;
|
|
304
84
|
export declare function parseStoredAgentRecord(value: unknown): StoredAgentRecord;
|