eve 0.60.0 → 0.61.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/CHANGELOG.md +20 -0
- package/dist/src/chunks/{use-eve-agent-Dmc6sX4d.js → use-eve-agent-C5-yqRuq.js} +177 -85
- package/dist/src/chunks/{use-eve-agent-jSR8P4nK.js → use-eve-agent-CVWk5KKy.js} +177 -85
- package/dist/src/cli/agent-command.js +1 -1
- package/dist/src/cli/dev/local-server-child.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/client/client.d.ts +3 -1
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/eve-agent-projection.d.ts +1 -0
- package/dist/src/client/eve-agent-projection.js +1 -1
- package/dist/src/client/eve-agent-store-helpers.js +1 -1
- package/dist/src/client/eve-agent-store-state.d.ts +4 -1
- package/dist/src/client/eve-agent-store.js +1 -1
- package/dist/src/client/message-reducer.js +1 -1
- package/dist/src/client/message-response.d.ts +5 -0
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/optimistic-message-submissions.d.ts +22 -0
- package/dist/src/client/optimistic-message-submissions.js +1 -0
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +6 -6
- package/dist/src/compiled/@workflow/core/index.js +1 -1
- package/dist/src/compiled/@workflow/core/log-format.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +5 -3
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/types.d.ts +22 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/runs.d.ts +12 -1
- package/dist/src/compiled/@workflow/world-local/index.js +3 -3
- package/dist/src/compiled/@workflow/world-vercel/index.js +7 -7
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-3SKHZsSX.js → attribute-changes-A6HfMNG3.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{dist-DearXsdS.js → dist-D38gP7YF.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/frames-QcJfYHmh.js +3 -0
- package/dist/src/compiled/_chunks/workflow/helpers-6kObVbfS.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{logger-CxBCNokg.js → logger-NN5YHpYy.js} +6 -5
- package/dist/src/compiled/_chunks/workflow/{resume-hook-B7_MC7FC.js → resume-hook-CAqlhwic.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{run-jGFog1uQ.js → run-DJevv8zz.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{serialization-VRHEKI6l.js → serialization-C5KgPESk.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/sleep-CbUwdv6O.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{wait-until-DDJySKt-.js → wait-until-BMY_tOr-.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{ws-transport-CEFNBXPC.js → ws-transport-DSDcKH08.js} +1 -1
- package/dist/src/compiler/default-tool-policy.js +1 -1
- package/dist/src/compiler/extension-compatibility.d.ts +18 -18
- package/dist/src/compiler/extension-compatibility.js +1 -1
- package/dist/src/compiler/manifest.d.ts +5 -2
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-tool.js +1 -1
- package/dist/src/compiler/project-sources.js +1 -1
- package/dist/src/compiler/validate-artifact.js +1 -1
- package/dist/src/context/build-dynamic-tools.js +1 -1
- package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
- package/dist/src/context/dynamic-tool-metadata.d.ts +1 -0
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/coordination-dispatch-shared.d.ts +2 -0
- package/dist/src/execution/coordination-dispatch-shared.js +1 -1
- package/dist/src/execution/coordination-dispatch-step.js +1 -1
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.d.ts +5 -0
- package/dist/src/execution/tools/agent-router-workflow.js +1 -0
- package/dist/src/execution/tools/agent-router.d.ts +9 -0
- package/dist/src/execution/tools/agent-router.js +1 -0
- package/dist/src/execution/tools/sleep-workflow.js +1 -1
- package/dist/src/execution/tools/subagent/metadata.d.ts +4 -0
- package/dist/src/execution/tools/subagent/metadata.js +1 -0
- package/dist/src/execution/tools/workflow/body.d.ts +3 -0
- package/dist/src/execution/tools/workflow/body.js +1 -1
- package/dist/src/execution/tools/workflow/start.d.ts +1 -0
- package/dist/src/execution/tools/workflow/start.js +1 -1
- package/dist/src/execution/tools/workflow/types.d.ts +2 -0
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +1 -0
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/authored-definition/schema-backed.js +1 -1
- package/dist/src/internal/authored-runtime-modules.js +1 -1
- package/dist/src/internal/nitro/dev-runtime-artifacts.d.ts +1 -0
- package/dist/src/internal/nitro/dev-runtime-artifacts.js +1 -1
- package/dist/src/internal/nitro/development-generation.js +1 -1
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/extension-distribution.js +1 -1
- package/dist/src/internal/nitro/host.js +1 -1
- package/dist/src/internal/node-esm-compat-banner.js +3 -3
- package/dist/src/internal/workflow-bundle/authored-workflow-directives.js +1 -1
- package/dist/src/internal/workflow-bundle/builder-support.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/builder-support.js +1 -1
- package/dist/src/internal/workflow-bundle/builder.js +1 -1
- package/dist/src/internal/workflow-bundle/nitro-step-entry.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/nitro-step-entry.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-directive-ast.d.ts +1 -0
- package/dist/src/internal/workflow-bundle/workflow-directive-ast.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-transformer.js +1 -1
- package/dist/src/protocol/message.d.ts +4 -0
- package/dist/src/protocol/message.js +1 -1
- package/dist/src/public/tools/agent-router.d.ts +1 -0
- package/dist/src/public/tools/agent-router.js +1 -0
- package/dist/src/public/tools/index.d.ts +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/resolve-tool.js +1 -1
- package/dist/src/runtime/tools/registry.js +1 -1
- package/dist/src/services/dev-client/agent-info-probe.d.ts +1 -0
- package/dist/src/services/dev-client/agent-info-probe.js +1 -1
- package/dist/src/setup/primitives/pm/pnpm.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/shared/map-concurrent.d.ts +2 -0
- package/dist/src/shared/map-concurrent.js +1 -0
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/tools/definition.d.ts +2 -0
- package/dist/src/tools/dynamic.d.ts +1 -0
- package/dist/src/tools/provided/agent-router.d.ts +7 -0
- package/dist/src/tools/provided/agent-router.js +1 -0
- package/dist/src/tools/workflow-definition.d.ts +6 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/concepts/sessions-runs-and-streaming.md +32 -32
- package/docs/guides/client/overview.mdx +2 -0
- package/docs/guides/evaluate.md +1 -1
- package/docs/guides/frontend/overview.mdx +7 -3
- package/docs/reference/typescript-api.md +3 -1
- package/docs/subagents/index.mdx +3 -3
- package/docs/tools/overview.mdx +17 -0
- package/docs/tools/workflows.mdx +99 -5
- package/package.json +12 -7
- package/dist/src/compiled/_chunks/workflow/frames-Bm_yZi8X.js +0 -3
- package/dist/src/compiled/_chunks/workflow/helpers-K7otPd_U.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-60eDbac6.js +0 -1
|
@@ -734,8 +734,10 @@ function isResultCompletedEvent(event) {
|
|
|
734
734
|
//#endregion
|
|
735
735
|
//#region src/client/message-response.ts
|
|
736
736
|
const consumeResponse = Symbol("consumeMessageResponse");
|
|
737
|
+
const acceptedDeliveryId = Symbol("acceptedDeliveryId");
|
|
737
738
|
var MessageResponse = class {
|
|
738
739
|
sessionId;
|
|
740
|
+
[acceptedDeliveryId];
|
|
739
741
|
#cancelTurn;
|
|
740
742
|
#cancellation;
|
|
741
743
|
#consumed = false;
|
|
@@ -745,6 +747,7 @@ var MessageResponse = class {
|
|
|
745
747
|
constructor(input) {
|
|
746
748
|
this.#cancelTurn = input.cancelTurn;
|
|
747
749
|
this.sessionId = input.sessionId;
|
|
750
|
+
this[acceptedDeliveryId] = input.deliveryId;
|
|
748
751
|
this.#createStream = input.createStream;
|
|
749
752
|
}
|
|
750
753
|
cancel() {
|
|
@@ -793,6 +796,9 @@ var MessageResponse = class {
|
|
|
793
796
|
}
|
|
794
797
|
}
|
|
795
798
|
};
|
|
799
|
+
function getMessageResponseDeliveryId(response) {
|
|
800
|
+
return response[acceptedDeliveryId];
|
|
801
|
+
}
|
|
796
802
|
function consumeMessageResponse(response, source) {
|
|
797
803
|
return response[consumeResponse](source);
|
|
798
804
|
}
|
|
@@ -1585,6 +1591,7 @@ var ClientSession = class ClientSession {
|
|
|
1585
1591
|
return new MessageResponse({
|
|
1586
1592
|
cancelTurn: async (turnId) => await this.cancel({ turnId }),
|
|
1587
1593
|
createStream: (source) => this.#createEventStream(initialStreamIndex, input, deliveryId, source),
|
|
1594
|
+
deliveryId,
|
|
1588
1595
|
sessionId: this.#state.sessionId
|
|
1589
1596
|
});
|
|
1590
1597
|
}
|
|
@@ -1801,8 +1808,8 @@ var Client = class {
|
|
|
1801
1808
|
}));
|
|
1802
1809
|
return result.data;
|
|
1803
1810
|
}
|
|
1804
|
-
async info() {
|
|
1805
|
-
const response = await this.fetch(EVE_INFO_ROUTE_PATH);
|
|
1811
|
+
async info(options = {}) {
|
|
1812
|
+
const response = await this.fetch(EVE_INFO_ROUTE_PATH, options);
|
|
1806
1813
|
if (!response.ok) {
|
|
1807
1814
|
const body = await response.text();
|
|
1808
1815
|
throw new ClientError(response.status, body, response.headers);
|
|
@@ -2009,6 +2016,10 @@ var EveAgentProjection = class {
|
|
|
2009
2016
|
this.#events = [...this.#events, event];
|
|
2010
2017
|
this.#data = this.#reducer.reduce(this.#data, event);
|
|
2011
2018
|
}
|
|
2019
|
+
remove(predicate) {
|
|
2020
|
+
this.#events = this.#events.filter((event) => !predicate(event));
|
|
2021
|
+
this.#data = this.#reduce();
|
|
2022
|
+
}
|
|
2012
2023
|
replace(predicate, replacement) {
|
|
2013
2024
|
const index = this.#events.findIndex(predicate);
|
|
2014
2025
|
this.#events = index === -1 ? [...this.#events, replacement] : this.#events.map((event, i) => i === index ? replacement : event);
|
|
@@ -2021,24 +2032,6 @@ var EveAgentProjection = class {
|
|
|
2021
2032
|
}
|
|
2022
2033
|
};
|
|
2023
2034
|
|
|
2024
|
-
//#endregion
|
|
2025
|
-
//#region src/protocol/event-dedupe.ts
|
|
2026
|
-
function createEventDeduper() {
|
|
2027
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2028
|
-
return {
|
|
2029
|
-
admit(event) {
|
|
2030
|
-
const id = event.meta?.id;
|
|
2031
|
-
if (id === void 0) return true;
|
|
2032
|
-
if (seen.has(id)) return false;
|
|
2033
|
-
seen.add(id);
|
|
2034
|
-
return true;
|
|
2035
|
-
},
|
|
2036
|
-
get size() {
|
|
2037
|
-
return seen.size;
|
|
2038
|
-
}
|
|
2039
|
-
};
|
|
2040
|
-
}
|
|
2041
|
-
|
|
2042
2035
|
//#endregion
|
|
2043
2036
|
//#region src/client/eve-agent-store-helpers.ts
|
|
2044
2037
|
function isSettledSessionTail(events) {
|
|
@@ -2089,7 +2082,7 @@ function createActiveTurn(cancel) {
|
|
|
2089
2082
|
completion: completion.promise,
|
|
2090
2083
|
followUpDispatches: /* @__PURE__ */ new Set(),
|
|
2091
2084
|
receivedFollowUps: 0,
|
|
2092
|
-
receivedFollowUpEvents: /* @__PURE__ */ new
|
|
2085
|
+
receivedFollowUpEvents: /* @__PURE__ */ new Map(),
|
|
2093
2086
|
followUpSubmissionIds: /* @__PURE__ */ new Set(),
|
|
2094
2087
|
resolveCompletion: completion.resolve,
|
|
2095
2088
|
response: response.promise,
|
|
@@ -2102,7 +2095,8 @@ async function followSteeredTurns(turn, events, isActive) {
|
|
|
2102
2095
|
if (turn.receivedFollowUps >= turn.acceptedFollowUps) return;
|
|
2103
2096
|
for await (const event of events) {
|
|
2104
2097
|
if (!isActive()) return;
|
|
2105
|
-
|
|
2098
|
+
turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
|
|
2099
|
+
turn.receivedFollowUpEvents.delete(event);
|
|
2106
2100
|
if (isCurrentTurnBoundaryEvent(event)) {
|
|
2107
2101
|
while (turn.followUpDispatches.size > 0) await Promise.allSettled(turn.followUpDispatches);
|
|
2108
2102
|
if (turn.receivedFollowUps >= turn.acceptedFollowUps) return;
|
|
@@ -2122,6 +2116,125 @@ async function waitWithSignal(promise, signal) {
|
|
|
2122
2116
|
}
|
|
2123
2117
|
}
|
|
2124
2118
|
|
|
2119
|
+
//#endregion
|
|
2120
|
+
//#region src/client/optimistic-message-submissions.ts
|
|
2121
|
+
var OptimisticMessageSubmissions = class {
|
|
2122
|
+
#optimistic;
|
|
2123
|
+
#projection;
|
|
2124
|
+
#pending = [];
|
|
2125
|
+
constructor(projection, optimistic) {
|
|
2126
|
+
this.#projection = projection;
|
|
2127
|
+
this.#optimistic = optimistic;
|
|
2128
|
+
}
|
|
2129
|
+
reset() {
|
|
2130
|
+
this.#pending = [];
|
|
2131
|
+
}
|
|
2132
|
+
submit(input, eventStartIndex) {
|
|
2133
|
+
if (input.message === void 0) return void 0;
|
|
2134
|
+
const pending = {
|
|
2135
|
+
createdAt: Date.now(),
|
|
2136
|
+
eventStartIndex,
|
|
2137
|
+
id: createSubmissionId(),
|
|
2138
|
+
message: summarizeUserContent(input.message),
|
|
2139
|
+
requiresDeliveryId: true
|
|
2140
|
+
};
|
|
2141
|
+
this.#pending = [...this.#pending, pending];
|
|
2142
|
+
if (this.#optimistic) this.#projection.append({
|
|
2143
|
+
data: {
|
|
2144
|
+
createdAt: pending.createdAt,
|
|
2145
|
+
message: pending.message,
|
|
2146
|
+
submissionId: pending.id
|
|
2147
|
+
},
|
|
2148
|
+
type: "client.message.submitted"
|
|
2149
|
+
});
|
|
2150
|
+
return pending.id;
|
|
2151
|
+
}
|
|
2152
|
+
apply(event) {
|
|
2153
|
+
if (event.type !== "message.received") {
|
|
2154
|
+
this.#projection.append(event);
|
|
2155
|
+
return;
|
|
2156
|
+
}
|
|
2157
|
+
if (event.data.kind === "execution.background_task") {
|
|
2158
|
+
this.#projection.append(event);
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
const matching = this.#matching(event);
|
|
2162
|
+
if (matching.length === 0) {
|
|
2163
|
+
this.#projection.append(event);
|
|
2164
|
+
return;
|
|
2165
|
+
}
|
|
2166
|
+
return this.#reconcile(matching, event, false);
|
|
2167
|
+
}
|
|
2168
|
+
correlate(submissionId, deliveryId, events) {
|
|
2169
|
+
if (submissionId === void 0) return void 0;
|
|
2170
|
+
this.#pending = this.#pending.map((pending) => pending.id === submissionId ? {
|
|
2171
|
+
...pending,
|
|
2172
|
+
deliveryId,
|
|
2173
|
+
requiresDeliveryId: deliveryId !== void 0
|
|
2174
|
+
} : pending);
|
|
2175
|
+
const pending = this.#pending.find((candidate) => candidate.id === submissionId);
|
|
2176
|
+
if (pending === void 0) return void 0;
|
|
2177
|
+
for (const event of events.slice(pending.eventStartIndex)) {
|
|
2178
|
+
if (event.type !== "message.received" || event.data.kind === "execution.background_task") continue;
|
|
2179
|
+
const matching = this.#matching(event);
|
|
2180
|
+
if (matching.some((candidate) => candidate.id === submissionId)) return this.#reconcile(matching, event, true);
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
fail(error, submissionId) {
|
|
2184
|
+
const pending = submissionId === void 0 ? this.#pending[0] : this.#pending.find((candidate) => candidate.id === submissionId);
|
|
2185
|
+
if (pending === void 0) return;
|
|
2186
|
+
this.#pending = this.#pending.filter((candidate) => candidate.id !== pending.id);
|
|
2187
|
+
this.#projection.replace((event) => event.type === "client.message.submitted" && event.data.submissionId === pending.id, {
|
|
2188
|
+
data: {
|
|
2189
|
+
createdAt: pending.createdAt,
|
|
2190
|
+
error: { message: error.message },
|
|
2191
|
+
message: pending.message,
|
|
2192
|
+
submissionId: pending.id
|
|
2193
|
+
},
|
|
2194
|
+
type: "client.message.failed"
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
failAll(error) {
|
|
2198
|
+
for (const pending of this.#pending) this.fail(error, pending.id);
|
|
2199
|
+
}
|
|
2200
|
+
#matching(event) {
|
|
2201
|
+
return this.#pending.filter((pending) => pending.deliveryId === void 0 ? !pending.requiresDeliveryId : event.meta.deliveryIds?.includes(pending.deliveryId) === true);
|
|
2202
|
+
}
|
|
2203
|
+
#reconcile(submissions, event, alreadyProjected) {
|
|
2204
|
+
const ids = submissions.map((pending) => pending.id);
|
|
2205
|
+
const idSet = new Set(ids);
|
|
2206
|
+
this.#pending = this.#pending.filter((pending) => !idSet.has(pending.id));
|
|
2207
|
+
if (alreadyProjected) this.#projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
|
|
2208
|
+
else {
|
|
2209
|
+
this.#projection.replace((candidate) => candidate.type === "client.message.submitted" && candidate.data.submissionId === ids[0], event);
|
|
2210
|
+
this.#projection.remove((candidate) => candidate.type === "client.message.submitted" && idSet.has(candidate.data.submissionId));
|
|
2211
|
+
}
|
|
2212
|
+
return {
|
|
2213
|
+
alreadyProjected,
|
|
2214
|
+
event,
|
|
2215
|
+
ids
|
|
2216
|
+
};
|
|
2217
|
+
}
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
//#endregion
|
|
2221
|
+
//#region src/protocol/event-dedupe.ts
|
|
2222
|
+
function createEventDeduper() {
|
|
2223
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2224
|
+
return {
|
|
2225
|
+
admit(event) {
|
|
2226
|
+
const id = event.meta?.id;
|
|
2227
|
+
if (id === void 0) return true;
|
|
2228
|
+
if (seen.has(id)) return false;
|
|
2229
|
+
seen.add(id);
|
|
2230
|
+
return true;
|
|
2231
|
+
},
|
|
2232
|
+
get size() {
|
|
2233
|
+
return seen.size;
|
|
2234
|
+
}
|
|
2235
|
+
};
|
|
2236
|
+
}
|
|
2237
|
+
|
|
2125
2238
|
//#endregion
|
|
2126
2239
|
//#region src/client/eve-agent-store.ts
|
|
2127
2240
|
const detachStore = Symbol("detachEveAgentStore");
|
|
@@ -2141,7 +2254,7 @@ var EveAgentStore = class {
|
|
|
2141
2254
|
#callbacks = {};
|
|
2142
2255
|
#error;
|
|
2143
2256
|
#events;
|
|
2144
|
-
#
|
|
2257
|
+
#messageSubmissions;
|
|
2145
2258
|
#prewarmGeneration = 0;
|
|
2146
2259
|
#prewarmPromise;
|
|
2147
2260
|
#prewarmController;
|
|
@@ -2165,6 +2278,7 @@ var EveAgentStore = class {
|
|
|
2165
2278
|
this.#events = initialEvents;
|
|
2166
2279
|
this.#projection = new EveAgentProjection(init.reducer, this.#events);
|
|
2167
2280
|
this.#optimistic = init.optimistic ?? true;
|
|
2281
|
+
this.#messageSubmissions = new OptimisticMessageSubmissions(this.#projection, this.#optimistic);
|
|
2168
2282
|
this.#session = init.session ?? (init.initialSession === void 0 ? void 0 : this.#client?.sessions.attach(init.initialSession.sessionId, { streamIndex: init.initialSession.streamIndex }));
|
|
2169
2283
|
this.#snapshot = this.#createSnapshot();
|
|
2170
2284
|
}
|
|
@@ -2239,7 +2353,7 @@ var EveAgentStore = class {
|
|
|
2239
2353
|
const preparedInput = await (prepareSend === void 0 ? input : waitWithSignal(Promise.resolve(prepareSend(input)), createAbortSignal(input.signal, turn.abortController.signal)));
|
|
2240
2354
|
assertExclusiveTurnInput(preparedInput);
|
|
2241
2355
|
if (!this.#isActiveTurn(turn)) return;
|
|
2242
|
-
this.#
|
|
2356
|
+
const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length);
|
|
2243
2357
|
this.#projectInputResponses(preparedInput);
|
|
2244
2358
|
this.#publish();
|
|
2245
2359
|
const turnInput = {
|
|
@@ -2251,9 +2365,11 @@ var EveAgentStore = class {
|
|
|
2251
2365
|
reader = dispatched.reader;
|
|
2252
2366
|
if (!this.#isActiveTurn(turn)) return;
|
|
2253
2367
|
turn.resolveResponse(response);
|
|
2368
|
+
if (this.#handleReconciliation(this.#messageSubmissions.correlate(submissionId, getMessageResponseDeliveryId(response), this.#events))) this.#publish();
|
|
2254
2369
|
for await (const event of consumeMessageResponse(response, reader)) {
|
|
2255
2370
|
if (!this.#isActiveTurn(turn)) return;
|
|
2256
|
-
|
|
2371
|
+
turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
|
|
2372
|
+
turn.receivedFollowUpEvents.delete(event);
|
|
2257
2373
|
}
|
|
2258
2374
|
if (!this.#isActiveTurn(turn)) return;
|
|
2259
2375
|
await followSteeredTurns(turn, reader, () => this.#isActiveTurn(turn));
|
|
@@ -2263,12 +2379,12 @@ var EveAgentStore = class {
|
|
|
2263
2379
|
if (!this.#isActiveTurn(turn)) return;
|
|
2264
2380
|
if (isAbortError(error)) {
|
|
2265
2381
|
this.#status = "ready";
|
|
2266
|
-
this.#
|
|
2382
|
+
this.#messageSubmissions.fail(toError(error));
|
|
2267
2383
|
} else {
|
|
2268
2384
|
const reported = this.#error !== void 0;
|
|
2269
2385
|
this.#error ??= toError(error);
|
|
2270
2386
|
this.#status = "error";
|
|
2271
|
-
this.#
|
|
2387
|
+
this.#messageSubmissions.fail(this.#error);
|
|
2272
2388
|
if (!reported) this.#callbacks.onError?.(this.#error);
|
|
2273
2389
|
}
|
|
2274
2390
|
} finally {
|
|
@@ -2312,7 +2428,8 @@ var EveAgentStore = class {
|
|
|
2312
2428
|
this.#publish();
|
|
2313
2429
|
for await (const event of reader) {
|
|
2314
2430
|
if (!this.#isActiveTurn(turn)) return;
|
|
2315
|
-
|
|
2431
|
+
turn.receivedFollowUps += turn.receivedFollowUpEvents.get(event) ?? 0;
|
|
2432
|
+
turn.receivedFollowUpEvents.delete(event);
|
|
2316
2433
|
if (isCurrentTurnBoundaryEvent(event) && this.#pendingAuthorizations.size === 0) break;
|
|
2317
2434
|
}
|
|
2318
2435
|
}
|
|
@@ -2361,7 +2478,7 @@ var EveAgentStore = class {
|
|
|
2361
2478
|
if (!this.#externalSession) this.#session = void 0;
|
|
2362
2479
|
this.#events = [];
|
|
2363
2480
|
this.#seenEvents = createEventDeduper();
|
|
2364
|
-
this.#
|
|
2481
|
+
this.#messageSubmissions.reset();
|
|
2365
2482
|
this.#projection.reset();
|
|
2366
2483
|
this.#error = void 0;
|
|
2367
2484
|
this.#status = "ready";
|
|
@@ -2378,7 +2495,7 @@ var EveAgentStore = class {
|
|
|
2378
2495
|
assertExclusiveTurnInput(preparedInput);
|
|
2379
2496
|
if (preparedInput.message === void 0 || preparedInput.turnPolicy !== "steer") throw new Error("An in-flight follow-up requires a message with turnPolicy: \"steer\".");
|
|
2380
2497
|
if (!this.#isActiveTurn(turn)) return await this.#submit(preparedInput);
|
|
2381
|
-
const submissionId = this.#
|
|
2498
|
+
const submissionId = this.#messageSubmissions.submit(preparedInput, this.#events.length);
|
|
2382
2499
|
if (submissionId !== void 0) turn.followUpSubmissionIds.add(submissionId);
|
|
2383
2500
|
this.#publish();
|
|
2384
2501
|
this.#ensureStream({
|
|
@@ -2392,14 +2509,15 @@ var EveAgentStore = class {
|
|
|
2392
2509
|
await waitWithSignal(turn.response, signal);
|
|
2393
2510
|
if (!this.#isActiveTurn(turn) || this.#session === void 0) throw new Error("The active eve turn ended before the follow-up could be sent.");
|
|
2394
2511
|
const { message, ...options } = preparedInput;
|
|
2395
|
-
await this.#session.send(message, {
|
|
2512
|
+
const response = await this.#session.send(message, {
|
|
2396
2513
|
...options,
|
|
2397
2514
|
signal
|
|
2398
2515
|
});
|
|
2399
2516
|
turn.acceptedFollowUps += 1;
|
|
2517
|
+
if (this.#handleReconciliation(this.#messageSubmissions.correlate(submissionId, getMessageResponseDeliveryId(response), this.#events))) this.#publish();
|
|
2400
2518
|
} catch (error) {
|
|
2401
2519
|
if (this.#isActiveTurn(turn)) {
|
|
2402
|
-
this.#
|
|
2520
|
+
this.#messageSubmissions.fail(toError(error), submissionId);
|
|
2403
2521
|
this.#publish();
|
|
2404
2522
|
}
|
|
2405
2523
|
throw error;
|
|
@@ -2503,25 +2621,6 @@ var EveAgentStore = class {
|
|
|
2503
2621
|
#isActiveTurn(turn) {
|
|
2504
2622
|
return this.#activeTurn === turn;
|
|
2505
2623
|
}
|
|
2506
|
-
#projectOptimisticMessage(input) {
|
|
2507
|
-
if (input.message === void 0) return;
|
|
2508
|
-
const id = createSubmissionId();
|
|
2509
|
-
const pending = {
|
|
2510
|
-
createdAt: Date.now(),
|
|
2511
|
-
id,
|
|
2512
|
-
message: summarizeUserContent(input.message)
|
|
2513
|
-
};
|
|
2514
|
-
this.#pendingMessageSubmissions = [...this.#pendingMessageSubmissions, pending];
|
|
2515
|
-
if (this.#optimistic) this.#projection.append({
|
|
2516
|
-
data: {
|
|
2517
|
-
createdAt: pending.createdAt,
|
|
2518
|
-
message: pending.message,
|
|
2519
|
-
submissionId: pending.id
|
|
2520
|
-
},
|
|
2521
|
-
type: "client.message.submitted"
|
|
2522
|
-
});
|
|
2523
|
-
return id;
|
|
2524
|
-
}
|
|
2525
2624
|
#projectInputResponses(input) {
|
|
2526
2625
|
if (input.inputResponses === void 0 || input.inputResponses.length === 0) return;
|
|
2527
2626
|
this.#projection.append({
|
|
@@ -2537,7 +2636,7 @@ var EveAgentStore = class {
|
|
|
2537
2636
|
const wasStreaming = this.#status === "streaming";
|
|
2538
2637
|
updatePendingAuthorizations(this.#pendingAuthorizations, event);
|
|
2539
2638
|
this.#events = [...this.#events, event];
|
|
2540
|
-
this.#
|
|
2639
|
+
this.#handleReconciliation(this.#messageSubmissions.apply(event));
|
|
2541
2640
|
this.#callbacks.onEvent?.(event);
|
|
2542
2641
|
this.#applyTerminalStreamFailure(event);
|
|
2543
2642
|
const settled = isCurrentTurnBoundaryEvent(event) && this.#pendingAuthorizations.size === 0;
|
|
@@ -2549,41 +2648,29 @@ var EveAgentStore = class {
|
|
|
2549
2648
|
this.#publish();
|
|
2550
2649
|
if (this.#activeTurn === void 0 && wasStreaming && settled) this.#callbacks.onFinish?.(this.#snapshot);
|
|
2551
2650
|
}
|
|
2552
|
-
#
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2651
|
+
#handleReconciliation(reconciliation) {
|
|
2652
|
+
if (reconciliation === void 0) return false;
|
|
2653
|
+
let followed = 0;
|
|
2654
|
+
for (const id of reconciliation.ids) if (this.#activeTurn?.followUpSubmissionIds.delete(id)) followed += 1;
|
|
2655
|
+
if (followed > 0 && this.#activeTurn !== void 0) {
|
|
2656
|
+
if (reconciliation.alreadyProjected) this.#activeTurn.receivedFollowUps += followed;
|
|
2657
|
+
else {
|
|
2658
|
+
const previous = this.#activeTurn.receivedFollowUpEvents.get(reconciliation.event) ?? 0;
|
|
2659
|
+
this.#activeTurn.receivedFollowUpEvents.set(reconciliation.event, previous + followed);
|
|
2660
|
+
}
|
|
2560
2661
|
}
|
|
2561
|
-
|
|
2662
|
+
return true;
|
|
2562
2663
|
}
|
|
2563
2664
|
#applyTerminalStreamFailure(event) {
|
|
2564
2665
|
const error = toTerminalStreamFailureError(event);
|
|
2565
2666
|
if (error === void 0) return;
|
|
2566
2667
|
this.#status = "error";
|
|
2567
|
-
this.#
|
|
2668
|
+
this.#messageSubmissions.failAll(error);
|
|
2568
2669
|
if (this.#error === void 0) {
|
|
2569
2670
|
this.#error = error;
|
|
2570
2671
|
this.#callbacks.onError?.(error);
|
|
2571
2672
|
}
|
|
2572
2673
|
}
|
|
2573
|
-
#failPendingMessageSubmission(error, submissionId) {
|
|
2574
|
-
const pending = submissionId === void 0 ? this.#pendingMessageSubmissions[0] : this.#pendingMessageSubmissions.find((candidate) => candidate.id === submissionId);
|
|
2575
|
-
if (pending === void 0) return;
|
|
2576
|
-
this.#pendingMessageSubmissions = this.#pendingMessageSubmissions.filter((candidate) => candidate.id !== pending.id);
|
|
2577
|
-
this.#projection.replace((event) => event.type === "client.message.submitted" && event.data.submissionId === pending.id, {
|
|
2578
|
-
data: {
|
|
2579
|
-
createdAt: pending.createdAt,
|
|
2580
|
-
error: { message: error.message },
|
|
2581
|
-
message: pending.message,
|
|
2582
|
-
submissionId: pending.id
|
|
2583
|
-
},
|
|
2584
|
-
type: "client.message.failed"
|
|
2585
|
-
});
|
|
2586
|
-
}
|
|
2587
2674
|
#createSnapshot() {
|
|
2588
2675
|
return {
|
|
2589
2676
|
data: this.#projection.data,
|
|
@@ -2856,6 +2943,9 @@ const messageRun = {
|
|
|
2856
2943
|
|
|
2857
2944
|
//#endregion
|
|
2858
2945
|
//#region src/client/message-reducer.ts
|
|
2946
|
+
function receivedMessageEventId(event) {
|
|
2947
|
+
return event.meta.id ?? `${event.data.turnId}:${event.data.sequence}`;
|
|
2948
|
+
}
|
|
2859
2949
|
function defaultMessageReducer() {
|
|
2860
2950
|
return {
|
|
2861
2951
|
initial() {
|
|
@@ -2902,15 +2992,17 @@ function reduceMessageData(data, event) {
|
|
|
2902
2992
|
for (const resolution of event.data.resolutions) next = resolveInputRequest(next, resolution);
|
|
2903
2993
|
return next;
|
|
2904
2994
|
}
|
|
2905
|
-
case "message.received":
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2995
|
+
case "message.received":
|
|
2996
|
+
if (event.data.kind === "execution.background_task") return data;
|
|
2997
|
+
return upsertMessage(data, {
|
|
2998
|
+
id: `${receivedMessageEventId(event)}:user`,
|
|
2999
|
+
metadata: {
|
|
3000
|
+
status: "complete",
|
|
3001
|
+
turnId: event.data.turnId
|
|
3002
|
+
},
|
|
3003
|
+
parts: projectReceivedParts(event.data.parts, event.data.message),
|
|
3004
|
+
role: "user"
|
|
3005
|
+
});
|
|
2914
3006
|
case "step.started": return updateAssistantMessage(data, event.data.turnId, (message) => ensureStepStartPart(message, event.data.stepIndex));
|
|
2915
3007
|
case "reasoning.appended": return updateAssistantMessage(data, event.data.turnId, (message) => messageRun.append(ensureStepStartPart(message, event.data.stepIndex), {
|
|
2916
3008
|
delta: event.data.reasoningDelta,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
async function selectWorkspaceAgent(e,t){let n=e.members.map(e=>e.name);if(t!==void 0){let r=e.members.find(e=>e.name===t);if(r===void 0)throw Error(`Unknown agent ${JSON.stringify(t)}. Available agents: ${n.join(`, `)}.`);return r.appRoot}if(e.members.length===1)return e.members[0].appRoot;if(!(process.stdin.isTTY&&process.stdout.isTTY))throw Error(`This command requires a specific agent. Pass --agent <name>. Available agents: ${n.join(`, `)}.`);let{createPrompter:r}=await import(`#setup/prompter.js`),i=await r().select({message:`Select an agent`,options:e.members.map(e=>({label:e.name,value:e.name})),search:e.members.length>8});return e.members.find(e=>e.name===i).appRoot}function agentCommand(e,t,n=()=>!0){return e.option(`--agent <name>`,`Select an agent from an agents/ workspace`),e.hook(`preAction`,async(e,r)=>{let i=r.opts().agent;if(!n(r)){if(i!==void 0)throw Error(`--agent cannot be combined with a remote URL target.`);return}let a=await t.resolveAgent();if(a.kind===`workspace`){t.root=await selectWorkspaceAgent(a.workspace,i),await t.resolve();return}await t.resolve()
|
|
1
|
+
async function selectWorkspaceAgent(e,t){let n=e.members.map(e=>e.name);if(t!==void 0){let r=e.members.find(e=>e.name===t);if(r===void 0)throw Error(`Unknown agent ${JSON.stringify(t)}. Available agents: ${n.join(`, `)}.`);return r.appRoot}if(e.members.length===1)return e.members[0].appRoot;if(!(process.stdin.isTTY&&process.stdout.isTTY))throw Error(`This command requires a specific agent. Pass --agent <name>. Available agents: ${n.join(`, `)}.`);let{createPrompter:r}=await import(`#setup/prompter.js`),i=await r().select({message:`Select an agent`,options:e.members.map(e=>({label:e.name,value:e.name})),search:e.members.length>8});return e.members.find(e=>e.name===i).appRoot}function agentCommand(e,t,n=()=>!0){return e.option(`--agent <name>`,`Select an agent from an agents/ workspace`),e.hook(`preAction`,async(e,r)=>{let i=r.opts().agent;if(!n(r)){if(i!==void 0)throw Error(`--agent cannot be combined with a remote URL target.`);return}let a=await t.resolveAgent();if(a.kind===`workspace`){t.root=await selectWorkspaceAgent(a.workspace,i),await t.resolve();return}if(await t.resolve(),i!==void 0&&(a.kind!==`workspace-member`||a.member.name!==i))throw Error(`--agent can only select a member of the enclosing agents/ workspace.`)})}export{agentCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createDevelopmentServer}from"#internal/nitro/host.js";import{getDevelopmentSandboxRunId}from"#execution/sandbox/development-run.js";import{reconcileCleanupIntents,recordCleanupIntent}from"#cli/dev/local-server-cleanup.js";const options=JSON.parse(process.argv[2]??`{}`),server=createDevelopmentServer(process.cwd(),{...options,onBootProgress:e=>send({type:`progress`,event:e})});let stopping=!1,removeCleanupIntent;reconcileCleanupIntents(process.cwd()).catch(()=>void 0);const send=e=>{try{process.connected&&process.send?.(e,()=>{})}catch{}},stop=()=>{if(stopping)return;stopping=!0,console.log=console.warn=console.error=()=>{},process.stdout.on(`error`,()=>{}),process.stderr.on(`error`,()=>{});let e=server.close();process.connected&&process.disconnect?.(),e.then(async()=>{await intentReady.catch(()=>void 0),await removeCleanupIntent?.().catch(()=>void 0),process.exit(0)},()=>process.exit(1))};process.on(`message`,e=>{e.type===`shutdown`&&stop()}),process.once(`disconnect`,stop),process.once(`SIGINT`,stop),process.once(`SIGTERM`,stop);const intentReady=server.start().then(async e=>{let t=getDevelopmentSandboxRunId();e.kind===`started`&&t!==void 0&&(removeCleanupIntent=await recordCleanupIntent(process.cwd(),{ownerPid:process.pid,runId:t})),send({type:`started`,handle:e}),e.kind===`existing`&&process.connected&&process.disconnect?.()},e=>{let t=e instanceof Error?e:Error(String(e));send({type:`failed`,message:t.message,stack:t.stack}),process.exitCode=1,process.connected&&process.disconnect?.()});export{};
|
|
1
|
+
import{createDevelopmentServer}from"#internal/nitro/host/start-development-server.js";import{getDevelopmentSandboxRunId}from"#execution/sandbox/development-run.js";import{reconcileCleanupIntents,recordCleanupIntent}from"#cli/dev/local-server-cleanup.js";const options=JSON.parse(process.argv[2]??`{}`),server=createDevelopmentServer(process.cwd(),{...options,onBootProgress:e=>send({type:`progress`,event:e})});let stopping=!1,removeCleanupIntent;reconcileCleanupIntents(process.cwd()).catch(()=>void 0);const send=e=>{try{process.connected&&process.send?.(e,()=>{})}catch{}},stop=()=>{if(stopping)return;stopping=!0,console.log=console.warn=console.error=()=>{},process.stdout.on(`error`,()=>{}),process.stderr.on(`error`,()=>{});let e=server.close();process.connected&&process.disconnect?.(),e.then(async()=>{await intentReady.catch(()=>void 0),await removeCleanupIntent?.().catch(()=>void 0),process.exit(0)},()=>process.exit(1))};process.on(`message`,e=>{e.type===`shutdown`&&stop()}),process.once(`disconnect`,stop),process.once(`SIGINT`,stop),process.once(`SIGTERM`,stop);const intentReady=server.start().then(async e=>{let t=getDevelopmentSandboxRunId();e.kind===`started`&&t!==void 0&&(removeCleanupIntent=await recordCleanupIntent(process.cwd(),{ownerPid:process.pid,runId:t})),send({type:`started`,handle:e}),e.kind===`existing`&&process.connected&&process.disconnect?.()},e=>{let t=e instanceof Error?e:Error(String(e));send({type:`failed`,message:t.message,stack:t.stack}),process.exitCode=1,process.connected&&process.disconnect?.()});export{};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{describeRemoteAuthCompletedMutations}from"./remote-auth-result.js";import{createRemoteConnectionController}from"./remote-connection.js";import{prepareRemoteTuiAccess}from"./remote-startup.js";import{SubagentPump}from"./subagent-pump.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import"#client/index.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{SteeringStream}from"#cli/dev/tui/steering-stream.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createEventDeduper}from"#protocol/event-dedupe.js";import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";async function delayMs(e){await new Promise(t=>{setTimeout(t,e).unref?.()})}async function abortableDelay(e,t){t.aborted||await new Promise(n=>{let r=setTimeout(done,e);r.unref?.(),t.addEventListener(`abort`,done,{once:!0});function done(){clearTimeout(r),t.removeEventListener(`abort`,done),n()}})}function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v=!1;#y;#b;#x=!0;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j=!1;#M=new AbortController;#N=!1;#P=0;#F=0;#I=[];#L;#R;#z;#B;#V;#H=new Map;#U;#W=[];#G;#K=!1;#q;#J=new Map;#Y=new Set;#X;#Z;#Q;constructor(e){this.#e=e.session,e.client!==void 0&&(this.#t=e.client),e.lifecycle!==void 0&&(this.#Q=e.lifecycle),this.#n=createRenderer(e);let t={formatActionResultError};if(this.#t!==void 0&&(t.client=this.#t),this.#n.subagents!==void 0&&(t.view=this.#n.subagents),e.appRoot!==void 0&&(t.onToolCompleted=async(e,t)=>{let n=registryHandoffAddress(e,t);n!==void 0&&this.#me(n)}),this.#q=new SubagentPump(t),this.#r=e.name??`eve`,this.#B=e.startup?.headerTip??pickAgentHeaderTip(),this.#w=e.withExclusiveTerminal,this.#i=e.tools??`full`,this.#a=e.reasoning??`full`,this.#o=e.subagents??`full`,this.#s=e.connectionAuth??`full`,this.#c=e.assistantResponseStats??`tokensPerSecond`,this.#l=e.contextSize,this.#u=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#m=e.initialInput),e.startup!==void 0&&(this.#h=e.startup),this.#_=e.onboard===!0,this.#y=e.onOnboardingStep,this.#b=e.onOnboardingTerminal,e.appRoot!==void 0){this.#p=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#R=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#z=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}if(e.promptCommandHandler!==void 0&&(this.#S=e.promptCommandHandler),this.#C=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0){if(this.#E=e.remote.runAuthFlow,this.#t===void 0)throw Error(`A remote TUI requires a configured development client.`);this.#T=createRemoteConnectionController({client:this.#t,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})}this.#D=e.bootDetections??BOOT_DETECTIONS,this.#O=e.getVercelAuthStatus??getVercelAuthStatus,this.#k=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#A=e.onBootProgress),e.serverUrl!==void 0&&(this.#f=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#d=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#$(){if(this.#f===void 0){this.#ne(),this.#_||await this.#ge(void 0);return}let e;if(this.#T!==void 0){let t=await this.#T.check();t.state===`ready`&&(e=t.info)}else{let t=this.#t;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t}),this.#A);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#ne();let t=this.#te(e);this.#_||await this.#ge(t)}#ee(){let e=this.#h?.finish();return this.#g=e?.queuedPrompt,e?.draft??this.#m}#te(e){let t=this.#p===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#V=t;let n=this.#f;if(n===void 0||this.#x)return t;let r={name:this.#r,serverUrl:n};return t!==void 0&&(r.info=t),this.#p!==void 0&&!this.#_&&(r.tip=this.#B),this.#n.renderAgentHeader?.(r),t}#ne(){let e=this.#A;this.#A=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#Q?.signal.aborted===!0?onStop():this.#Q?.signal.addEventListener(`abort`,onStop,{once:!0});try{await this.#re()}finally{this.#Q?.signal.removeEventListener(`abort`,onStop),this.#j=!0,this.#M.abort(),this.#q.abortAll(),this.#Z?.(),this.#Z=void 0,this.#n.shutdown?.(),this.#R?.dispose(),this.#z?.dispose(),this.#T?.dispose()}}async#re(){let e=this.#r,t,n,r=!1,i=!1,a=!1;this.#n.setStartupPhase?.(`starting`),await this.#$(),this.#be(),this.#R?.refreshIdentity(),this.#z?.refresh();let o=(this.#_||this.#V?.agent.model.endpoint?.kind===`gateway`&&!this.#V.agent.model.endpoint.connected)&&this.#p!==void 0&&this.#S!==void 0&&this.#n.setupFlow!==void 0,s;if(this.#T!==void 0&&this.#n.setupFlow!==void 0){let e=await prepareRemoteTuiAccess({connection:this.#T,renderer:this.#n.setupFlow,signal:this.#Q?.signal,runAuthFlow:this.#E});if(e?.kind===`authenticated`){let e=this.#T.current().connection;e.state===`ready`&&this.#te(e.info)}else e?.kind===`failed`||e?.kind===`unavailable`?s={tone:`error`,message:e.kind===`failed`?e.message:e.failure.message}:e?.kind===`cancelled`&&(s={cancelled:!0},e.completedMutations.length>0&&(s.message=`Completed before cancellation: ${describeRemoteAuthCompletedMutations(e.completedMutations).join(`, `)}.`))}o&&(this.#n.setStartupPhase?.(`connecting`),s=await this.#De(e));let c=this.#ee();for(s?.cancelled||s?.tone===`error`?c=[this.#g,c].filter(Boolean).join(`
|
|
1
|
+
import{PROMPT_COMMANDS,formatPromptCommandHelp,parsePromptCommand}from"./prompt-commands.js";import{pickAgentHeaderTip}from"./agent-header.js";import{failureKey,formatFailureDetail,formatFailureHint,formatFailureMessage,isInterruptedError,localFailureHint}from"./errors.js";import{parseLogDisplayMode}from"./log-display-mode.js";import{createMcpConnectionStatusTracker}from"./mcp-connection-status.js";import{describeRemoteAuthCompletedMutations}from"./remote-auth-result.js";import{createRemoteConnectionController}from"./remote-connection.js";import{prepareRemoteTuiAccess}from"./remote-startup.js";import{SubagentPump}from"./subagent-pump.js";import{BOOT_DETECTIONS,CLI_MISSING_SETUP_ISSUE,LOGIN_SETUP_ISSUE,detectSetupIssues,formatSetupIssuesLine,normalizeLocalModelEndpoint,orderedSetupIssues}from"./setup-issues.js";import{TerminalRenderer}from"./terminal-renderer.js";import{createVercelStatusTracker}from"./vercel-status.js";import"#client/index.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{inspectApplication}from"#services/inspect-application.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{toErrorMessage}from"#shared/errors.js";import{getVercelAuthStatus}from"#setup/vercel-project.js";import{probeAgentInfo}from"#services/dev-client/agent-info-probe.js";import{SteeringStream}from"#cli/dev/tui/steering-stream.js";import{renderApplicationInfo}from"#cli/commands/info.js";import{subscribeDevelopmentSandboxPrewarmLogs}from"#execution/sandbox/development-prewarm.js";import{createEventDeduper}from"#protocol/event-dedupe.js";import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{createDevelopmentRuntimeArtifactRefresher}from"#services/dev-client.js";async function delayMs(e){await new Promise(t=>{setTimeout(t,e).unref?.()})}async function abortableDelay(e,t){t.aborted||await new Promise(n=>{let r=setTimeout(done,e);r.unref?.(),t.addEventListener(`abort`,done,{once:!0});function done(){clearTimeout(r),t.removeEventListener(`abort`,done),n()}})}function authIssueForStatus(e){if(e===`logged-out`)return LOGIN_SETUP_ISSUE;if(e===`cli-missing`)return CLI_MISSING_SETUP_ISSUE}var EveTUIRunner=class{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v=!1;#y;#b;#x=!0;#S;#C;#w;#T;#E;#D;#O;#k;#A;#j=!1;#M=new AbortController;#N=!1;#P=0;#F=0;#I=[];#L;#R;#z;#B;#V;#H=new Map;#U;#W=[];#G;#K=!1;#q;#J=new Map;#Y=new Set;#X;#Z;#Q;constructor(e){this.#e=e.session,e.client!==void 0&&(this.#t=e.client),e.lifecycle!==void 0&&(this.#Q=e.lifecycle),this.#n=createRenderer(e);let t={formatActionResultError};if(this.#t!==void 0&&(t.client=this.#t),this.#n.subagents!==void 0&&(t.view=this.#n.subagents),e.appRoot!==void 0&&(t.onToolCompleted=async(e,t)=>{let n=registryHandoffAddress(e,t);n!==void 0&&this.#me(n)}),this.#q=new SubagentPump(t),this.#r=e.name??`eve`,this.#B=e.startup?.headerTip??pickAgentHeaderTip(),this.#w=e.withExclusiveTerminal,this.#i=e.tools??`full`,this.#a=e.reasoning??`full`,this.#o=e.subagents??`full`,this.#s=e.connectionAuth??`full`,this.#c=e.assistantResponseStats??`tokensPerSecond`,this.#l=e.contextSize,this.#u=e.formatTransportError??toErrorMessage,e.initialInput!==void 0&&(this.#m=e.initialInput),e.startup!==void 0&&(this.#h=e.startup),this.#_=e.onboard===!0,this.#y=e.onOnboardingStep,this.#b=e.onOnboardingTerminal,e.appRoot!==void 0){this.#p=e.appRoot;let t={appRoot:e.appRoot,onChange:e=>this.#n.setVercelStatus?.(e)};e.detectProjectIdentity!==void 0&&(t.detectIdentity=e.detectProjectIdentity),this.#R=createVercelStatusTracker(t),e.probeMcpConnection!==void 0&&(this.#z=createMcpConnectionStatusTracker({onChange:()=>{},probe:e.probeMcpConnection}))}if(e.promptCommandHandler!==void 0&&(this.#S=e.promptCommandHandler),this.#C=e.availablePromptCommands??PROMPT_COMMANDS,e.remote!==void 0){if(this.#E=e.remote.runAuthFlow,this.#t===void 0)throw Error(`A remote TUI requires a configured development client.`);this.#T=createRemoteConnectionController({client:this.#t,credentials:e.remote.credentials,target:e.remote.target,onChange:e=>this.#n.setRemoteConnectionStatus?.(e),resolveOidcToken:e.remote.resolveOidcToken,resolveDeployment:e.remote.resolveDeployment})}this.#D=e.bootDetections??BOOT_DETECTIONS,this.#O=e.getVercelAuthStatus??getVercelAuthStatus,this.#k=e.inspectApplication??inspectApplication,e.onBootProgress!==void 0&&(this.#A=e.onBootProgress),e.serverUrl!==void 0&&(this.#f=e.serverUrl),e.serverUrl!==void 0&&e.remote===void 0&&(this.#d=createDevelopmentRuntimeArtifactRefresher({serverUrl:e.serverUrl}))}async#$(){if(this.#f===void 0){this.#ne(),this.#_||await this.#ge(void 0);return}let e;if(this.#T!==void 0){let t=await this.#T.check();t.state===`ready`&&(e=t.info)}else{let t=this.#t;if(t!==void 0)try{let n=await devBootPhase(`connecting to agent`,()=>probeAgentInfo({client:t,timeoutMs:2e3}),this.#A);n.kind===`ready`&&(e=n.info)}catch{e=void 0}}this.#ne();let t=this.#te(e);this.#_||await this.#ge(t)}#ee(){let e=this.#h?.finish();return this.#g=e?.queuedPrompt,e?.draft??this.#m}#te(e){let t=this.#p===void 0?e:normalizeLocalModelEndpoint(e,process.env);this.#V=t;let n=this.#f;if(n===void 0||this.#x)return t;let r={name:this.#r,serverUrl:n};return t!==void 0&&(r.info=t),this.#p!==void 0&&!this.#_&&(r.tip=this.#B),this.#n.renderAgentHeader?.(r),t}#ne(){let e=this.#A;this.#A=void 0,e?.({type:`before-first-paint`})}async run(){let onStop=()=>this.#n.requestInterrupt?.();this.#Q?.signal.aborted===!0?onStop():this.#Q?.signal.addEventListener(`abort`,onStop,{once:!0});try{await this.#re()}finally{this.#Q?.signal.removeEventListener(`abort`,onStop),this.#j=!0,this.#M.abort(),this.#q.abortAll(),this.#Z?.(),this.#Z=void 0,this.#n.shutdown?.(),this.#R?.dispose(),this.#z?.dispose(),this.#T?.dispose()}}async#re(){let e=this.#r,t,n,r=!1,i=!1,a=!1;this.#n.setStartupPhase?.(`starting`),await this.#$(),this.#be(),this.#R?.refreshIdentity(),this.#z?.refresh();let o=(this.#_||this.#V?.agent.model.endpoint?.kind===`gateway`&&!this.#V.agent.model.endpoint.connected)&&this.#p!==void 0&&this.#S!==void 0&&this.#n.setupFlow!==void 0,s;if(this.#T!==void 0&&this.#n.setupFlow!==void 0){let e=await prepareRemoteTuiAccess({connection:this.#T,renderer:this.#n.setupFlow,signal:this.#Q?.signal,runAuthFlow:this.#E});if(e?.kind===`authenticated`){let e=this.#T.current().connection;e.state===`ready`&&this.#te(e.info)}else e?.kind===`failed`||e?.kind===`unavailable`?s={tone:`error`,message:e.kind===`failed`?e.message:e.failure.message}:e?.kind===`cancelled`&&(s={cancelled:!0},e.completedMutations.length>0&&(s.message=`Completed before cancellation: ${describeRemoteAuthCompletedMutations(e.completedMutations).join(`, `)}.`))}o&&(this.#n.setStartupPhase?.(`connecting`),s=await this.#De(e));let c=this.#ee();for(s?.cancelled||s?.tone===`error`?c=[this.#g,c].filter(Boolean).join(`
|
|
2
2
|
|
|
3
3
|
`)||void 0:t=this.#g,this.#x=!1,this.#te(this.#V),this.#_e(),this.#n.setStartupPhase?.(void 0),o&&this.#Ce({type:`extension`,name:`login`,argument:``},`startup`,s?.tone),this.#xe(s?.message,s?.tone);;){if(this.#Q?.signal.aborted===!0||this.#n.exitRequested?.()===!0)return;let o=this.#W[0];if(o!==void 0&&n===void 0&&this.#U===void 0){this.#W.shift(),this.#G=o;try{await this.#he(o)}finally{this.#G=void 0}i=!1,a=!1,t=void 0;continue}if(!a){if(t==null){if(!this.#n.readPrompt){if(r)return;throw Error(`No prompt was provided and the renderer does not support prompt input.`)}let n={title:e};c!==void 0&&(n.initialDraft=c,c=void 0);try{this.#K=!0,t=await this.#ce(n)}catch(e){if(isInterruptedError(e)){if(this.#U===void 0&&this.#W.length===0)return;a=!0,t=``}else throw e}finally{this.#K=!1}if(this.#W.length>0&&this.#U===void 0){t=void 0;continue}if(t==null&&this.#U===void 0)return}let o=this.#U===void 0?parsePromptCommand(t):null;if(o?.type===`exit`){this.#Q?.requestStop();return}if(o?.type===`cancel`){if(this.#e===void 0){this.#xe(`No active turn to cancel.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.cancel();if(this.#xe(e.status===`accepted`?`Turn cancellation requested.`:`No active turn to cancel.`),e.status===`no_active_turn`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#xe(`Couldn't cancel the turn: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(o?.type===`reset`){if(!await this.#oe()){n=void 0,a=!1,t=void 0;continue}n=void 0,a=!1,t=void 0;continue}if(o?.type===`compact`){if(this.#e===void 0){this.#xe(`No active session to compact.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.compact();if(this.#xe(e.status===`accepted`?`Compaction requested.`:`No active session to compact.`),e.status===`no_active_session`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#xe(`Couldn't compact the session: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(o?.type===`clear`){if(this.#e===void 0){this.#xe(`No active session to clear.`),n=void 0,i=!1,a=!1,t=void 0;continue}try{let e=await this.#e.clear();if(this.#xe(e.status===`accepted`?`Context clear requested.`:`No active session to clear.`),e.status===`no_active_session`){n=void 0,i=!1,a=!1,t=void 0;continue}}catch(e){this.#xe(`Couldn't clear the session: ${toErrorMessage(e)}`),n=void 0,i=!1,a=!1,t=void 0;continue}n=void 0,i=!0,a=!1,t=void 0}if(o?.type===`help`){this.#xe(formatPromptCommandHelp(this.#C)),n=void 0,a=!1,t=void 0;continue}if(o?.type===`info`){await this.#Ae(),n=void 0,a=!1,t=void 0;continue}if(o?.type===`loglevel`){this.#xe(this.#je(o.argument)),n=void 0,a=!1,t=void 0;continue}if(o?.type===`traces`){await this.#ke(o.argument),n=void 0,a=!1,t=void 0;continue}if(o?.type===`extension`){try{await this.#Ee(o,e,{trigger:`command`})}catch(e){if(isInterruptedError(e))return;throw e}n=void 0,t=void 0,a=!1;continue}r=!0}let s=this.#U;this.#U=void 0;let l=s??(i?this.#fe():await(async()=>(this.#ae(),await this.#ue({prompt:a?void 0:t,inputResponses:n})))()),u=this.#e?.state.sessionId;u!==void 0&&this.#n.setSessionId?.(u);let d=t,f=!1;try{for(;;){await this.#n.renderStream(l,{title:e,submittedPrompt:d,continueSession:!!this.#n.readPrompt,tools:this.#i,reasoning:this.#a,subagents:this.#o,connectionAuth:this.#s,assistantResponseStats:this.#c,contextSize:this.#l});let r=l.turnState?.pendingApprovals??[],i=l.turnState?.pendingQuestions??[];if(r.length>0||i.length>0){let o=[];if(r.length>0){if(!this.#n.readToolApproval)throw Error(`Tool approval was requested, but the renderer does not support tool approval input.`);for(let t of r){let n=await this.#n.readToolApproval(t,{title:e});o.push({requestId:t.approvalId,optionId:n.approved?`approve`:`cancel`}),this.#H.delete(t.approvalId)}}if(i.length>0){if(!this.#n.readInputQuestion)throw Error(`An interactive question was requested, but the renderer does not support input questions.`);for(let t of i){let n=toAgentTUIInputQuestion(t),r=await this.#n.readInputQuestion(n,{title:e});if(r===void 0)continue;let i={requestId:t.requestId};r.optionId!==void 0&&(i.optionId=r.optionId),r.text!==void 0&&(i.text=r.text),o.push(i),this.#H.delete(t.requestId)}}if(o.length===0)break;a=!0,n=o,t=void 0,f=!0;break}if(this.#Le(l)){l=this.#fe(),d=void 0;continue}if(l.turnState&&l.turnState.boundaryEvent===void 0&&!l.turnState.aborted){let e=this.#e?.state.sessionId;this.#n.renderNotice?.(e?`Lost the event stream — the turn may still be running on the server (session ${e}). Your next message resumes this session; use /cancel to stop the turn.`:`Lost the connection to the running turn.`)}break}}catch(e){if(isInterruptedError(e))return;throw e}if(f)continue;i=!1,a=!1,n=void 0,t=void 0;let p=l.turnState?.boundaryEvent;this.#X!==this.#e&&(p===`session.waiting`||p===`session.completed`)&&(t=this.#n.takeQueuedPrompt?.()),this.#ae(l.turnState?.aborted===!0)}}#ie(){this.#q.abortAll(),this.#H.clear(),this.#J.clear(),this.#Y.clear(),this.#n.setConnectionAuthPendingCount?.(0),this.#e=void 0,this.#d?.clear()}#ae(e=!1){let t=this.#X;t!==void 0&&(this.#X=void 0,this.#e===t&&(this.#ie(),e?this.#n.renderNotice?.(`Stopped following the turn and started a new session. Earlier context was cleared; the interrupted turn may still be running on the server.`):this.#n.renderSessionBoundary===void 0?this.#n.renderNotice?.(`Session ended — started a new session. Earlier context was cleared.`):this.#n.renderSessionBoundary()))}async#oe(){if(this.#e===void 0)return this.#ie(),this.#n.reset?.(),!0;try{await this.#e.reset()}catch(e){return this.#n.renderNotice?.(`Couldn't reset the session: ${toErrorMessage(e)}`),!1}return this.#ie(),this.#n.reset?.(),!0}async#se(e){if(!this.#n.readPrompt)return;let t=this.#n.readPrompt(e),n=this.#d;if(n===void 0)return await t;let r=!1,i=!1,a,o=0,refresh=async()=>{if(!(r||i)){i=!0;try{await n.refreshIdle({onRuntimeArtifactsChanged:()=>this.#Fe()});let e=this.#V?.agent.model.endpoint,t=e?.kind===`chatgpt`&&(e.state===`signed-out`||e.state===`reauth-required`),r=Date.now();t&&r-o>=5e3&&(o=r,this.#Ne())}finally{i=!1}}},startRefresh=()=>{if(r||i)return;let e=refresh().finally(()=>{a===e&&(a=void 0)});a=e};startRefresh();let s=setInterval(()=>{startRefresh()},500);s.unref?.();try{return await t}finally{r=!0,clearInterval(s),await a}}async#ce(e){let t=this.#se(e);if(this.#n.renderIdleStream===void 0||this.#e?.state.sessionId===void 0)return await t;let n=new AbortController,r=this.#le(n.signal,e).catch(e=>{n.signal.aborted||this.#n.renderNotice?.(`Stopped following session updates: ${toErrorMessage(e)}`)});try{return await t}finally{n.abort(),await r}}async#le(e,t){let n=this.#e;if(n===void 0)return;let r=100;for(;!e.aborted;){let i=n.stream({signal:e})[Symbol.asyncIterator](),a=!1;try{for(;!e.aborted;){let r=!1,o={async*[Symbol.asyncIterator](){for(;!e.aborted;){let e=await i.next();if(e.done===!0||(r=!0,a=!0,yield e.value,isCurrentTurnBoundaryEvent(e.value)))return}}},s=this.#pe(o,()=>{},n);if(await this.#n.renderIdleStream(s,{...t,continueSession:!0}),this.#Le(s),(s.turnState?.pendingApprovals.length??0)>0||(s.turnState?.pendingQuestions.length??0)>0){this.#U={events:(async function*(){})(),turnState:s.turnState},this.#n.suspendPromptForInput?.();return}if(s.turnState?.boundaryEvent===`session.completed`||s.turnState?.boundaryEvent===`session.failed`)return;if(!r)break}}finally{await i.return?.()}r=a?100:Math.min(r*2,2e3),e.aborted||await abortableDelay(r,e)}}async#ue(e){let t=new AbortController,n={signal:t.signal};e.prompt!==void 0&&(n.message=e.prompt),e.inputResponses!==void 0&&e.inputResponses.length>0&&(n.inputResponses=e.inputResponses);let r,i=this.#e;try{if(this.#d!==void 0&&await this.#d.refresh({inputResponses:n.inputResponses,message:n.message,onRuntimeArtifactsChanged:()=>this.#Fe()}),n.message!==void 0&&(n.inputResponses?.length??0)===0&&this.#n.flushDelayedDevBuildErrors?.(),this.#e===void 0){if(this.#t===void 0)throw Error(`Cannot create a session without an eve client.`);if(n.message===void 0)throw Error(`Cannot answer an input request before the session starts.`);let e=await this.#t.sessions.create({...n,message:n.message});this.#e=e.session,r=e.response}else r=n.inputResponses===void 0?await this.#e.send(n.message,{signal:n.signal,turnPolicy:`queue`}):await this.#e.respond(n.inputResponses,{signal:n.signal})}catch(e){if(isInterruptedError(e))throw e;return this.#T?.reportFailure(e),this.#X=i,{events:errorOnlyTUIStream({errorText:this.#u(e)}),turnState:createTurnState()}}return this.#pe(r,()=>t.abort(),this.#e)}async#de(e,t){if(e.cancelInFlight!==!0){e.cancelInFlight=!0;try{for(let n=0;n<8;n+=1){if(e.boundaryEvent!==void 0||e.aborted===!0)return;let n=e.turnId;try{if((await t?.cancel(n===void 0?void 0:{turnId:n}))?.status===`accepted`)return}catch{}await delayMs(250)}}finally{e.cancelInFlight=!1}}}#fe(){if(this.#e===void 0)throw Error(`Cannot stream a session before its first turn is accepted.`);let e=new AbortController,t=this.#e;return this.#pe(t.stream({signal:e.signal}),()=>e.abort(),t)}#pe(e,t,n){let r=createTurnState(),i=n===void 0?void 0:new SteeringStream(e,n);return{steer:i===void 0?void 0:e=>i.send(e),abort:()=>{r.aborted=!0,this.#X=n,i?.abort(),t()},cancel:()=>{this.#de(r,n)},events:eveEventsToTUIStream({onAssistantResponse:()=>{this.#_&&!this.#v&&(this.#v=!0,this.#y?.({flow:`onboarding`,step:`first_response`}))},events:i??e,pendingInputRequests:this.#H,turnState:r,onSubagentCalled:e=>this.#q.begin(e),onSubagentBackgrounded:e=>this.#q.background(e),onSubagentCompleted:e=>this.#q.settle(e),onTurnCancelled:e=>this.#q.settleCancelledTurn(e),onConnectionAuthRequired:e=>this.#Ie(e),onConnectionAuthCompleted:e=>this.#Re(e),onRegistryHandoff:this.#p===void 0?void 0:async e=>this.#me(e),onTerminalFailure:()=>{this.#X=n},failureHintOverride:this.#p===void 0?void 0:localFailureHint}),turnState:r}}#me(e){this.#G===e||this.#W.includes(e)||(this.#W.push(e),this.#K&&this.#n.suspendPromptForInput?.())}async#he(e){await this.#Ee({type:`extension`,name:`add`,argument:e},`Add to your agent`,{trigger:`command`})}async#ge(e){if(this.#p===void 0)return;let t={appRoot:this.#p,env:process.env};e!==void 0&&(t.info=e),this.#I=await detectSetupIssues(t,this.#D),this.#n.renderSetupWarning!==void 0&&(this.#_e(),this.#ve())}#_e(){if(this.#x)return;let e=orderedSetupIssues(this.#I,this.#L);e.length>0?this.#n.renderSetupWarning?.(formatSetupIssuesLine(e)):this.#n.clearSetupWarning?.()}async#ve(){let e=this.#p;if(e===void 0||process.env.EVE_MODEL_CONNECTION!==`ai-gateway-project`)return;let t;try{t=await this.#O(e,{signal:this.#M.signal})}catch{return}this.#j||this.#N||(this.#L=authIssueForStatus(t),this.#_e())}async#ye(e){let t=this.#p;if(t===void 0||this.#n.renderSetupWarning===void 0)return;let n=++this.#P,r={appRoot:t,env:process.env};e!==void 0&&(r.info=e);try{let[e,i]=await Promise.all([detectSetupIssues(r,this.#D),process.env.EVE_MODEL_CONNECTION===`ai-gateway-project`?this.#O(t,{signal:this.#M.signal}):void 0]);if(this.#j||n!==this.#P)return;this.#I=e,this.#L=i===void 0?void 0:authIssueForStatus(i),this.#_e()}catch{return}}#be(){this.#p!==void 0&&this.#n.renderSandboxLog!==void 0&&this.#Z===void 0&&(this.#Z=subscribeDevelopmentSandboxPrewarmLogs({appRoot:this.#p,log:e=>this.#n.renderSandboxLog?.(e)}))}#xe(e,t){if(e!==void 0){if(this.#n.renderCommandResult!==void 0){this.#n.renderCommandResult(e,t);return}this.#n.renderNotice?.(e)}}async#Se(e,t){let n=this.#S;if(n===void 0)return{message:`/${e.name} is not available in this session.`};let r=this.#V?.agent.model.endpoint,i={...t,renderer:this.#n,settleOutcome:e=>this.#Te(e),chatGptAccountLabel:r?.kind===`chatgpt`&&r.state===`ready`?r.accountLabel:void 0,withExclusiveTerminal:this.#w},a=this.#z?.current(),o=a!==void 0&&Object.keys(a).length>0?{...i,disabledConnectionReasons:a}:i;return await n.handle(e,o)}#Ce(e,t,n){if(t!==`startup`)return;let r=this.#T?.current().connection.state,i=n===`error`||r===`auth-failed`||r===`unavailable`?`failed`:void 0,a=e.argument.length===0?``:` ${e.argument}`;this.#n.renderCommandInvocation?.(`/${e.name}${a}`,i)}async#we(e){if(e?.kind===`model-access-changed`){this.#R?.applyEffect({kind:`refresh-identity`}),this.#N=!0,await this.#Me(e);return}e!==void 0&&(this.#R?.applyEffect(e),this.#N=!0,this.#ye(this.#V))}async#Te(e){if(e.effect===void 0)return e;let t=e.effect.kind===`model-access-changed`&&e.effect.reload?setTimeout(()=>{this.#x&&this.#n.setStartupPhase?.(`updating`),this.#n.setupFlow?.setStatus(`Loading selected model…`)},150):void 0;try{await this.#we(e.effect);let{effect:t,...n}=e;return n}catch{return{tone:`error`,message:`Settings were saved, but the agent could not reload. Retry the command or restart eve dev.`}}finally{clearTimeout(t)}}async#Ee(e,t,n){let r=await this.#Se(e,{...n,title:t}),i=r===void 0?void 0:await this.#Te(r);return!(n.suppressSuccessfulTranscript===!0&&i?.tone!==`error`||n.suppressCancelledTranscript===!0&&i?.cancelled===!0)&&n.trigger!==`startup`&&this.#xe(i?.message,i?.tone),this.#Oe(),i}async#De(e){this.#y?.({flow:`onboarding`,step:`model_provider`});let t=await this.#Ee({type:`extension`,name:`login`,argument:``},e,{trigger:`startup`,initialModelStep:`provider`});return!t?.cancelled&&t?.tone!==`error`&&this.#y?.({flow:`onboarding`,step:`connection_ready`}),this.#b?.({flow:`onboarding`,step:`model_provider`,result:t?.cancelled?`cancelled`:t?.tone===`error`?`error`:`completed`}),t}#Oe(){if(this.#x)return;let e=this.#T?.current().connection;e?.state===`ready`&&e.info!==this.#V&&(this.#V=e.info,this.#f!==void 0&&this.#n.renderAgentHeader?.({info:e.info,name:this.#r,serverUrl:this.#f}))}async#ke(e){if(this.#p===void 0||this.#n.traceViewer===void 0){this.#xe(`/traces is only available in local dev sessions.`);return}try{await this.#n.traceViewer.open({appRoot:this.#p,sessionId:this.#e?.state.sessionId,reference:e===``?void 0:e})}catch(e){if(isInterruptedError(e))return;throw e}}async#Ae(){let e=this.#p;if(e===void 0){this.#xe(`/info is only available in local dev sessions.`);return}try{this.#xe(renderApplicationInfo(await this.#k(e)))}catch(e){this.#xe(`Couldn't inspect the application: ${toErrorMessage(e)}`,`error`)}}#je(e){let t=this.#n;if(t.logDisplayMode===void 0||t.setLogDisplayMode===void 0)return`/loglevel is not available in this session.`;if(e===``)return`Logs: ${t.logDisplayMode()}. Use /loglevel all|stderr|sandbox|none — logs stay buffered, so switching also hides or restores past lines.`;let n=parseLogDisplayMode(e);if(n===void 0)return`Unknown log level "${e}". Use all, stderr, sandbox, or none.`;if(n===t.logDisplayMode())return`Logs already set to ${n}.`;switch(t.setLogDisplayMode(n),n){case`none`:return`Logs hidden. Output stays buffered — /loglevel all restores it.`;case`stderr`:return`Showing stderr logs only.`;case`sandbox`:return`Showing sandbox logs only.`;case`all`:return`Showing all logs.`}}async#Me(e){let t=this.#p;t!==void 0&&(++this.#F,++this.#P,await loadDevelopmentEnvironmentFiles(t),e.reload&&await this.#d?.refreshAfterSourceChange({}),e.model&&this.#V?this.#te({...this.#V,agent:{...this.#V.agent,model:{...this.#V.agent.model,...e.model}}}):this.#te(this.#V),this.#I=[],this.#L=void 0,this.#_e(),this.#Ne())}async#Ne(e=!1){let t=this.#V,n=++this.#F,r=await this.#Pe();this.#j||n!==this.#F||r===void 0||(this.#te(r),e&&!this.#n.renderAgentHeader&&this.#n.renderNotice?.(formatAgentUpdateNotice(t,r)),this.#ye(this.#V))}async#Pe(){let e=this.#t;if(e===void 0)return;let t=await probeAgentInfo({client:e});return t.kind===`ready`?t.info:void 0}#Fe(){this.#Ne(!0)}#Ie(e){let t={name:e.data.name,description:e.data.description,state:`required`};e.data.authorization!==void 0&&(t.challenge=e.data.authorization),e.data.webhookUrl!==void 0&&(t.webhookUrl=e.data.webhookUrl),this.#J.set(e.data.name,t),this.#ze(t)}#Le(e){if(e.turnState?.boundaryEvent!==`session.waiting`)return!1;let t=!1;for(let e of this.#J.values())e.state===`required`&&e.webhookUrl!==void 0&&(e.state=`pending`,this.#Y.add(e.name),this.#ze(e),t=!0);return t&&this.#n.setConnectionAuthPendingCount?.(this.#Y.size),this.#Y.size>0}#Re(e){let t=this.#J.get(e.data.name)??{name:e.data.name,description:``,state:e.data.outcome};t.state=e.data.outcome,e.data.reason!==void 0&&(t.reason=e.data.reason),this.#J.set(e.data.name,t),this.#Y.delete(e.data.name),this.#ze(t),this.#n.setConnectionAuthPendingCount?.(this.#Y.size)}#ze(e){let t={name:e.name,description:e.description,state:e.state};e.challenge!==void 0&&(t.challenge=e.challenge),e.reason!==void 0&&(t.reason=e.reason),this.#n.upsertConnectionAuth?.(t)}};function createRenderer(e){return e.renderer?e.renderer:new TerminalRenderer({tools:e.tools,reasoning:e.reasoning,subagents:e.subagents,connectionAuth:e.connectionAuth,assistantResponseStats:e.assistantResponseStats,contextSize:e.contextSize,logs:e.logs,availablePromptCommands:e.availablePromptCommands,input:e.userInput,output:e.screen,diagnostics:e.diagnostics,onExitRequest:e.lifecycle?.requestStop})}function formatAgentUpdateNotice(e,t){let n=e?.agent.model.id,r=t?.agent.model.id;return n!==void 0&&r!==void 0&&n!==r?`Agent updated: Model ${n} -> ${r}`:`Agent updated.`}function registryHandoffAddress(e,t){if(e!==`selfmod__registry_add`||typeof t!=`object`||!t)return;let n=t;return n.status===`needs-terminal`&&typeof n.address==`string`?n.address:void 0}async function*eveEventsToTUIStream(e){let{events:t,pendingInputRequests:n,turnState:r,onSubagentCalled:i,onSubagentBackgrounded:a,onSubagentCompleted:o,onTurnCancelled:s,onConnectionAuthRequired:c,onConnectionAuthCompleted:l,onRegistryHandoff:u,onTerminalFailure:d,failureHintOverride:f}=e,p=new Map,m=new Map,h=new Map,g=createEventDeduper(),_=0,v=new Set,y=new Set,b=new Set,x=!1,S=!1,C;for await(let w of t)if(g.admit(w)&&!(S&&isPostTurnVisibleEvent(w)))switch(w.type){case`session.started`:case`message.received`:break;case`turn.started`:w.data.turnId!==r.turnId&&(S=!1),r.turnId=w.data.turnId,yield{type:`turn-start`,turnId:w.data.turnId};break;case`step.started`:_+=1,yield{type:`step-start`,modelId:w.data.modelId};break;case`step.completed`:{let e=w;C=e.data.usage,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`step-finish`,usage:e.data.usage};break}case`message.appended`:{let t=w,n=textPartId(t.data.turnId,t.data.stepIndex),r=partStateFor(p,n);if(r.completed){if(_<=r.completedEpoch)break;r.generation+=1,r.text=``,r.completed=!1}let i=t.data.messageDelta;if(i.length===0)break;r.text+=i,i&&e.onAssistantResponse?.(),yield{type:`assistant-delta`,id:partGenerationId(n,r.generation),delta:i};break}case`message.completed`:{let t=textPartId(w.data.turnId,w.data.stepIndex),n=partStateFor(p,t),r=w.data.message;if(n.completed){if(r===null||_<=n.completedEpoch)break;n.generation+=1,n.text=r,n.completedEpoch=_,yield{type:`assistant-complete`,id:partGenerationId(t,n.generation),text:r};break}let i=partGenerationId(t,n.generation);if(r!==null){if(n.text.length===0)n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i,text:r};else if(r.startsWith(n.text)){let t=r.slice(n.text.length);t.length>0&&(t&&e.onAssistantResponse?.(),yield{type:`assistant-delta`,id:i,delta:t}),n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i}}else n.text=r,n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i,text:r}}else n.text.length>0&&(n.completed=!0,n.completedEpoch=_,yield{type:`assistant-complete`,id:i});break}case`reasoning.appended`:{let e=w,t=reasoningPartId(e.data.turnId,e.data.stepIndex),n=partStateFor(m,t);if(n.completed){if(_<=n.completedEpoch)break;n.generation+=1,n.text=``,n.completed=!1}let r=e.data.reasoningDelta;if(r.length===0)break;n.text+=r,yield{type:`reasoning-delta`,id:partGenerationId(t,n.generation),delta:r};break}case`reasoning.completed`:{let e=reasoningPartId(w.data.turnId,w.data.stepIndex),t=partStateFor(m,e),n=w.data.reasoning;if(t.completed){if(n.length===0||_<=t.completedEpoch)break;t.generation+=1,t.text=n,t.completedEpoch=_;let r=partGenerationId(e,t.generation);yield{type:`reasoning-delta`,id:r,delta:n},yield{type:`reasoning-complete`,id:r};break}let r=partGenerationId(e,t.generation);if(t.text.length===0&&n.length>0)t.text=n,yield{type:`reasoning-delta`,id:r,delta:n};else if(n.length>0&&!n.startsWith(t.text)){yield{type:`reasoning-complete`,id:r},t.generation+=1,t.text=n,t.completed=!0,t.completedEpoch=_;let i=partGenerationId(e,t.generation);yield{type:`reasoning-delta`,id:i,delta:n},yield{type:`reasoning-complete`,id:i};break}t.completed=!0,t.completedEpoch=_,yield{type:`reasoning-complete`,id:r};break}case`actions.requested`:{let e=w.data.actions.filter(e=>e.kind===`tool-call`);if(e.length===0)break;for(let t of e)h.set(t.callId,t.toolName),!v.has(t.callId)&&(v.add(t.callId),yield{type:`tool-call`,toolCallId:t.callId,toolName:t.toolName,input:t.input});break}case`input.requested`:{let e=w.data.requests.filter(e=>e.action.kind===`tool-call`);if(e.length===0)break;for(let t of e){let e=t.action.callId;if(h.set(e,t.action.toolName),t.kind!==`session-limit`&&!v.has(e)&&(v.add(e),yield{type:`tool-call`,toolCallId:e,toolName:t.action.toolName,input:t.action.input}),!y.has(t.requestId)){if(y.add(t.requestId),n.set(t.requestId,t),t.kind!==`tool-approval`){upsertPendingQuestion(r,t);continue}upsertPendingApproval(r,t),yield{type:`tool-approval-request`,approvalId:t.requestId,toolCallId:e}}}break}case`action.result`:{let e=w;if(e.data.result.kind!==`tool-result`)break;let t=e.data.result.callId;if(!v.has(t))break;switch(e.data.status){case`completed`:{let n=e.data.result.output;yield{type:`tool-result`,toolCallId:t,output:n};let r=registryHandoffAddress(h.get(t),n);r!==void 0&&await u?.(r);break}case`failed`:yield{type:`tool-error`,toolCallId:t,errorText:formatActionResultError(e)};break;case`rejected`:yield{type:`tool-rejected`,toolCallId:t,reason:formatActionResultError(e)}}break}case`step.failed`:case`turn.failed`:{let e=toFailureEvent(w,b,f);e&&(yield e);break}case`session.failed`:{r.sawSessionFailure=!0,d?.(w);let e=toFailureEvent(w,b,f);e&&(yield e),r.boundaryEvent=w.type,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C},x=!0;return}case`session.waiting`:case`session.completed`:r.boundaryEvent=w.type,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C},x=!0;return;case`turn.completed`:S=!0,yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_);break;case`turn.cancelled`:s?.(w.data.turnId),yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`turn-cancelled`};break;case`subagent.called`:i?.(w);break;case`subagent.started`:case`subagent.event`:break;case`subagent.completed`:{let e=w;e.data.backgroundTask===void 0?o?.(e.data.callId):a?.(e.data.callId);break}case`authorization.required`:c?.(w);break;case`authorization.completed`:l?.(w)}x||(yield*closeOpenParts(p,`assistant-complete`,_),yield*closeOpenParts(m,`reasoning-complete`,_),yield{type:`finish`,usage:C})}async function*errorOnlyTUIStream(e){yield{type:`error`,errorText:e.errorText},yield{type:`finish`}}function createTurnState(){return{aborted:!1,pendingApprovals:[],pendingQuestions:[],sawSessionFailure:!1}}function upsertPendingApproval(e,t){let n=toAgentTUIToolApprovalRequest(t),r=e.pendingApprovals.findIndex(e=>e.approvalId===n.approvalId);r===-1?e.pendingApprovals.push(n):e.pendingApprovals[r]=n}function toAgentTUIToolApprovalRequest(e){return{approvalId:e.requestId,toolCallId:e.action.callId,toolName:e.action.toolName,input:e.action.input}}function upsertPendingQuestion(e,t){let n=e.pendingQuestions.findIndex(e=>e.requestId===t.requestId);n===-1?e.pendingQuestions.push(t):e.pendingQuestions[n]=t}function textPartId(e,t){return`text:${e}:${t}`}function reasoningPartId(e,t){return`reasoning:${e}:${t}`}function partStateFor(e,t){let n=e.get(t);return n===void 0&&(n={generation:0,text:``,completed:!1,completedEpoch:0},e.set(t,n)),n}function partGenerationId(e,t){return t===0?e:`${e}#${t}`}function*closeOpenParts(e,t,n){for(let[r,i]of e)i.completed||i.text.length===0||(i.completed=!0,i.completedEpoch=n,yield{type:t,id:partGenerationId(r,i.generation)})}function isPostTurnVisibleEvent(e){switch(e.type){case`actions.requested`:case`authorization.completed`:case`authorization.required`:case`input.requested`:case`message.appended`:case`message.completed`:case`reasoning.appended`:case`reasoning.completed`:case`result.completed`:case`step.completed`:case`step.failed`:case`step.started`:case`subagent.called`:case`subagent.completed`:case`subagent.event`:case`subagent.started`:case`turn.completed`:case`turn.failed`:return!0;default:return!1}}function formatActionResultError(e){if(e.data.error?.message)return e.data.error.message;let t=e.data.result.output;if(typeof t==`string`)return t;try{return JSON.stringify(t)}catch{return`Tool execution failed.`}}function toFailureEvent(e,t,n){let r=failureKey(e);if(t.has(r))return;t.add(r);let i={type:`error`,errorText:formatFailureMessage(e)},a=n?.(e)??formatFailureHint(e);a!==void 0&&(i.hint=a);let o=formatFailureDetail(e);return o!==void 0&&(i.detail=o),i}function toAgentTUIInputQuestion(e){let t=e.display===`text`?`text`:e.display===`select`||e.options!==void 0&&e.options.length>0?`select`:`text`,n={requestId:e.requestId,prompt:e.prompt,display:t};return e.options!==void 0&&(n.options=e.options.map(e=>{let t={id:e.id,label:e.label};return e.description!==void 0&&(t.description=e.description),e.style!==void 0&&(t.style=e.style),t})),e.allowFreeform!==void 0&&(n.allowFreeform=e.allowFreeform),n}export{EveTUIRunner,parsePromptCommand,registryHandoffAddress};
|
|
@@ -31,7 +31,9 @@ export declare class Client {
|
|
|
31
31
|
* shape). Inspection is best-effort: a working connection does not depend on
|
|
32
32
|
* this route, so connection probes treat this distinctly from a failed request.
|
|
33
33
|
*/
|
|
34
|
-
info(
|
|
34
|
+
info(options?: {
|
|
35
|
+
readonly signal?: AbortSignal;
|
|
36
|
+
}): Promise<AgentInfoResult>;
|
|
35
37
|
/**
|
|
36
38
|
* Performs an authenticated fetch against a path on this eve target.
|
|
37
39
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{HealthResponseError}from"#client/health-response-error.js";import{HealthResultSchema}from"#client/health-schema.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientError}from"#client/client-error.js";import{ClientSessions}from"#client/sessions.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;sessions;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.redirect,this.sessions=new ClientSessions({host:this.#n,redirect:this.#r,resolveHeaders:e=>this.#i(e)})}async health(){let e=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),t=await this.#i(),n=await fetch(e,withRedirectPolicy({headers:t},this.#r));if(!n.ok){let e=await n.text();throw new ClientError(n.status,e,n.headers)}let r;try{r=await n.json()}catch{throw new HealthResponseError}let i=HealthResultSchema.safeParse(r);if(!i.success)throw new HealthResponseError(i.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return i.data}async info(){let
|
|
1
|
+
import{EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{encodeBasicCredentials}from"#internal/http/basic-auth.js";import{AgentInfoResponseError}from"#client/agent-info-error.js";import{HealthResponseError}from"#client/health-response-error.js";import{HealthResultSchema}from"#client/health-schema.js";import{AgentInfoResultSchema}from"#client/agent-info-schema.js";import{ClientError}from"#client/client-error.js";import{ClientSessions}from"#client/sessions.js";import{createClientUrl}from"#client/url.js";import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";var Client=class{#e;#t;#n;#r;sessions;constructor(e){this.#n=e.host,this.#e=e.auth,this.#t=e.headers,this.#r=e.redirect,this.sessions=new ClientSessions({host:this.#n,redirect:this.#r,resolveHeaders:e=>this.#i(e)})}async health(){let e=createClientUrl(this.#n,EVE_HEALTH_ROUTE_PATH),t=await this.#i(),n=await fetch(e,withRedirectPolicy({headers:t},this.#r));if(!n.ok){let e=await n.text();throw new ClientError(n.status,e,n.headers)}let r;try{r=await n.json()}catch{throw new HealthResponseError}let i=HealthResultSchema.safeParse(r);if(!i.success)throw new HealthResponseError(i.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return i.data}async info(e={}){let t=await this.fetch(EVE_INFO_ROUTE_PATH,e);if(!t.ok){let e=await t.text();throw new ClientError(t.status,e,t.headers)}let n;try{n=await t.json()}catch{throw new AgentInfoResponseError}let r=AgentInfoResultSchema.safeParse(n);if(!r.success)throw new AgentInfoResponseError(r.error.issues.slice(0,5).map(e=>{let t=e.path.join(`.`);return t.length===0?e.message:`${t}: ${e.message}`}));return r.data}async fetch(e,t={}){let n=createClientUrl(this.#n,e),r=await this.#i(headersInitToRecord(t.headers));return await fetch(n,withRedirectPolicy({...t,headers:r},this.#r))}async#i(e){let t=new Headers,[n,r]=await Promise.all([resolveHeadersValue(this.#t),this.#a()]);for(let[e,r]of Object.entries(n))t.set(e,r);for(let[e,n]of Object.entries(r))t.set(e,n);if(e)for(let[n,r]of Object.entries(e))t.set(n,r);return t}async#a(){let e=this.#e;if(!e)return{};if(`vercelOidc`in e){let t=(await resolveTokenValue(e.vercelOidc.token)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`,[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]:t}}if(`bearer`in e){let t=(await resolveTokenValue(e.bearer)).trim();return t.length===0?{}:{authorization:`Bearer ${t}`}}if(`basic`in e){let t=await resolveTokenValue(e.basic.password);return{authorization:`Basic ${encodeBasicCredentials(e.basic.username,t)}`}}return{}}};async function resolveTokenValue(e){return typeof e==`function`?e():e}async function resolveHeadersValue(e){return e===void 0?{}:typeof e==`function`?await e():e}function headersInitToRecord(e){return e===void 0?{}:Object.fromEntries(new Headers(e).entries())}function withRedirectPolicy(e,t){return t===void 0?e:{...e,redirect:t}}export{Client};
|
|
@@ -6,5 +6,6 @@ export declare class EveAgentProjection<TData> {
|
|
|
6
6
|
get data(): TData;
|
|
7
7
|
reset(): void;
|
|
8
8
|
append(event: EveAgentReducerEvent): void;
|
|
9
|
+
remove(predicate: (event: EveAgentReducerEvent) => boolean): void;
|
|
9
10
|
replace(predicate: (event: EveAgentReducerEvent) => boolean, replacement: EveAgentReducerEvent): void;
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var EveAgentProjection=class{#e;#t;#n;constructor(e,t){this.#e=e,this.#t=t,this.#n=this.#r()}get data(){return this.#n}reset(){this.#t=[],this.#n=this.#e.initial()}append(e){this.#t=[...this.#t,e],this.#n=this.#e.reduce(this.#n,e)}replace(e,t){let n=this.#t.findIndex(e);this.#t=n===-1?[...this.#t,t]:this.#t.map((e,r)=>r===n?t:e),this.#n=this.#r()}#r(){let e=this.#e.initial();for(let t of this.#t)e=this.#e.reduce(e,t);return e}};export{EveAgentProjection};
|
|
1
|
+
var EveAgentProjection=class{#e;#t;#n;constructor(e,t){this.#e=e,this.#t=t,this.#n=this.#r()}get data(){return this.#n}reset(){this.#t=[],this.#n=this.#e.initial()}append(e){this.#t=[...this.#t,e],this.#n=this.#e.reduce(this.#n,e)}remove(e){this.#t=this.#t.filter(t=>!e(t)),this.#n=this.#r()}replace(e,t){let n=this.#t.findIndex(e);this.#t=n===-1?[...this.#t,t]:this.#t.map((e,r)=>r===n?t:e),this.#n=this.#r()}#r(){let e=this.#e.initial();for(let t of this.#t)e=this.#e.reduce(e,t);return e}};export{EveAgentProjection};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{isCurrentTurnBoundaryEvent}from"#protocol/message.js";import{updatePendingAuthorizations}from"#client/session-utils.js";function isSettledSessionTail(e){let t=e.at(-1);return t!==void 0&&isCurrentTurnBoundaryEvent(t)&&(t.type!==`session.waiting`||collectPendingAuthorizations(e).size===0)}function collectPendingAuthorizations(e){let t=new Set;for(let n of e)updatePendingAuthorizations(t,n);return t}function assertExclusiveTurnInput(e){if(e.message!==void 0==(e.inputResponses!==void 0))throw Error(`A turn requires exactly one of message or inputResponses.`)}let submissionSequence=0;function createSubmissionId(){let e=globalThis.crypto?.randomUUID;return e===void 0?(submissionSequence+=1,`submission_${submissionSequence.toString()}`):e.call(globalThis.crypto)}function createAbortSignal(e,t){return e?AbortSignal.any([e,t]):t}function summarizeUserContent(e){if(typeof e==`string`)return e;let t=[];for(let n of e)n.type===`text`?t.push(n.text):n.type===`file`&&t.push(n.filename?`[file: ${n.filename}]`:`[file]`);return t.join(`
|
|
2
|
-
`)}function isAbortError(e){return e instanceof Error&&e.name===`AbortError`}function toTerminalStreamFailureError(e){if(e.type!==`session.failed`)return;let t=Error(e.data.message);return t.name=e.data.code,t}function createActiveTurn(e){let t=Promise.withResolvers(),n=Promise.withResolvers(),r={abortController:new AbortController,acceptedFollowUps:0,cancel:()=>e(r),completion:n.promise,followUpDispatches:new Set,receivedFollowUps:0,receivedFollowUpEvents:new
|
|
2
|
+
`)}function isAbortError(e){return e instanceof Error&&e.name===`AbortError`}function toTerminalStreamFailureError(e){if(e.type!==`session.failed`)return;let t=Error(e.data.message);return t.name=e.data.code,t}function createActiveTurn(e){let t=Promise.withResolvers(),n=Promise.withResolvers(),r={abortController:new AbortController,acceptedFollowUps:0,cancel:()=>e(r),completion:n.promise,followUpDispatches:new Set,receivedFollowUps:0,receivedFollowUpEvents:new Map,followUpSubmissionIds:new Set,resolveCompletion:n.resolve,response:t.promise,resolveResponse:t.resolve};return r}async function followSteeredTurns(e,t,n){for(;e.followUpDispatches.size>0;)await Promise.allSettled(e.followUpDispatches);if(!(e.receivedFollowUps>=e.acceptedFollowUps))for await(let r of t){if(!n())return;if(e.receivedFollowUps+=e.receivedFollowUpEvents.get(r)??0,e.receivedFollowUpEvents.delete(r),isCurrentTurnBoundaryEvent(r)){for(;e.followUpDispatches.size>0;)await Promise.allSettled(e.followUpDispatches);if(e.receivedFollowUps>=e.acceptedFollowUps)return}}}async function waitWithSignal(e,t){if(t===void 0)return await e;let n=Promise.withResolvers(),onAbort=()=>n.reject(t.reason);t.addEventListener(`abort`,onAbort,{once:!0}),t.aborted&&onAbort();try{return await Promise.race([n.promise,e])}finally{t.removeEventListener(`abort`,onAbort)}}export{assertExclusiveTurnInput,collectPendingAuthorizations,createAbortSignal,createActiveTurn,createSubmissionId,followSteeredTurns,isAbortError,isSettledSessionTail,summarizeUserContent,toTerminalStreamFailureError,waitWithSignal};
|
|
@@ -54,8 +54,11 @@ export interface EveAgentStoreInit<TData> {
|
|
|
54
54
|
}
|
|
55
55
|
export interface PendingMessageSubmission {
|
|
56
56
|
readonly createdAt: number;
|
|
57
|
+
readonly eventStartIndex: number;
|
|
57
58
|
readonly id: string;
|
|
58
59
|
readonly message: string;
|
|
60
|
+
readonly requiresDeliveryId: boolean;
|
|
61
|
+
readonly deliveryId?: string;
|
|
59
62
|
}
|
|
60
63
|
export interface ActiveTurn {
|
|
61
64
|
readonly abortController: AbortController;
|
|
@@ -64,7 +67,7 @@ export interface ActiveTurn {
|
|
|
64
67
|
readonly completion: Promise<void>;
|
|
65
68
|
readonly followUpDispatches: Set<Promise<void>>;
|
|
66
69
|
receivedFollowUps: number;
|
|
67
|
-
readonly receivedFollowUpEvents:
|
|
70
|
+
readonly receivedFollowUpEvents: Map<MessageStreamEvent, number>;
|
|
68
71
|
readonly followUpSubmissionIds: Set<string>;
|
|
69
72
|
readonly resolveCompletion: () => void;
|
|
70
73
|
readonly response: Promise<MessageResponse | undefined>;
|