@preplabsai/rovara-code 0.5.7 → 0.5.9

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/bin/agentx-cli.mjs +70 -19
  2. package/package.json +1 -1
@@ -21887,8 +21887,19 @@ function environmentRoles(scope2) {
21887
21887
  function environmentInstanceProfiles(scope2) {
21888
21888
  return `arn:${scope2.partition}:iam::${scope2.account}:instance-profile${environmentRolePath(scope2.env)}*`;
21889
21889
  }
21890
+ function savedEnvPushPullLookupPattern(env3) {
21891
+ const push = savedEnvPushRoleName(env3);
21892
+ const pull = savedEnvPullRoleName(env3);
21893
+ const pattern = `${push.slice(0, -2)}??`;
21894
+ if (pull.length !== push.length || !pull.startsWith(push.slice(0, -2)))
21895
+ throw new Error(`the image push and pull role names no longer share one lookup pattern: ${push}, ${pull}`);
21896
+ return pattern;
21897
+ }
21898
+ function namedBrokerRoleName(env3) {
21899
+ return `agentx-${env3}-broker-role`;
21900
+ }
21890
21901
  function brokerRoleArn(scope2) {
21891
- return `arn:${scope2.partition}:iam::${scope2.account}:role${environmentRolePath(scope2.env)}agentx-${scope2.env}-broker-role`;
21902
+ return `arn:${scope2.partition}:iam::${scope2.account}:role${environmentRolePath(scope2.env)}${namedBrokerRoleName(scope2.env)}`;
21892
21903
  }
21893
21904
  function savedEnvSessionRoleArns(scope2) {
21894
21905
  return [savedEnvPushRoleName(scope2.env), savedEnvPullRoleName(scope2.env), savedEnvManageRoleName(scope2.env)].map((name3) => `arn:${scope2.partition}:iam::${scope2.account}:role${environmentRolePath(scope2.env)}${name3}`);
@@ -21923,7 +21934,16 @@ function fixedNameRoleLookupStatement(scope2) {
21923
21934
  Effect: "Allow",
21924
21935
  Action: [...FIXED_NAME_ROLE_LOOKUP_ACTIONS],
21925
21936
  // R5 step 1: the Slack token reader role is fixed-name too (contracts slack-company-tokens.ts), so its lookup is listed with the three image roles and (PRIVATE-PACKAGES P1b) the company-secrets role.
21926
- Resource: [...[savedEnvPushRoleName(scope2.env), savedEnvPullRoleName(scope2.env), savedEnvManageRoleName(scope2.env), companySecretsRoleName(scope2.env)].map((name3) => `arn:${scope2.partition}:iam::${scope2.account}:role/${name3}`), slackTokenReaderLookupResource(scope2)]
21937
+ // #1579: and the broker's role, fixed-name in named environments since fc5df010e (infra control-plane.ts brokerRoleName): without it a fresh install's control plane
21938
+ // failed on iam:GetRole for agentx-<env>-broker-role and its rollback on iam:DetachRolePolicy. An install that already has the role never hit it (its lookup finds the path).
21939
+ // The image push and pull roles share one pattern, `agentx-<env>-img-pu??` (IAM's `?` is exactly one character), so the broker's entry fits the deploy boundary's
21940
+ // 6,144-character limit at the longest environment name on the longest partition. It names exactly those two: no other role of this or any environment has that shape.
21941
+ Resource: [
21942
+ `arn:${scope2.partition}:iam::${scope2.account}:role/${savedEnvPushPullLookupPattern(scope2.env)}`,
21943
+ ...[savedEnvManageRoleName(scope2.env), companySecretsRoleName(scope2.env)].map((name3) => `arn:${scope2.partition}:iam::${scope2.account}:role/${name3}`),
21944
+ slackTokenReaderLookupResource(scope2),
21945
+ `arn:${scope2.partition}:iam::${scope2.account}:role/${namedBrokerRoleName(scope2.env)}`
21946
+ ]
21927
21947
  };
21928
21948
  }
21929
21949
  function ecrTemplateServiceLinkedRoleStatement(scope2) {
@@ -24494,7 +24514,7 @@ function modelSourceSchema(options = {}) {
24494
24514
  ];
24495
24515
  return external_exports.discriminatedUnion("kind", options.customModelEndpoint === false ? shapes.slice(0, 4) : shapes);
24496
24516
  }
24497
- var ModelSourceKindSchema, MAX_MODELS_PER_SOURCE, MAX_CUSTOM_SOURCES_PER_ORG, BEDROCK_ROLE_ARN_PATTERN, REGION_PATTERN, SOURCE_ID_PATTERN, BEDROCK_EXTERNAL_ID_PATTERN, EXTERNAL_ID_PATTERN, CATALOG_PROVIDER, MODEL_ENDPOINT_SECRET_PREFIX, MODEL_ENDPOINT_SECRET_REF, MODEL_ENDPOINT_SECRET_REF_MAX, QUALIFICATION_DIGEST, LabelSchema, ModelSourceInputSchema, ModelSourceSchema, OrgModelSourcesSchema;
24517
+ var ROVARA_AI_PAUSED_MESSAGE, ModelSourceKindSchema, MAX_MODELS_PER_SOURCE, MAX_CUSTOM_SOURCES_PER_ORG, BEDROCK_ROLE_ARN_PATTERN, REGION_PATTERN, SOURCE_ID_PATTERN, BEDROCK_EXTERNAL_ID_PATTERN, EXTERNAL_ID_PATTERN, CATALOG_PROVIDER, MODEL_ENDPOINT_SECRET_PREFIX, MODEL_ENDPOINT_SECRET_REF, MODEL_ENDPOINT_SECRET_REF_MAX, QUALIFICATION_DIGEST, LabelSchema, ModelSourceInputSchema, ModelSourceSchema, OrgModelSourcesSchema;
24498
24518
  var init_model_sources = __esm({
24499
24519
  "packages/contracts/dist/model-sources.js"() {
24500
24520
  "use strict";
@@ -24503,6 +24523,7 @@ var init_model_sources = __esm({
24503
24523
  init_chatgpt();
24504
24524
  init_models();
24505
24525
  init_models_node();
24526
+ ROVARA_AI_PAUSED_MESSAGE = "Rovara's AI is paused on this install. Your work is safe; try again later or use your own AI source.";
24506
24527
  ModelSourceKindSchema = external_exports.enum(["rovara", "personal-chatgpt", "anthropic", "openai", "openrouter", "bedrock", "endpoint"]);
24507
24528
  MAX_MODELS_PER_SOURCE = 20;
24508
24529
  MAX_CUSTOM_SOURCES_PER_ORG = 10;
@@ -25915,6 +25936,8 @@ var init_routes = __esm({
25915
25936
  { method: "GET", path: "/v1/app/sessions/{sessionId}", requires: "tasks:read" },
25916
25937
  // The task's log of questions, answers and decisions (B5): the same readers as the session; one more row, nothing existing changed.
25917
25938
  { method: "GET", path: "/v1/app/sessions/{sessionId}/log", requires: "tasks:read" },
25939
+ // The task's agent activity (#1548, #1589): the same readers as the session and its log.
25940
+ { method: "GET", path: "/v1/app/sessions/{sessionId}/activity", requires: "tasks:read" },
25918
25941
  { method: "POST", path: "/v1/app/sessions/{sessionId}/follow", requires: "tasks:read" },
25919
25942
  { method: "DELETE", path: "/v1/app/sessions/{sessionId}/follow", requires: "tasks:read" },
25920
25943
  { method: "POST", path: "/v1/app/sessions/{sessionId}/unfollow", requires: "tasks:read" },
@@ -71331,11 +71354,12 @@ var init_slack_answers = __esm({
71331
71354
  });
71332
71355
 
71333
71356
  // packages/contracts/dist/slack-model-access.js
71334
- var ModelName, SlackModelAccessResultSchema;
71357
+ var ModelName, SlackModelAccessResultSchema, SLACK_MODEL_WORDS;
71335
71358
  var init_slack_model_access = __esm({
71336
71359
  "packages/contracts/dist/slack-model-access.js"() {
71337
71360
  "use strict";
71338
71361
  init_zod();
71362
+ init_model_sources();
71339
71363
  ModelName = external_exports.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u);
71340
71364
  SlackModelAccessResultSchema = external_exports.discriminatedUnion("status", [
71341
71365
  external_exports.object({ status: external_exports.literal("install") }).strict(),
@@ -71348,6 +71372,17 @@ var init_slack_model_access = __esm({
71348
71372
  }).strict(),
71349
71373
  external_exports.object({ status: external_exports.literal("unavailable") }).strict()
71350
71374
  ]);
71375
+ SLACK_MODEL_WORDS = {
71376
+ installPaused: ROVARA_AI_PAUSED_MESSAGE,
71377
+ /** No gateway here, or a workspace that is not a company's. */
71378
+ notSetUp: "Rovara's AI isn't set up for this workspace yet. Ask a company admin to check the setup in Rovara.",
71379
+ /** The company has no connected AI source (or the one it has was refused). */
71380
+ noProvider: "Your company has no AI connected yet, so I can't answer here. A company admin can connect one in Rovara.",
71381
+ /** The company's monthly room for this is used up. */
71382
+ paused: "Your company's AI limit for this month is used up, so I can't answer here until it is raised or next month starts.",
71383
+ /** Anything else (a gateway fault, a timeout). */
71384
+ unavailable: "I couldn't reach your company's AI just now. Please try again in a minute."
71385
+ };
71351
71386
  }
71352
71387
  });
71353
71388
 
@@ -204960,16 +204995,21 @@ async function assertGatewayRunPrices(origin2, transport2 = fetch) {
204960
204995
  }
204961
204996
  async function waitForGatewayRunPrices(origin2, options = {}) {
204962
204997
  const transport2 = options.transport ?? fetch;
204963
- const timeoutMs = options.timeoutMs ?? 18e4;
204998
+ const timeoutMs = options.timeoutMs ?? GATEWAY_READY_TIMEOUT_MS;
204964
204999
  const pollMs = options.pollMs ?? 5e3;
205000
+ const streak = Math.max(1, options.streak ?? GATEWAY_READY_STREAK);
204965
205001
  const now = options.now ?? Date.now;
204966
205002
  const sleep4 = options.sleep ?? ((ms) => new Promise((resolve17) => setTimeout(resolve17, ms)));
204967
205003
  const deadline = now() + timeoutMs;
205004
+ let good = 0;
204968
205005
  for (; ; ) {
204969
205006
  try {
204970
205007
  await assertGatewayRunPrices(origin2, transport2);
204971
- return;
205008
+ good += 1;
205009
+ if (good >= streak) return;
205010
+ continue;
204972
205011
  } catch (error64) {
205012
+ good = 0;
204973
205013
  if (now() >= deadline) throw error64;
204974
205014
  await sleep4(Math.min(pollMs, Math.max(0, deadline - now())));
204975
205015
  }
@@ -205000,11 +205040,13 @@ async function fetchControlPlaneTaskKeyIds(controlPlaneUrl, transport2 = fetch)
205000
205040
  }
205001
205041
  return unique5.join(",");
205002
205042
  }
205003
- var TASK_KID;
205043
+ var GATEWAY_READY_STREAK, GATEWAY_READY_TIMEOUT_MS, TASK_KID;
205004
205044
  var init_gateway_price_preflight = __esm({
205005
205045
  "packages/cli/src/deploy/gateway-price-preflight.ts"() {
205006
205046
  "use strict";
205007
205047
  init_dist2();
205048
+ GATEWAY_READY_STREAK = 3;
205049
+ GATEWAY_READY_TIMEOUT_MS = 42e4;
205008
205050
  TASK_KID = /^[A-Za-z0-9_-]{16}$/u;
205009
205051
  }
205010
205052
  });
@@ -367591,7 +367633,7 @@ init_dist2();
367591
367633
  import { realpathSync } from "node:fs";
367592
367634
 
367593
367635
  // packages/cli/src/version.ts
367594
- var RELEASE_VERSION = true ? "0.5.7" : void 0;
367636
+ var RELEASE_VERSION = true ? "0.5.9" : void 0;
367595
367637
  var CLI_VERSION = RELEASE_VERSION ?? "0.1.0";
367596
367638
  function isPrereleaseVersion(version3) {
367597
367639
  return /^\d+\.\d+\.\d+-/.test(version3);
@@ -376957,6 +376999,24 @@ init_dist2();
376957
376999
  var REPLY_WAIT_MS = 10 * 6e4;
376958
377000
  var POLL_MS3 = 15e3;
376959
377001
  var EARLY_MS2 = 5e3;
377002
+ var REFUSAL_WORDS = new Set(Object.values(SLACK_MODEL_WORDS));
377003
+ var isRefusal = (entry) => typeof entry.responseText === "string" && REFUSAL_WORDS.has(entry.responseText.trim());
377004
+ function settledReply(mine, input2) {
377005
+ const answered = mine.find((entry) => entry.disposition === "answered" && !isRefusal(entry));
377006
+ if (answered !== void 0) {
377007
+ const seconds2 = Math.round(answered.durationMs / 1e3);
377008
+ input2.write(`AgentX replied in #${input2.channelName} in ${seconds2} seconds.`);
377009
+ return { eventId: answered.eventId, seconds: seconds2 };
377010
+ }
377011
+ const other = mine[0];
377012
+ if (other === void 0) return void 0;
377013
+ for (const entry of mine) input2.reported?.add(entry.eventId);
377014
+ const refused5 = mine.find((entry) => entry.disposition === "answered");
377015
+ if (refused5 !== void 0) {
377016
+ throw agentXError("RUNTIME_UNAVAILABLE", `AgentX answered in #${input2.channelName}, but only with its fixed refusal "${(refused5.responseText ?? "").trim()}": it made no model call. See agentx --env ${input2.env} admin turns export --since 15m and the Slack service's log (model_access), fix it, then run ${input2.rerun} again`);
377017
+ }
377018
+ throw agentXError("RUNTIME_UNAVAILABLE", `AgentX replied in #${input2.channelName}, but the turn ended as ${other.disposition}${other.error === void 0 ? "" : ` (${other.error.name})`}; see agentx --env ${input2.env} admin turns export --since 15m, fix it, then run ${input2.rerun} again`);
377019
+ }
376960
377020
  async function waitForThreadedReply(input2) {
376961
377021
  const timeout = input2.timeoutMs ?? REPLY_WAIT_MS;
376962
377022
  const count8 = Math.round(timeout / 6e4);
@@ -376971,17 +377031,8 @@ async function waitForThreadedReply(input2) {
376971
377031
  turns.push(JSON.parse(line21));
376972
377032
  } }, input2.fetch);
376973
377033
  const mine = turns.filter((entry) => entry.subject.startsWith(prefix2) && Date.parse(entry.receivedAt) >= started - EARLY_MS2 && input2.reported?.has(entry.eventId) !== true);
376974
- const answered = mine.find((entry) => entry.disposition === "answered");
376975
- if (answered !== void 0) {
376976
- const seconds2 = Math.round(answered.durationMs / 1e3);
376977
- input2.write(`AgentX replied in #${input2.channelName} in ${seconds2} seconds.`);
376978
- return { eventId: answered.eventId, seconds: seconds2 };
376979
- }
376980
- const other = mine[0];
376981
- if (other !== void 0) {
376982
- for (const entry of mine) input2.reported?.add(entry.eventId);
376983
- throw agentXError("RUNTIME_UNAVAILABLE", `AgentX replied in #${input2.channelName}, but the turn ended as ${other.disposition}${other.error === void 0 ? "" : ` (${other.error.name})`}; see agentx --env ${input2.env} admin turns export --since 15m, fix it, then run ${input2.rerun} again`);
376984
- }
377034
+ const reply = settledReply(mine, input2);
377035
+ if (reply !== void 0) return reply;
376985
377036
  if (input2.now() - started >= timeout) {
376986
377037
  throw agentXError("RUNTIME_UNAVAILABLE", `no AgentX reply in #${input2.channelName} within ${minutes2}; check that the message mentioned the bot, that Slack shows the Request URL as Verified, and agentx --env ${input2.env} admin turns export --since 15m, then run ${input2.rerun} again`);
376987
377038
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preplabsai/rovara-code",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "rovara": "bin/agentx.mjs",