@nuvin/session 0.2.0-rc.9 → 0.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/dist/{chunk-HJLRL64D.js → chunk-4UBSHJWS.js} +3 -1
- package/dist/{chunk-TUNCGICQ.js → chunk-5XT7AOI2.js} +1 -1
- package/dist/{chunk-KQHHBUVY.js → chunk-B6S3CWQX.js} +109 -6
- package/dist/{chunk-O3UBTUIO.js → chunk-FAYWOY6R.js} +1 -1
- package/dist/client/daemon-client.d.ts.map +1 -1
- package/dist/client/data-client.d.ts +28 -1
- package/dist/client/data-client.d.ts.map +1 -1
- package/dist/client/http-data-client.d.ts.map +1 -1
- package/dist/client/index.js +175 -74
- package/dist/client/session-client.d.ts +41 -9
- package/dist/client/session-client.d.ts.map +1 -1
- package/dist/controller/index.js +9 -4
- package/dist/controller/session-controller.d.ts +5 -2
- package/dist/controller/session-controller.d.ts.map +1 -1
- package/dist/grant/index.js +2 -2
- package/dist/protocol/data-rpc.d.ts +52 -1
- package/dist/protocol/data-rpc.d.ts.map +1 -1
- package/dist/protocol/index.js +4 -2
- package/dist/protocol/types.d.ts +250 -52
- package/dist/protocol/types.d.ts.map +1 -1
- package/dist/protocol/version.d.ts +1 -1
- package/dist/state/file-edit-preview.d.ts +47 -0
- package/dist/state/file-edit-preview.d.ts.map +1 -0
- package/dist/state/index.js +3 -1
- package/dist/state/messages.d.ts +20 -0
- package/dist/state/messages.d.ts.map +1 -1
- package/dist/state/tool-preview.d.ts +3 -0
- package/dist/state/tool-preview.d.ts.map +1 -1
- package/dist/state/tool-preview.js +192 -63
- package/dist/test-utils/index.js +3 -3
- package/package.json +2 -2
|
@@ -54,6 +54,9 @@ function scopedToolKey(parentToolCallId, toolCallId) {
|
|
|
54
54
|
|
|
55
55
|
// src/state/messages.ts
|
|
56
56
|
import { getReasoningTextFromMessage, getTextFromMessage } from "@nuvin/agent-core/formats";
|
|
57
|
+
function isProviderRetryMessage(message) {
|
|
58
|
+
return message.role === "warning" && message.providerRetry !== void 0;
|
|
59
|
+
}
|
|
57
60
|
function createMessageId(state) {
|
|
58
61
|
return `message-${state.nextId}`;
|
|
59
62
|
}
|
|
@@ -73,6 +76,98 @@ function addMessage(state, message) {
|
|
|
73
76
|
function scopedRegistryKey(scope, id) {
|
|
74
77
|
return scope ? `${scope}::${id}` : id;
|
|
75
78
|
}
|
|
79
|
+
function compactError(error) {
|
|
80
|
+
const normalized = error.trim().replace(/\s+/g, " ");
|
|
81
|
+
return normalized.length <= 160 ? normalized : `${normalized.slice(0, 159)}\u2026`;
|
|
82
|
+
}
|
|
83
|
+
function retryDelayText(delayMs) {
|
|
84
|
+
return delayMs === 0 ? "retry now" : `retry after ${Math.max(1, Math.ceil(delayMs / 1e3))}s`;
|
|
85
|
+
}
|
|
86
|
+
function retryReasonText(event) {
|
|
87
|
+
if (event.reason === "transport_error") return "Network interrupted";
|
|
88
|
+
if (event.reason === "stream_error") return "Provider stream interrupted";
|
|
89
|
+
return event.status === void 0 ? "Provider unavailable" : `Provider unavailable (HTTP ${event.status})`;
|
|
90
|
+
}
|
|
91
|
+
function formatProviderRetryText(event) {
|
|
92
|
+
return `${retryReasonText(event)}: ${compactError(event.error)} \xB7 ${retryDelayText(event.delayMs)} \xB7 attempt ${event.attempt + 1}/${event.maxAttempts}`;
|
|
93
|
+
}
|
|
94
|
+
function removeProviderStreamMessages(state, assistantMessageId, reasoningMessageId, parentToolCallId) {
|
|
95
|
+
const assistantKey = scopedRegistryKey(parentToolCallId, assistantMessageId);
|
|
96
|
+
const reasoningKey = scopedRegistryKey(parentToolCallId, reasoningMessageId);
|
|
97
|
+
const assistantRowId = state.assistantMessageIds[assistantKey];
|
|
98
|
+
const reasoningRowId = state.reasoningMessageIds[reasoningKey];
|
|
99
|
+
if (!assistantRowId && !reasoningRowId) {
|
|
100
|
+
return state;
|
|
101
|
+
}
|
|
102
|
+
const removedIds = /* @__PURE__ */ new Set();
|
|
103
|
+
if (assistantRowId) {
|
|
104
|
+
removedIds.add(assistantRowId);
|
|
105
|
+
}
|
|
106
|
+
if (reasoningRowId) {
|
|
107
|
+
removedIds.add(reasoningRowId);
|
|
108
|
+
}
|
|
109
|
+
const assistantMessageIds = { ...state.assistantMessageIds };
|
|
110
|
+
const reasoningMessageIds = { ...state.reasoningMessageIds };
|
|
111
|
+
if (assistantRowId) {
|
|
112
|
+
delete assistantMessageIds[assistantKey];
|
|
113
|
+
}
|
|
114
|
+
if (reasoningRowId) {
|
|
115
|
+
delete reasoningMessageIds[reasoningKey];
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
...state,
|
|
119
|
+
assistantMessageIds,
|
|
120
|
+
reasoningMessageIds,
|
|
121
|
+
messages: state.messages.filter((message) => !removedIds.has(message.id))
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function upsertProviderRetryMessage(state, event, parentToolCallId, now) {
|
|
125
|
+
const trackingKey = scopedRegistryKey(parentToolCallId, event.assistantMessageId);
|
|
126
|
+
const existingId = state.providerRetryMessageIds[trackingKey];
|
|
127
|
+
const attempt = {
|
|
128
|
+
failedAttempt: event.attempt,
|
|
129
|
+
maxAttempts: event.maxAttempts,
|
|
130
|
+
error: event.error,
|
|
131
|
+
delayMs: event.delayMs,
|
|
132
|
+
reason: event.reason,
|
|
133
|
+
...event.status !== void 0 ? { status: event.status } : {},
|
|
134
|
+
occurredAt: now
|
|
135
|
+
};
|
|
136
|
+
const text = formatProviderRetryText(event);
|
|
137
|
+
if (existingId) {
|
|
138
|
+
return withUpdatedMessage(state, existingId, (message) => {
|
|
139
|
+
if (!isProviderRetryMessage(message)) {
|
|
140
|
+
return message;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
...message,
|
|
144
|
+
text,
|
|
145
|
+
providerRetry: {
|
|
146
|
+
...message.providerRetry,
|
|
147
|
+
attempts: [...message.providerRetry.attempts, attempt]
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const id = createMessageId(state);
|
|
153
|
+
const nextState = addMessage(state, {
|
|
154
|
+
id,
|
|
155
|
+
role: "warning",
|
|
156
|
+
text,
|
|
157
|
+
...parentToolCallId ? { parentToolCallId } : {},
|
|
158
|
+
providerRetry: {
|
|
159
|
+
assistantMessageId: event.assistantMessageId,
|
|
160
|
+
attempts: [attempt]
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
...nextState,
|
|
165
|
+
providerRetryMessageIds: {
|
|
166
|
+
...nextState.providerRetryMessageIds,
|
|
167
|
+
[trackingKey]: id
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
76
171
|
function upsertTrackedTextMessage(state, registryKey, messageId, role, text, mode, live, parentToolCallId, timing) {
|
|
77
172
|
const trackingKey = scopedRegistryKey(parentToolCallId, messageId);
|
|
78
173
|
const existingId = state[registryKey][trackingKey];
|
|
@@ -350,6 +445,7 @@ function createMessageState() {
|
|
|
350
445
|
assistantMessageIds: {},
|
|
351
446
|
messages: [],
|
|
352
447
|
nextId: 1,
|
|
448
|
+
providerRetryMessageIds: {},
|
|
353
449
|
reasoningMessageIds: {},
|
|
354
450
|
toolMessageIds: {}
|
|
355
451
|
};
|
|
@@ -361,15 +457,20 @@ function createMessageStateFromMessages(messages) {
|
|
|
361
457
|
return Math.max(max, Number(match[1]) + 1);
|
|
362
458
|
}, 1) + messages.length;
|
|
363
459
|
const toolMessageIds = {};
|
|
460
|
+
const providerRetryMessageIds = {};
|
|
364
461
|
for (const message of messages) {
|
|
365
462
|
if (message.role === "tool") {
|
|
366
463
|
toolMessageIds[scopedToolKey(message.parentToolCallId, message.toolCallId)] = message.id;
|
|
367
464
|
}
|
|
465
|
+
if (isProviderRetryMessage(message)) {
|
|
466
|
+
providerRetryMessageIds[scopedRegistryKey(message.parentToolCallId, message.providerRetry.assistantMessageId)] = message.id;
|
|
467
|
+
}
|
|
368
468
|
}
|
|
369
469
|
return {
|
|
370
470
|
assistantMessageIds: {},
|
|
371
471
|
messages,
|
|
372
472
|
nextId,
|
|
473
|
+
providerRetryMessageIds,
|
|
373
474
|
reasoningMessageIds: {},
|
|
374
475
|
toolMessageIds
|
|
375
476
|
};
|
|
@@ -542,14 +643,15 @@ function applyAgentEvent(state, event, parentToolCallId, now = Date.now()) {
|
|
|
542
643
|
};
|
|
543
644
|
});
|
|
544
645
|
}
|
|
545
|
-
case "
|
|
546
|
-
|
|
547
|
-
const delayText = event.delayMs > 0 ? `in ${delaySeconds}s` : "now";
|
|
548
|
-
return appendWarningMessage(
|
|
646
|
+
case "provider_stream_reset":
|
|
647
|
+
return removeProviderStreamMessages(
|
|
549
648
|
state,
|
|
550
|
-
|
|
649
|
+
event.assistantMessageId,
|
|
650
|
+
event.reasoningMessageId,
|
|
651
|
+
parentToolCallId
|
|
551
652
|
);
|
|
552
|
-
|
|
653
|
+
case "provider_retry":
|
|
654
|
+
return upsertProviderRetryMessage(state, event, parentToolCallId, now);
|
|
553
655
|
default:
|
|
554
656
|
return state;
|
|
555
657
|
}
|
|
@@ -769,6 +871,7 @@ export {
|
|
|
769
871
|
removeApproval,
|
|
770
872
|
asJsonObject,
|
|
771
873
|
scopedToolKey,
|
|
874
|
+
isProviderRetryMessage,
|
|
772
875
|
settleAllLiveReasoning,
|
|
773
876
|
setToolMessageStatus,
|
|
774
877
|
setToolMessageApprovalKind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-client.d.ts","sourceRoot":"","sources":["../../src/client/daemon-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAEL,KAA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AC;IAC3C,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,iBAAiB,CAAC;IACtF,KAAK,IAAI,IAAI,CAAC;CACf;AASD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,MAAM,GACf,qBAAqB,CAyBvB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,IAAI,GAAE,gBAAqB,GAC1B,YAAY,CA8Md"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AddProviderInput, ConfigMutationResult, DaemonDirectoryRow, HistoryPage, ListHistoryParams, ListHistoryWorkspacesParams, ListHistoryWorkspacesResult, ListWorkspaceHistoryParams, PersistenceIdentity, ProfileSummary, ProviderConfigSummary, ProviderCredentialInput, SessionSnapshot, UpdateWorkspaceInput, WorkspaceConfigSummary, WorkspaceHistoryPage } from "../protocol/index.ts";
|
|
1
|
+
import type { AddProviderInput, AgentModelSetsView, AgentModelTierMappings, ConfigMutationResult, DaemonDirectoryRow, HistoryPage, ListHistoryParams, ListHistoryWorkspacesParams, ListHistoryWorkspacesResult, ListWorkspaceHistoryParams, PersistenceIdentity, ProfileSummary, ProviderConfigSummary, ProviderCredentialInput, SessionSnapshot, UpdateWorkspaceInput, WorkspaceConfigSummary, WorkspaceHistoryPage } from "../protocol/index.ts";
|
|
2
2
|
import type { TransportCredential } from "./endpoint.ts";
|
|
3
3
|
/** Discovery payload: the daemon directory (account-scoped cloud, machine-scoped local). */
|
|
4
4
|
export type DaemonDirectory = {
|
|
@@ -68,6 +68,33 @@ export interface DaemonDataClient {
|
|
|
68
68
|
profile?: string;
|
|
69
69
|
}): Promise<ConfigMutationResult<null>>;
|
|
70
70
|
updateWorkspace(daemonId: string, name: string, patch: UpdateWorkspaceInput): Promise<ConfigMutationResult<WorkspaceConfigSummary>>;
|
|
71
|
+
listAgentModelSets(daemonId: string, input: {
|
|
72
|
+
profile: string;
|
|
73
|
+
workspace?: string;
|
|
74
|
+
}): Promise<AgentModelSetsView>;
|
|
75
|
+
createAgentModelSet(daemonId: string, input: {
|
|
76
|
+
profile: string;
|
|
77
|
+
name: string;
|
|
78
|
+
mappings: AgentModelTierMappings;
|
|
79
|
+
}): Promise<ConfigMutationResult<null>>;
|
|
80
|
+
replaceAgentModelSet(daemonId: string, input: {
|
|
81
|
+
profile: string;
|
|
82
|
+
name: string;
|
|
83
|
+
mappings: AgentModelTierMappings;
|
|
84
|
+
}): Promise<ConfigMutationResult<null>>;
|
|
85
|
+
deleteAgentModelSet(daemonId: string, input: {
|
|
86
|
+
profile: string;
|
|
87
|
+
name: string;
|
|
88
|
+
}): Promise<ConfigMutationResult<null>>;
|
|
89
|
+
setDefaultAgentModelSet(daemonId: string, input: {
|
|
90
|
+
profile: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
}): Promise<ConfigMutationResult<null>>;
|
|
93
|
+
setWorkspaceAgentModelSet(daemonId: string, input: {
|
|
94
|
+
profile: string;
|
|
95
|
+
workspace: string;
|
|
96
|
+
name?: string;
|
|
97
|
+
}): Promise<ConfigMutationResult<null>>;
|
|
71
98
|
}
|
|
72
99
|
/** The full client both web modes compose (spec §4.2). */
|
|
73
100
|
export type DataClient = DaemonDirectoryClient & DaemonDataClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-client.d.ts","sourceRoot":"","sources":["../../src/client/data-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAA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AM,CAAC;QAAC,QAAQ,EAAE,sBAAsB,CAAA;KAAE,GACzE,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,oBAAoB,CAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,sBAAsB,CAAA;KAAE,GACzE,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,mBAAmB,CACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GACvC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,uBAAuB,CACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GACxC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,yBAAyB,CACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3D,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;CACxC;AAED,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,qBAAqB,GAAG,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-data-client.d.ts","sourceRoot":"","sources":["../../src/client/http-data-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"http-data-client.d.ts","sourceRoot":"","sources":["../../src/client/http-data-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,YAAY,EAQb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAmC,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGpF,MAAM,MAAM,qBAAqB,GAAG;IAClC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;gBAA1B,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM;CAKlB;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIvD;AA6CD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,UAAU,CAgcpF"}
|
package/dist/client/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSessionViewState,
|
|
3
3
|
reduceSessionEvent
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-B6S3CWQX.js";
|
|
5
5
|
import {
|
|
6
6
|
PROTOCOL_VERSION
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-FAYWOY6R.js";
|
|
8
8
|
|
|
9
9
|
// src/client/endpoint.ts
|
|
10
10
|
var TerminalEndpointError = class extends Error {
|
|
@@ -363,6 +363,80 @@ function createHttpDataClient(options = {}) {
|
|
|
363
363
|
});
|
|
364
364
|
if (!response.ok) await throwFromResponse(response, "Failed to update workspace");
|
|
365
365
|
return await response.json();
|
|
366
|
+
},
|
|
367
|
+
async listAgentModelSets(daemonId, input) {
|
|
368
|
+
const suffix = `/agent-model-sets${queryString({
|
|
369
|
+
profile: input.profile,
|
|
370
|
+
workspace: input.workspace
|
|
371
|
+
})}`;
|
|
372
|
+
const response = await daemonFetch(daemonId, suffix);
|
|
373
|
+
if (!response.ok) {
|
|
374
|
+
await throwFromResponse(response, "Failed to load agent model sets", {
|
|
375
|
+
404: { reason: "daemon-revoked", message: "This daemon is no longer registered." }
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
return await response.json();
|
|
379
|
+
},
|
|
380
|
+
async createAgentModelSet(daemonId, input) {
|
|
381
|
+
const response = await daemonFetch(daemonId, "/agent-model-sets", {
|
|
382
|
+
method: "POST",
|
|
383
|
+
headers: { "Content-Type": "application/json" },
|
|
384
|
+
body: JSON.stringify(input)
|
|
385
|
+
});
|
|
386
|
+
if (!response.ok) await throwFromResponse(response, "Failed to create agent model set");
|
|
387
|
+
return await response.json();
|
|
388
|
+
},
|
|
389
|
+
async replaceAgentModelSet(daemonId, input) {
|
|
390
|
+
const response = await daemonFetch(
|
|
391
|
+
daemonId,
|
|
392
|
+
`/agent-model-sets/${encodeURIComponent(input.name)}`,
|
|
393
|
+
{
|
|
394
|
+
method: "PUT",
|
|
395
|
+
headers: { "Content-Type": "application/json" },
|
|
396
|
+
body: JSON.stringify(input)
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
if (!response.ok) await throwFromResponse(response, "Failed to replace agent model set");
|
|
400
|
+
return await response.json();
|
|
401
|
+
},
|
|
402
|
+
async deleteAgentModelSet(daemonId, input) {
|
|
403
|
+
const response = await daemonFetch(
|
|
404
|
+
daemonId,
|
|
405
|
+
`/agent-model-sets/${encodeURIComponent(input.name)}`,
|
|
406
|
+
{
|
|
407
|
+
method: "DELETE",
|
|
408
|
+
headers: { "Content-Type": "application/json" },
|
|
409
|
+
body: JSON.stringify(input)
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
if (!response.ok) await throwFromResponse(response, "Failed to delete agent model set");
|
|
413
|
+
return await response.json();
|
|
414
|
+
},
|
|
415
|
+
async setDefaultAgentModelSet(daemonId, input) {
|
|
416
|
+
const response = await daemonFetch(daemonId, "/agent-model-set-default", {
|
|
417
|
+
method: "PUT",
|
|
418
|
+
headers: { "Content-Type": "application/json" },
|
|
419
|
+
body: JSON.stringify(input)
|
|
420
|
+
});
|
|
421
|
+
if (!response.ok) {
|
|
422
|
+
await throwFromResponse(response, "Failed to set default agent model set");
|
|
423
|
+
}
|
|
424
|
+
return await response.json();
|
|
425
|
+
},
|
|
426
|
+
async setWorkspaceAgentModelSet(daemonId, input) {
|
|
427
|
+
const response = await daemonFetch(
|
|
428
|
+
daemonId,
|
|
429
|
+
`/workspace-agent-model-set/${encodeURIComponent(input.workspace)}`,
|
|
430
|
+
{
|
|
431
|
+
method: "PUT",
|
|
432
|
+
headers: { "Content-Type": "application/json" },
|
|
433
|
+
body: JSON.stringify(input)
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
if (!response.ok) {
|
|
437
|
+
await throwFromResponse(response, "Failed to set workspace agent model set");
|
|
438
|
+
}
|
|
439
|
+
return await response.json();
|
|
366
440
|
}
|
|
367
441
|
};
|
|
368
442
|
}
|
|
@@ -375,76 +449,33 @@ var SessionCommandError = class extends Error {
|
|
|
375
449
|
this.name = "SessionCommandError";
|
|
376
450
|
}
|
|
377
451
|
};
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
recentModels: []
|
|
382
|
-
};
|
|
383
|
-
var EMPTY_THINKING_COMPLETION = {
|
|
384
|
-
modelIdentity: "",
|
|
385
|
-
canDisable: false,
|
|
386
|
-
options: []
|
|
387
|
-
};
|
|
388
|
-
function toModelCompletion(result) {
|
|
389
|
-
if (typeof result !== "object" || result === null || Array.isArray(result)) {
|
|
390
|
-
return EMPTY_MODEL_COMPLETION;
|
|
391
|
-
}
|
|
452
|
+
function toSlashCommandCompletion(result, requestedName, requestedArgumentsText) {
|
|
453
|
+
const empty = { name: requestedName, argumentsText: requestedArgumentsText, items: [] };
|
|
454
|
+
if (typeof result !== "object" || result === null || Array.isArray(result)) return empty;
|
|
392
455
|
const record = result;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (typeof record.perProvider === "object" && record.perProvider !== null) {
|
|
396
|
-
for (const [provider, models] of Object.entries(
|
|
397
|
-
record.perProvider
|
|
398
|
-
)) {
|
|
399
|
-
if (!Array.isArray(models)) continue;
|
|
400
|
-
perProvider[provider] = models.flatMap((entry) => {
|
|
401
|
-
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return [];
|
|
402
|
-
const id = entry.id;
|
|
403
|
-
if (typeof id !== "string") return [];
|
|
404
|
-
const name = entry.name;
|
|
405
|
-
return [typeof name === "string" ? { id, name } : { id }];
|
|
406
|
-
});
|
|
407
|
-
}
|
|
456
|
+
if (record.name !== requestedName || record.argumentsText !== requestedArgumentsText || !Array.isArray(record.items)) {
|
|
457
|
+
return empty;
|
|
408
458
|
}
|
|
409
|
-
const
|
|
459
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
460
|
+
const items = record.items.flatMap((entry) => {
|
|
410
461
|
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return [];
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
}
|
|
417
|
-
function optionalString(record, key) {
|
|
418
|
-
const value = record[key];
|
|
419
|
-
return typeof value === "string" ? value : void 0;
|
|
420
|
-
}
|
|
421
|
-
function toThinkingCompletion(result) {
|
|
422
|
-
if (typeof result !== "object" || result === null || Array.isArray(result)) {
|
|
423
|
-
return EMPTY_THINKING_COMPLETION;
|
|
424
|
-
}
|
|
425
|
-
const record = result;
|
|
426
|
-
if (typeof record.modelIdentity !== "string" || typeof record.canDisable !== "boolean" || !Array.isArray(record.options)) {
|
|
427
|
-
return EMPTY_THINKING_COMPLETION;
|
|
428
|
-
}
|
|
429
|
-
const options = record.options.flatMap((entry) => {
|
|
430
|
-
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return [];
|
|
431
|
-
const option = entry;
|
|
432
|
-
if (typeof option.id !== "string" || option.id.length === 0) return [];
|
|
462
|
+
const item = entry;
|
|
463
|
+
if (typeof item.id !== "string" || item.id.length === 0 || seenIds.has(item.id) || typeof item.label !== "string" || item.label.length === 0 || item.action !== "continue" && item.action !== "submit") {
|
|
464
|
+
return [];
|
|
465
|
+
}
|
|
466
|
+
seenIds.add(item.id);
|
|
433
467
|
return [
|
|
434
|
-
|
|
468
|
+
{
|
|
469
|
+
id: item.id,
|
|
470
|
+
label: item.label,
|
|
471
|
+
action: item.action,
|
|
472
|
+
...typeof item.submitValue === "string" ? { submitValue: item.submitValue } : {},
|
|
473
|
+
...typeof item.description === "string" ? { description: item.description } : {},
|
|
474
|
+
...typeof item.group === "string" && item.group.length > 0 ? { group: item.group } : {}
|
|
475
|
+
}
|
|
435
476
|
];
|
|
436
477
|
});
|
|
437
|
-
|
|
438
|
-
const defaultOption = optionalString(record, "defaultOption");
|
|
439
|
-
const selectedOption = optionalString(record, "selectedOption");
|
|
440
|
-
return {
|
|
441
|
-
modelIdentity: record.modelIdentity,
|
|
442
|
-
...effectiveOption !== void 0 ? { effectiveOption } : {},
|
|
443
|
-
...defaultOption !== void 0 ? { defaultOption } : {},
|
|
444
|
-
...selectedOption !== void 0 ? { selectedOption } : {},
|
|
445
|
-
canDisable: record.canDisable,
|
|
446
|
-
options
|
|
447
|
-
};
|
|
478
|
+
return { name: requestedName, argumentsText: requestedArgumentsText, items };
|
|
448
479
|
}
|
|
449
480
|
function toPersistBashPermissionResult(result) {
|
|
450
481
|
if (typeof result !== "object" || result === null || Array.isArray(result)) {
|
|
@@ -473,6 +504,16 @@ function toPersistBashPermissionResult(result) {
|
|
|
473
504
|
fieldErrors
|
|
474
505
|
};
|
|
475
506
|
}
|
|
507
|
+
function toMemoryRemovalResult(result) {
|
|
508
|
+
if (typeof result !== "object" || result === null || Array.isArray(result)) {
|
|
509
|
+
throw new SessionCommandError("invalid-result", "Invalid memory removal response.");
|
|
510
|
+
}
|
|
511
|
+
const record = result;
|
|
512
|
+
if (typeof record.removed !== "boolean" || typeof record.slug !== "string") {
|
|
513
|
+
throw new SessionCommandError("invalid-result", "Invalid memory removal response.");
|
|
514
|
+
}
|
|
515
|
+
return { removed: record.removed, slug: record.slug };
|
|
516
|
+
}
|
|
476
517
|
function createSessionClient(transport) {
|
|
477
518
|
let state = createSessionViewState();
|
|
478
519
|
let seq = 0;
|
|
@@ -642,11 +683,13 @@ function createSessionClient(transport) {
|
|
|
642
683
|
(result) => Array.isArray(result) ? result.filter((entry) => typeof entry === "string") : []
|
|
643
684
|
);
|
|
644
685
|
},
|
|
645
|
-
|
|
646
|
-
return sendCommand((id) => ({
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
686
|
+
completeSlashCommand(name, argumentsText) {
|
|
687
|
+
return sendCommand((id) => ({
|
|
688
|
+
id,
|
|
689
|
+
type: "complete-slash-command",
|
|
690
|
+
name,
|
|
691
|
+
argumentsText
|
|
692
|
+
})).then((result) => toSlashCommandCompletion(result, name, argumentsText));
|
|
650
693
|
},
|
|
651
694
|
setConfig(patches) {
|
|
652
695
|
return sendCommand((id) => ({ id, type: "set-config", patches })).then(
|
|
@@ -683,15 +726,67 @@ function createSessionClient(transport) {
|
|
|
683
726
|
(result) => Array.isArray(result) ? result : []
|
|
684
727
|
);
|
|
685
728
|
},
|
|
729
|
+
listWorkspaceMemories() {
|
|
730
|
+
return sendCommand((id) => ({ id, type: "list-workspace-memories" })).then(
|
|
731
|
+
(result) => Array.isArray(result) ? result : []
|
|
732
|
+
);
|
|
733
|
+
},
|
|
734
|
+
getWorkspaceMemory(slug) {
|
|
735
|
+
return sendCommand((id) => ({ id, type: "get-workspace-memory", memorySlug: slug })).then(
|
|
736
|
+
(result) => result
|
|
737
|
+
);
|
|
738
|
+
},
|
|
739
|
+
removeWorkspaceMemory(slug) {
|
|
740
|
+
return sendCommand((id) => ({ id, type: "remove-workspace-memory", memorySlug: slug })).then(
|
|
741
|
+
toMemoryRemovalResult
|
|
742
|
+
);
|
|
743
|
+
},
|
|
744
|
+
listConsolidateProposals() {
|
|
745
|
+
return sendCommand((id) => ({ id, type: "list-consolidate-proposals" })).then(
|
|
746
|
+
(result) => Array.isArray(result) ? result : []
|
|
747
|
+
);
|
|
748
|
+
},
|
|
749
|
+
decideConsolidateProposal(proposalId, decision, selectedOperationIds) {
|
|
750
|
+
return sendCommand((id) => ({
|
|
751
|
+
id,
|
|
752
|
+
type: "decide-consolidate-proposal",
|
|
753
|
+
proposalId,
|
|
754
|
+
decision,
|
|
755
|
+
...decision === "approve" && selectedOperationIds !== void 0 ? { selectedOperationIds: [...selectedOperationIds] } : {}
|
|
756
|
+
})).then((result) => result);
|
|
757
|
+
},
|
|
758
|
+
getConsolidateProposal(proposalId) {
|
|
759
|
+
return sendCommand((id) => ({
|
|
760
|
+
id,
|
|
761
|
+
type: "get-consolidate-proposal",
|
|
762
|
+
proposalId
|
|
763
|
+
})).then((result) => result);
|
|
764
|
+
},
|
|
765
|
+
listExtracts() {
|
|
766
|
+
return sendCommand((id) => ({ id, type: "list-extracts" })).then(
|
|
767
|
+
(result) => Array.isArray(result) ? result : []
|
|
768
|
+
);
|
|
769
|
+
},
|
|
770
|
+
runConsolidate() {
|
|
771
|
+
return sendCommand((id) => ({ id, type: "run-consolidate" })).then(
|
|
772
|
+
(result) => result
|
|
773
|
+
);
|
|
774
|
+
},
|
|
775
|
+
runConsolidateInteractive() {
|
|
776
|
+
return sendCommand((id) => ({ id, type: "run-consolidate-interactive" })).then(
|
|
777
|
+
(result) => result
|
|
778
|
+
);
|
|
779
|
+
},
|
|
686
780
|
capabilities() {
|
|
687
781
|
return transport.capabilities?.() ?? [];
|
|
688
782
|
},
|
|
689
|
-
completeProviderAuth(credential) {
|
|
783
|
+
completeProviderAuth(credential, name) {
|
|
690
784
|
return sendCommand((id) => ({
|
|
691
785
|
id,
|
|
692
786
|
type: "complete-provider-auth",
|
|
693
787
|
providerId: "openai-codex",
|
|
694
|
-
credential
|
|
788
|
+
credential,
|
|
789
|
+
...name !== void 0 ? { name } : {}
|
|
695
790
|
})).then(() => {
|
|
696
791
|
});
|
|
697
792
|
},
|
|
@@ -1052,7 +1147,13 @@ function bindDaemonDataClient(client, daemonId) {
|
|
|
1052
1147
|
setDefaultProvider: (providerId, opts) => client.setDefaultProvider(daemonId, providerId, opts),
|
|
1053
1148
|
setProviderAuth: (providerId, credential, opts) => client.setProviderAuth(daemonId, providerId, credential, opts),
|
|
1054
1149
|
clearProviderAuth: (providerId, opts) => client.clearProviderAuth(daemonId, providerId, opts),
|
|
1055
|
-
updateWorkspace: (name, patch) => client.updateWorkspace(daemonId, name, patch)
|
|
1150
|
+
updateWorkspace: (name, patch) => client.updateWorkspace(daemonId, name, patch),
|
|
1151
|
+
listAgentModelSets: (input) => client.listAgentModelSets(daemonId, input),
|
|
1152
|
+
createAgentModelSet: (input) => client.createAgentModelSet(daemonId, input),
|
|
1153
|
+
replaceAgentModelSet: (input) => client.replaceAgentModelSet(daemonId, input),
|
|
1154
|
+
deleteAgentModelSet: (input) => client.deleteAgentModelSet(daemonId, input),
|
|
1155
|
+
setDefaultAgentModelSet: (input) => client.setDefaultAgentModelSet(daemonId, input),
|
|
1156
|
+
setWorkspaceAgentModelSet: (input) => client.setWorkspaceAgentModelSet(daemonId, input)
|
|
1056
1157
|
};
|
|
1057
1158
|
}
|
|
1058
1159
|
function createDaemonClient(target, deps = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentInput, AskUserAnswers } from "@nuvin/agent-core/shared";
|
|
2
|
-
import type { AgentCatalogEntry, AgentDetail, ChatGptCredentialInput, CommandDetail, ConfigPatch, CustomProviderInput, GrantCapability, McpAction, McpActionResult, McpServerInfo,
|
|
2
|
+
import type { AgentCatalogEntry, AgentDetail, ChatGptCredentialInput, CommandDetail, ConfigPatch, ConsolidateProposalDetail, ConsolidateProposalSummary, ConsolidateRunOutcome, CustomProviderInput, GrantCapability, McpAction, McpActionResult, McpServerInfo, MemoryExtractSummary, PersistBashPermissionRequest, PersistBashPermissionResult, ServerEvent, SessionViewState, SetConfigResult, SkillCatalogEntry, SkillDetail, SlashCommandCompletion, SlashCommandDescriptor, WorkspaceMemoryDetail, WorkspaceMemorySummary } from "../protocol/types.ts";
|
|
3
3
|
import type { ClientTransport } from "./transport.ts";
|
|
4
4
|
export type ClientSubmitOptions = {
|
|
5
5
|
displayText: string;
|
|
@@ -48,13 +48,12 @@ export interface SessionClient {
|
|
|
48
48
|
*/
|
|
49
49
|
completePath(prefix: string): Promise<string[]>;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
* through the host's `complete-
|
|
53
|
-
* completion when no host is attached / the daemon is
|
|
51
|
+
* Request argument candidates for one built-in slash command. Round-trips
|
|
52
|
+
* through the host's `complete-slash-command` handler; resolves with a
|
|
53
|
+
* correlated empty completion when no host is attached / the daemon is
|
|
54
|
+
* unsupported. The runtime keeps items read-only — selection happens here.
|
|
54
55
|
*/
|
|
55
|
-
|
|
56
|
-
/** Fetch model-specific `/thinking` options from the attached runtime. */
|
|
57
|
-
completeThinking(): Promise<ThinkingCompletion>;
|
|
56
|
+
completeSlashCommand(name: string, argumentsText: string): Promise<SlashCommandCompletion>;
|
|
58
57
|
/**
|
|
59
58
|
* Restricted config write (spec: Ctrl+P config panel §Writes). Sends the batch
|
|
60
59
|
* to the attached host, which allowlists/validates/writes each patch and
|
|
@@ -76,6 +75,38 @@ export interface SessionClient {
|
|
|
76
75
|
getCommand(name: string): Promise<CommandDetail>;
|
|
77
76
|
/** MCP servers with live status + per-server tools for the MCP tab. */
|
|
78
77
|
listMcpServers(): Promise<McpServerInfo[]>;
|
|
78
|
+
/** Committed workspace memories for the Memory tab. */
|
|
79
|
+
listWorkspaceMemories(): Promise<WorkspaceMemorySummary[]>;
|
|
80
|
+
/** Lazy-load one committed memory's full content for the Memory tab. */
|
|
81
|
+
getWorkspaceMemory(slug: string): Promise<WorkspaceMemoryDetail>;
|
|
82
|
+
/** Delete one committed workspace memory. */
|
|
83
|
+
removeWorkspaceMemory(slug: string): Promise<{
|
|
84
|
+
removed: boolean;
|
|
85
|
+
slug: string;
|
|
86
|
+
}>;
|
|
87
|
+
/** Consolidate proposals awaiting review for this session workspace. */
|
|
88
|
+
listConsolidateProposals(): Promise<ConsolidateProposalSummary[]>;
|
|
89
|
+
/** Approve or reject one consolidate proposal. */
|
|
90
|
+
decideConsolidateProposal(proposalId: string, decision: "approve" | "reject", selectedOperationIds?: readonly string[]): Promise<{
|
|
91
|
+
status: string;
|
|
92
|
+
id?: string;
|
|
93
|
+
error?: string;
|
|
94
|
+
}>;
|
|
95
|
+
/** One consolidate proposal's ops for the Memory-tab detail pane. */
|
|
96
|
+
getConsolidateProposal(proposalId: string): Promise<ConsolidateProposalDetail>;
|
|
97
|
+
/** Extract records (read-only) for the Memory-tab Extracts browser. */
|
|
98
|
+
listExtracts(): Promise<MemoryExtractSummary[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Run consolidation for this session workspace. The daemon enqueues a
|
|
101
|
+
* coordinator-owned run and acks once the job leaves queued/running; resolves
|
|
102
|
+
* with the {@link ConsolidateRunOutcome}.
|
|
103
|
+
*/
|
|
104
|
+
runConsolidate(): Promise<ConsolidateRunOutcome>;
|
|
105
|
+
/**
|
|
106
|
+
* Run consolidation as an attached foreground turn of this session. The ack
|
|
107
|
+
* carries the same {@link ConsolidateRunOutcome} shape as `runConsolidate`.
|
|
108
|
+
*/
|
|
109
|
+
runConsolidateInteractive(): Promise<ConsolidateRunOutcome>;
|
|
79
110
|
/**
|
|
80
111
|
* Effective grant capabilities from the transport's latest welcome (UI hint).
|
|
81
112
|
* Empty when the transport does not expose capabilities.
|
|
@@ -83,9 +114,10 @@ export interface SessionClient {
|
|
|
83
114
|
capabilities(): readonly GrantCapability[];
|
|
84
115
|
/**
|
|
85
116
|
* Complete ChatGPT/Codex device-code login. Provider id is locked to
|
|
86
|
-
* `openai-codex`; callers cannot select another.
|
|
117
|
+
* `openai-codex`; callers cannot select another. `name` is an optional alias
|
|
118
|
+
* entry name (defaults to the canonical provider id). Resolves on the ack.
|
|
87
119
|
*/
|
|
88
|
-
completeProviderAuth(credential: ChatGptCredentialInput): Promise<void>;
|
|
120
|
+
completeProviderAuth(credential: ChatGptCredentialInput, name?: string): Promise<void>;
|
|
89
121
|
/**
|
|
90
122
|
* Register a custom provider (base URL + API key + surface) on the attached
|
|
91
123
|
* host. Sends `add-custom-provider` and resolves on the ack.
|