@ycodium-ai/agent-antigravity 0.2.3254 → 0.2.3265

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.
Files changed (2) hide show
  1. package/dist/index.js +205 -38
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -26656,11 +26656,15 @@ function createAcpConnection(options2) {
26656
26656
  });
26657
26657
  };
26658
26658
  const close = (error62) => shutdown(error62 ?? new AcpConnectionClosedError());
26659
+ const abandonPending = (error62) => {
26660
+ rejectPending(error62);
26661
+ };
26659
26662
  return {
26660
26663
  request: request2,
26661
26664
  begin,
26662
26665
  notify,
26663
26666
  awaitInboundIdle,
26667
+ abandonPending,
26664
26668
  close,
26665
26669
  closed
26666
26670
  };
@@ -27126,10 +27130,11 @@ function createExecutorPrompt({
27126
27130
  const prompt = async (input2) => {
27127
27131
  failIfPromptUnavailable();
27128
27132
  const started = requireStarted();
27133
+ let sessionId = started.sessionId;
27129
27134
  let record2;
27130
27135
  const settle2 = (rest) => settleTurn({
27131
27136
  expectedGeneration: started.generation,
27132
- expectedSessionId: started.sessionId,
27137
+ expectedSessionId: sessionId,
27133
27138
  record: record2,
27134
27139
  ...rest
27135
27140
  });
@@ -27213,12 +27218,32 @@ function createExecutorPrompt({
27213
27218
  const queuedTurnId = turnId;
27214
27219
  const isStale = () => interruptedTurnIds.has(queuedTurnId) || input2.expectedActiveTurnId !== void 0 && shared.activeTurnId !== queuedTurnId;
27215
27220
  if (!isStale()) {
27216
- shared.modelSelectionState = await applyRequestedModel({
27217
- state: shared.modelSelectionState,
27218
- acpSessionId: started.sessionId,
27219
- requestedModelId: input2.requestedModelId,
27220
- expectedGeneration: started.generation
27221
- });
27221
+ try {
27222
+ const applied = await applyRequestedModel({
27223
+ state: shared.modelSelectionState,
27224
+ acpSessionId: sessionId,
27225
+ setup: shared.startResult?.sessionSetupResult ?? {},
27226
+ requestedModelId: input2.requestedModelId,
27227
+ expectedGeneration: started.generation
27228
+ });
27229
+ shared.modelSelectionState = applied.state;
27230
+ sessionId = applied.sessionId;
27231
+ record2.sessionId = applied.sessionId;
27232
+ } catch (error62) {
27233
+ const failureCategory = readAcpFailureCategory(error62);
27234
+ if (failureCategory === "model-unavailable") {
27235
+ const errorMessage2 = error62 instanceof Error && error62.message.trim().length > 0 ? error62.message : "Requested model is not in this agent's catalog. This turn was not sent.";
27236
+ settle2({
27237
+ turnId,
27238
+ stopReason: "error",
27239
+ state: "failed",
27240
+ errorMessage: errorMessage2,
27241
+ failureCategory
27242
+ });
27243
+ throw error62 instanceof Error ? withFailureCategory(error62, failureCategory) : error62;
27244
+ }
27245
+ throw error62;
27246
+ }
27222
27247
  }
27223
27248
  failIfDisposed();
27224
27249
  if (isStale()) {
@@ -27229,7 +27254,7 @@ function createExecutorPrompt({
27229
27254
  let written = false;
27230
27255
  try {
27231
27256
  response = await sendPromptRpc(
27232
- started.sessionId,
27257
+ sessionId,
27233
27258
  promptParts,
27234
27259
  () => {
27235
27260
  written = true;
@@ -27279,7 +27304,7 @@ function createExecutorPrompt({
27279
27304
  if (hooks.readContextWindow !== void 0) {
27280
27305
  try {
27281
27306
  contextWindow = await hooks.readContextWindow({
27282
- sessionId: started.sessionId,
27307
+ sessionId,
27283
27308
  promptResponse: response
27284
27309
  }) ?? void 0;
27285
27310
  } catch {
@@ -27954,6 +27979,56 @@ function acpInitializePayload(clientInfo, overrides) {
27954
27979
  };
27955
27980
  }
27956
27981
 
27982
+ // ../../packages/ycodium-acp-executor/src/refreshDeadline.ts
27983
+ var MODEL_CATALOG_REFRESH_TIMEOUT_MS = 9e4;
27984
+
27985
+ // ../../packages/ycodium-acp-executor/src/model-send.ts
27986
+ function judgeRequestedModel(input2) {
27987
+ const requested = normalizeModelId(input2.requestedModelId);
27988
+ const current = input2.state.currentModelId;
27989
+ if (requested === void 0 || requested === current) return { kind: "keep" };
27990
+ const hasCatalog = input2.state.advertisedModelValues.length > 0;
27991
+ const hasCurrent = current !== void 0;
27992
+ if (!hasCatalog && !hasCurrent) return { kind: "keep" };
27993
+ const canSwitch = input2.state.strategy === "session/set_model" && input2.state.sessionModelsAdvertised || input2.state.strategy === "config-option" && input2.state.modelConfigId !== void 0;
27994
+ const value = hasCatalog ? matchAdvertisedModelValue(requested, input2.state.advertisedModelValues) : void 0;
27995
+ if (value !== void 0 && value === current) return { kind: "keep" };
27996
+ if (value !== void 0 && canSwitch) return { kind: "switch", value };
27997
+ return input2.refreshed ? { kind: "unavailable" } : { kind: "refresh" };
27998
+ }
27999
+ function modelUnavailableError(requestedModelId, currentModelId) {
28000
+ const current = currentModelId ?? "its own model";
28001
+ return withFailureCategory(
28002
+ new Error(
28003
+ `Requested model "${requestedModelId}" is not in this agent's catalog; it is on "${current}". This turn was not sent. Refresh the model list in this agent's settings and try again.`
28004
+ ),
28005
+ "model-unavailable"
28006
+ );
28007
+ }
28008
+ var ModelCatalogRefreshTimeoutError = class extends Error {
28009
+ constructor() {
28010
+ super("model catalog refresh timed out");
28011
+ this.name = "ModelCatalogRefreshTimeoutError";
28012
+ }
28013
+ };
28014
+ function modelRefreshTimedOutError(requestedModelId) {
28015
+ return withFailureCategory(
28016
+ new Error(
28017
+ `Refreshing this agent's model list timed out, so this turn was not sent. Requested model "${requestedModelId}".`
28018
+ ),
28019
+ "model-unavailable"
28020
+ );
28021
+ }
28022
+ function modelRefreshFailedError(requestedModelId, error62) {
28023
+ const detail = error62 instanceof Error && error62.message.trim().length > 0 ? error62.message : "the model list could not be read";
28024
+ return withFailureCategory(
28025
+ new Error(
28026
+ `Refreshing this agent's model list failed (${detail}), so this turn was not sent. Requested model "${requestedModelId}".`
28027
+ ),
28028
+ "model-unavailable"
28029
+ );
28030
+ }
28031
+
27957
28032
  // ../../packages/ycodium-acp-executor/src/runtime-mode.ts
27958
28033
  function isRecord5(value) {
27959
28034
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -28037,43 +28112,131 @@ function createExecutorSession({
28037
28112
  failIfDisposed,
28038
28113
  shared
28039
28114
  }) {
28040
- const applyRequestedModel = async (input2) => {
28041
- const requestedModelId = normalizeModelId(input2.requestedModelId);
28042
- if (requestedModelId === void 0 || requestedModelId === input2.state.currentModelId || input2.state.strategy === "session/set_model" && !input2.state.sessionModelsAdvertised || input2.state.strategy === "config-option" && input2.state.modelConfigId === void 0) {
28043
- return input2.state;
28044
- }
28045
- const value = matchAdvertisedModelValue(requestedModelId, input2.state.advertisedModelValues);
28046
- if (value === void 0) {
28047
- if (requestedModelId !== shared.lastUnmatchedModelId) {
28048
- shared.lastUnmatchedModelId = requestedModelId;
28049
- options2.log?.info("requested model is not in the agent catalog; keeping its own model", {
28050
- requestedModelId,
28051
- currentModelId: input2.state.currentModelId,
28052
- advertisedModelValues: input2.state.advertisedModelValues
28053
- });
28054
- }
28055
- return input2.state;
28115
+ const openFreshSession = async (expectedGeneration) => {
28116
+ const initialized = shared.initializeResult;
28117
+ if (initialized === void 0) {
28118
+ throw new Error("no handshake");
28119
+ }
28120
+ const mcpServers = filterMcpServersByAgentCapabilities(
28121
+ options2.mcpServers ?? [],
28122
+ initialized.agentCapabilities
28123
+ );
28124
+ const additionalDirectories = options2.additionalDirectories !== void 0 && options2.additionalDirectories.length > 0 ? { additionalDirectories: options2.additionalDirectories } : {};
28125
+ const created = await connection.request("session/new", {
28126
+ cwd: options2.cwd,
28127
+ mcpServers,
28128
+ ...additionalDirectories
28129
+ });
28130
+ if (!isLive(expectedGeneration)) {
28131
+ throw new AcpExecutorDisposedError();
28056
28132
  }
28057
- if (value === input2.state.currentModelId) {
28058
- return input2.state;
28133
+ if (created.sessionId === void 0 || created.sessionId.length === 0) {
28134
+ throw new Error("session/new did not return a session id");
28059
28135
  }
28136
+ return { sessionId: created.sessionId, setup: created };
28137
+ };
28138
+ const switchModel = async (input2) => {
28060
28139
  let configOptions = input2.state.configOptions;
28061
28140
  if (input2.state.strategy === "config-option") {
28062
28141
  const switched = await connection.request(
28063
28142
  "session/set_config_option",
28064
- { sessionId: input2.acpSessionId, configId: input2.state.modelConfigId, value }
28143
+ { sessionId: input2.sessionId, configId: input2.state.modelConfigId, value: input2.value }
28065
28144
  );
28066
28145
  configOptions = switched?.configOptions ?? configOptions;
28067
28146
  } else {
28068
28147
  await connection.request("session/set_model", {
28069
- sessionId: input2.acpSessionId,
28070
- modelId: value
28148
+ sessionId: input2.sessionId,
28149
+ modelId: input2.value
28071
28150
  });
28072
28151
  }
28073
28152
  if (!isLive(input2.expectedGeneration)) {
28074
28153
  throw new AcpExecutorDisposedError();
28075
28154
  }
28076
- return { ...input2.state, currentModelId: value, configOptions };
28155
+ return { ...input2.state, currentModelId: input2.value, configOptions };
28156
+ };
28157
+ const adoptReopenedSession = (applied) => {
28158
+ if (shared.sessionId === void 0 && shared.startResult === void 0) return;
28159
+ const setup = applied.setup;
28160
+ shared.sessionId = applied.sessionId;
28161
+ shared.modelSelectionState = applied.state;
28162
+ shared.modeState = parseSessionModeState(setup);
28163
+ if (shared.startResult !== void 0) {
28164
+ shared.startResult = {
28165
+ ...shared.startResult,
28166
+ sessionId: applied.sessionId,
28167
+ sessionSetupResult: setup,
28168
+ modelConfigId: extractModelConfigId(setup),
28169
+ modelId: applied.state.currentModelId
28170
+ };
28171
+ }
28172
+ };
28173
+ const applyRequestedModel = async (input2) => {
28174
+ async function applyOnce(state, sessionId, setup, refreshed) {
28175
+ const requestedModelId = normalizeModelId(input2.requestedModelId) ?? "";
28176
+ const judgment = judgeRequestedModel({
28177
+ state,
28178
+ requestedModelId: input2.requestedModelId,
28179
+ refreshed
28180
+ });
28181
+ if (judgment.kind === "keep") return { state, sessionId, setup };
28182
+ if (judgment.kind === "unavailable") {
28183
+ throw modelUnavailableError(requestedModelId, state.currentModelId);
28184
+ }
28185
+ if (judgment.kind === "switch") {
28186
+ return {
28187
+ state: await switchModel({
28188
+ state,
28189
+ sessionId,
28190
+ value: judgment.value,
28191
+ expectedGeneration: input2.expectedGeneration
28192
+ }),
28193
+ sessionId,
28194
+ setup
28195
+ };
28196
+ }
28197
+ return refreshAndRejudge(requestedModelId);
28198
+ }
28199
+ async function refreshAndRejudge(requestedModelId) {
28200
+ const timeoutMs = options2.modelCatalogRefreshTimeoutMs ?? MODEL_CATALOG_REFRESH_TIMEOUT_MS;
28201
+ let timedOut = false;
28202
+ const timeoutError = new ModelCatalogRefreshTimeoutError();
28203
+ let timer;
28204
+ const work = (async () => {
28205
+ await options2.refreshCatalogForSend?.();
28206
+ if (timedOut) throw timeoutError;
28207
+ const reopened = await openFreshSession(input2.expectedGeneration);
28208
+ if (timedOut) throw timeoutError;
28209
+ const next = modelSelectionStateFromSetup(reopened.setup);
28210
+ const applied = await applyOnce(next, reopened.sessionId, reopened.setup, true);
28211
+ if (timedOut) throw timeoutError;
28212
+ adoptReopenedSession(applied);
28213
+ return applied;
28214
+ })();
28215
+ void work.then(
28216
+ () => void 0,
28217
+ () => void 0
28218
+ );
28219
+ const deadline = new Promise((_resolve, reject) => {
28220
+ timer = setTimeout(() => {
28221
+ timedOut = true;
28222
+ connection.abandonPending(timeoutError);
28223
+ reject(timeoutError);
28224
+ }, timeoutMs);
28225
+ });
28226
+ try {
28227
+ return await Promise.race([work, deadline]);
28228
+ } catch (error62) {
28229
+ if (error62 instanceof AcpExecutorDisposedError) throw error62;
28230
+ if (timedOut || error62 instanceof ModelCatalogRefreshTimeoutError) {
28231
+ throw modelRefreshTimedOutError(requestedModelId);
28232
+ }
28233
+ if (readAcpFailureCategory(error62) === "model-unavailable") throw error62;
28234
+ throw modelRefreshFailedError(requestedModelId, error62);
28235
+ } finally {
28236
+ if (timer !== void 0) clearTimeout(timer);
28237
+ }
28238
+ }
28239
+ return applyOnce(input2.state, input2.acpSessionId, input2.setup, false);
28077
28240
  };
28078
28241
  const startOnce = async (expectedGeneration) => {
28079
28242
  const initializePayload = acpInitializePayload(options2.clientInfo, options2.clientCapabilities);
@@ -28142,12 +28305,17 @@ function createExecutorSession({
28142
28305
  categories: unhandledCategories
28143
28306
  });
28144
28307
  }
28145
- const nextModelSelectionState = await applyRequestedModel({
28146
- state: modelSelectionStateFromSetup(setup),
28308
+ const openedSetup = setup;
28309
+ const appliedModel = await applyRequestedModel({
28310
+ state: modelSelectionStateFromSetup(openedSetup),
28147
28311
  acpSessionId: nextSessionId,
28312
+ setup: openedSetup,
28148
28313
  requestedModelId: options2.requestedModelId,
28149
28314
  expectedGeneration
28150
28315
  });
28316
+ nextSessionId = appliedModel.sessionId;
28317
+ setup = appliedModel.setup;
28318
+ const nextModelSelectionState = appliedModel.state;
28151
28319
  await applyRequestedEffort({
28152
28320
  connection,
28153
28321
  log: options2.log,
@@ -28682,7 +28850,6 @@ function createAcpExecutor(options2) {
28682
28850
  currentModelId: void 0,
28683
28851
  advertisedModelValues: []
28684
28852
  },
28685
- lastUnmatchedModelId: void 0,
28686
28853
  initializeResult: void 0,
28687
28854
  startResult: void 0,
28688
28855
  startInFlight: void 0,
@@ -30460,7 +30627,7 @@ function modelIdFromSelection(selection) {
30460
30627
  function nowIso() {
30461
30628
  return (/* @__PURE__ */ new Date()).toISOString();
30462
30629
  }
30463
- function modelUnavailableError(model) {
30630
+ function modelUnavailableError2(model) {
30464
30631
  return new Error(
30465
30632
  `Antigravity model '${model}' is unavailable for this Google account. Select an available model.`
30466
30633
  );
@@ -30653,7 +30820,7 @@ function createAntigravitySession({
30653
30820
  recordCatalog(live, catalog, acpAgentVersion(started.initializeResult) ?? void 0);
30654
30821
  const matchedModel = requestedModelId === void 0 || live.knownModelValues.length === 0 ? void 0 : matchAdvertisedModelValue(requestedModelId, live.knownModelValues);
30655
30822
  if (requestedModelId !== void 0 && live.knownModelValues.length > 0 && matchedModel === void 0) {
30656
- throw modelUnavailableError(requestedModelId);
30823
+ throw modelUnavailableError2(requestedModelId);
30657
30824
  }
30658
30825
  if (matchedModel !== void 0 && started.modelId !== matchedModel && catalog?.currentModel !== matchedModel) {
30659
30826
  host.log.warn(NOT_APPLIED_MESSAGE, { requestedModelId: matchedModel });
@@ -30786,7 +30953,7 @@ function createAntigravityTurn({
30786
30953
  });
30787
30954
  const requestedModelId = modelIdFromSelection(input2.modelSelection);
30788
30955
  if (requestedModelId !== void 0 && booked.live.knownModelValues.length > 0 && matchAdvertisedModelValue(requestedModelId, booked.live.knownModelValues) === void 0) {
30789
- throw modelUnavailableError(requestedModelId);
30956
+ throw modelUnavailableError2(requestedModelId);
30790
30957
  }
30791
30958
  const onAbort = () => {
30792
30959
  void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
@@ -33956,7 +34123,7 @@ var executors = [
33956
34123
  ];
33957
34124
  var index_default = definePlugin({
33958
34125
  id: "agent-antigravity",
33959
- apiVersion: 30,
34126
+ apiVersion: 31,
33960
34127
  executors,
33961
34128
  activate(ctx) {
33962
34129
  const runtime = createRuntimeManager({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-antigravity",
3
- "version": "0.2.3254",
3
+ "version": "0.2.3265",
4
4
  "description": "Google Antigravity executor: runs the Antigravity agent over Agent Client Protocol stdio.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -31,9 +31,9 @@
31
31
  "typescript": "~6.0.3",
32
32
  "vite-plus": "0.2.2",
33
33
  "yauzl": "^3.4.0",
34
+ "@ycodium-ai/plugin-api": "0.2.3265",
34
35
  "ycodium-executor-testing": "0.0.0",
35
- "@ycodium-ai/plugin-api": "0.2.3254",
36
- "ycodium-acp-executor": "0.2.3254"
36
+ "ycodium-acp-executor": "0.2.3265"
37
37
  },
38
38
  "ycodium": {
39
39
  "plugin": "./dist/index.js",