@installagent/sdk 0.10.0 → 0.12.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.
@@ -18,7 +18,7 @@
18
18
  // `ci/repo-lint.mjs`. It never writes a file, never runs a workflow, and never
19
19
  // changes anything on n8n, GitHub or Slack. `postClientDriftReport` is the one
20
20
  // write in this module, and only the CLI's `--post` calls it.
21
- import { existsSync, readdirSync, readFileSync } from "node:fs";
21
+ import { existsSync, readFileSync } from "node:fs";
22
22
  import { join, resolve } from "node:path";
23
23
  import { checkAgentMirror, fetchLiveWorkflows } from "./agent-mirror.js";
24
24
  import { parseLinearProjectSlugId } from "./client-linear.js";
@@ -28,10 +28,10 @@ import { gitStatus } from "./git.js";
28
28
  import { findProjectBySlugId, LINEAR_API_TOKEN_ENV, LinearAuthError, linearProjectIssueStates, } from "./linear-project.js";
29
29
  import { listN8nExecutions } from "./n8n-executions.js";
30
30
  import { parseBuildsManifest } from "./portal-sync-builds.js";
31
+ import { selectClientSlugs } from "./template-sync.js";
31
32
  /** An active scheduled workflow with no run in this many days is silent. */
32
33
  export const CLIENT_DRIFT_SILENCE_DAYS = 7;
33
34
  const DAY_MS = 86_400_000;
34
- const SLUG = /^[a-z0-9][a-z0-9-]*$/;
35
35
  /** "(SHADOW)", "TEST run", "[test]" — but not "cardfee-test", a keyword inside a word. */
36
36
  const STALE_NAME = /(?:^|[\s([])(shadow|test)(?=$|[\s)\]:,.!-])/i;
37
37
  /** A repo-lint drift warning: `⚠ rule 16 — <message>`. Rules 12+ are the drift rules. */
@@ -43,27 +43,6 @@ const SLACK_LINES_PER_CLIENT = 12;
43
43
  const message = (error) => (error instanceof Error ? error.message : String(error));
44
44
  const short = (text, max) => text.length > max ? `${text.slice(0, max - 1)}…` : text;
45
45
  const days = (ms) => ms / DAY_MS;
46
- function clientSlugs(workspaceDir, options) {
47
- if (Boolean(options.slug) === Boolean(options.all)) {
48
- throw new Error("client-drift needs a slug or --all (one of them, not both)");
49
- }
50
- const clientsDir = join(workspaceDir, "clients");
51
- if (options.all) {
52
- if (!existsSync(clientsDir))
53
- return [];
54
- return readdirSync(clientsDir, { withFileTypes: true })
55
- .filter((e) => e.isDirectory() && e.name.startsWith("client-") && e.name !== "client-template")
56
- .map((e) => e.name.slice("client-".length))
57
- .sort();
58
- }
59
- const slug = String(options.slug).replace(/^client-/, "");
60
- if (!SLUG.test(slug))
61
- throw new Error(`"${options.slug}" is not a client slug (kebab-case, e.g. best-materials)`);
62
- if (!existsSync(join(clientsDir, `client-${slug}`))) {
63
- throw new Error(`no checkout at clients/client-${slug} under ${workspaceDir}`);
64
- }
65
- return [slug];
66
- }
67
46
  /** owner/repo of a GitHub remote URL (https or ssh), or null. */
68
47
  function githubRepo(remote) {
69
48
  const match = /github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/.exec(remote.trim());
@@ -294,11 +273,20 @@ const saysShipped = (heading) => SHIPPED_WORDS.test(heading) && !NOT_SHIPPED.tes
294
273
  const LOG_HEADING = /^##\s+(\d{4}-\d{2}-\d{2})\b\s*(.*)$/;
295
274
  const ISSUE_TOKEN = /\b[A-Z][A-Z0-9]{1,9}-\d+\b/g;
296
275
  const CLOSED_STATES = new Set(["completed", "canceled", "duplicate"]);
276
+ const FOLLOW_UPS_FIELD = /^-\s+\*\*Follow-ups?:\*\*/i;
277
+ const INDENTED = /^[ \t]+\S/;
278
+ /**
279
+ * The day client-template's repo-lint rule 20 starts: from then on, a log
280
+ * entry's Follow-ups is `none` or INS ids only (owed work, never shipped work).
281
+ * Mirrors FOLLOWUPS_INS_FROM in client-template/ci/repo-lint.mjs.
282
+ */
283
+ export const FOLLOWUPS_INS_FROM = "2026-11-08";
297
284
  /** Dated delivery-log entries. Fenced examples are skipped. */
298
285
  function logEntries(log) {
299
286
  const entries = [];
300
287
  let current = null;
301
288
  let fenced = false;
289
+ let inFollowUps = false;
302
290
  for (const line of log.split("\n")) {
303
291
  if (/^\s*```/.test(line)) {
304
292
  fenced = !fenced;
@@ -309,15 +297,19 @@ function logEntries(log) {
309
297
  const heading = LOG_HEADING.exec(line);
310
298
  if (heading) {
311
299
  const text = heading[2].replace(/^[—–-]\s*/, "").trim();
312
- current = { date: heading[1], heading: text, tokens: new Set() };
300
+ current = { date: heading[1], heading: text, tokens: new Set(), followUps: new Set() };
313
301
  entries.push(current);
314
302
  }
315
303
  else if (/^##\s/.test(line)) {
316
304
  current = null;
317
305
  }
318
- if (current)
319
- for (const match of line.matchAll(ISSUE_TOKEN))
320
- current.tokens.add(match[0]);
306
+ inFollowUps = FOLLOW_UPS_FIELD.test(line) || (inFollowUps && INDENTED.test(line));
307
+ if (!current)
308
+ continue;
309
+ // A rule-20 follow-up is owed work: it must not count as the entry naming the issue.
310
+ const into = inFollowUps && current.date >= FOLLOWUPS_INS_FROM ? current.followUps : current.tokens;
311
+ for (const match of line.matchAll(ISSUE_TOKEN))
312
+ into.add(match[0]);
321
313
  }
322
314
  return entries;
323
315
  }
@@ -331,6 +323,11 @@ function linearRows(issues, entries, now, add) {
331
323
  if (known.has(token))
332
324
  namedBy.set(token, [...(namedBy.get(token) ?? []), entry]);
333
325
  }
326
+ for (const id of entry.followUps) {
327
+ if (known.has(id) || !id.startsWith("INS-"))
328
+ continue;
329
+ add("linear", "check", id, `delivery log ${entry.date}: Follow-ups names ${id}`, "Linear: not in this client's Linear project", "Fix the id in the entry, or move the issue into this client's project (a Linear write: the account owner does it).");
330
+ }
334
331
  }
335
332
  for (const issue of issues) {
336
333
  const naming = namedBy.get(issue.identifier) ?? [];
@@ -407,7 +404,7 @@ function linearReader(options) {
407
404
  */
408
405
  export async function clientDrift(options) {
409
406
  const workspaceDir = resolve(options.workspaceDir ?? ".");
410
- const slugs = clientSlugs(workspaceDir, options);
407
+ const { slugs, adhoc } = selectClientSlugs(workspaceDir, options, "client-drift");
411
408
  const now = (options.now ?? (() => new Date()))();
412
409
  const silenceDays = options.silenceDays ?? CLIENT_DRIFT_SILENCE_DAYS;
413
410
  const execFileImpl = options.execFileImpl ?? execFileAsync;
@@ -478,6 +475,11 @@ export async function clientDrift(options) {
478
475
  "Read-only: GET /workflows and GET /executions (status only, never run data); Linear GraphQL queries (never a mutation); git status/log/remote; gh pr list; the repo's own ci/repo-lint.mjs. Nothing was written.",
479
476
  `Silence: an active scheduled workflow with no run in ${silenceDays} days. n8n keeps only its newest ~10,000 runs, so "no run kept" is drift only when the kept window is at least that long.`,
480
477
  "`check` rows are prompts for a person; only `drift` rows (and unread sources) fail the run.",
478
+ ...(adhoc.length > 0
479
+ ? [
480
+ `Skipped ad hoc repos (not official Install Agent projects; name one to check it): ${adhoc.join(", ")}.`,
481
+ ]
482
+ : []),
481
483
  ],
482
484
  };
483
485
  }
@@ -1,3 +1,4 @@
1
+ import { GEMINI_API_KEY_ENV } from "./build-estimate.js";
1
2
  /** `required` fails `ia doctor` when unset; `optional` only warns. */
2
3
  export type EnvVarTier = "required" | "optional";
3
4
  /**
@@ -48,8 +49,8 @@ export interface EnvVarSpec {
48
49
  export declare const DEFAULT_TECH_VAULT = "team-techs";
49
50
  /** Payments / DB / deploy secrets — granted case-by-case. */
50
51
  export declare const INFRA_VAULT = "team-admin";
51
- /** Only `ia secrets mint gemini-api-key` reads it, so it has no owning module. */
52
- export declare const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
52
+ /** Owned by build-estimate.ts (`ia build-estimate`); re-exported here as before. */
53
+ export { GEMINI_API_KEY_ENV };
53
54
  /** Read by apps/slack-agent (relay.ts, feedback.ts) — an app, so it has no SDK module. */
54
55
  export declare const SLACK_RELAY_SECRET_ENV = "SLACK_RELAY_SECRET";
55
56
  /** Read by nothing; registered so every team-techs item is accounted for. */
@@ -1,4 +1,5 @@
1
1
  import { N8N_API_KEY_ENV, N8N_API_URL_ENV } from "./agent-templates.js";
2
+ import { GEMINI_API_KEY_ENV } from "./build-estimate.js";
2
3
  import { HOURS_EXPORT_SECRET_ENV } from "./claude-hours.js";
3
4
  import { GITHUB_API_TOKEN_ENV } from "./client-build.js";
4
5
  import { AIRTABLE_API_TOKEN_ENV, GOOGLE_SERVICE_ACCOUNT_KEY_ENV } from "./client-drive.js";
@@ -12,8 +13,8 @@ export const DEFAULT_TECH_VAULT = "team-techs";
12
13
  /** Payments / DB / deploy secrets — granted case-by-case. */
13
14
  export const INFRA_VAULT = "team-admin";
14
15
  const OP_DEFAULT_FIELD = "value";
15
- /** Only `ia secrets mint gemini-api-key` reads it, so it has no owning module. */
16
- export const GEMINI_API_KEY_ENV = "GEMINI_API_KEY";
16
+ /** Owned by build-estimate.ts (`ia build-estimate`); re-exported here as before. */
17
+ export { GEMINI_API_KEY_ENV };
17
18
  /** Read by apps/slack-agent (relay.ts, feedback.ts) — an app, so it has no SDK module. */
18
19
  export const SLACK_RELAY_SECRET_ENV = "SLACK_RELAY_SECRET";
19
20
  /** Read by nothing; registered so every team-techs item is accounted for. */
@@ -186,7 +187,7 @@ export const ENV_VARS = [
186
187
  source: "vault",
187
188
  doctor: false,
188
189
  vault: DEFAULT_TECH_VAULT,
189
- neededBy: "ia secrets mint gemini-api-key",
190
+ neededBy: "ia build-estimate, ia secrets mint gemini-api-key",
190
191
  howToGet: inTechVault,
191
192
  section: SECTION_DRIVERS,
192
193
  },
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  export { type AccessCheckItem, type AccessCheckOptions, type AccessCheckResult, type AccessService, type AccessStatus, accessCheck, classifyKey, clientVaultFor, } from "./access-check.js";
2
2
  export { type AgentMirrorOptions, type AgentMirrorResult, checkAgentMirror, type FetchLiveWorkflowsOptions, fetchLiveWorkflows, type LiveWorkflow, type MirrorRow, type MirrorState, type MirrorSummary, } from "./agent-mirror.js";
3
3
  export { type AgentBankOptions, type AgentTemplateInfo, type AgentTemplateMatch, type CreateFromTemplateInput, type CreateFromTemplateResult, createFromAgentTemplate, type ListAgentTemplatesResult, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError, type SanitizedWorkflow, type SaveAgentTemplateInput, type SaveAgentTemplateOptions, type SaveAgentTemplateResult, type SearchAgentTemplatesOptions, type SearchAgentTemplatesResult, type SopState, type StrippedCredential, sanitizeN8nWorkflow, saveAgentTemplate, searchAgentTemplates, } from "./agent-templates.js";
4
+ export { BASIS_CHAR_CAP, BUILD_ESTIMATE_MODEL, type BuildEstimateOptions, type BuildEstimateOutcome, type BuildEstimateResult, type BuildEstimateRow, buildEstimate, buildEstimatePrompt, type EstimatePromptInput, type HoursRange, isBuildSpecFile, parseEstimateReply, redactContactDetails, removeMoney, SPEC_CHAR_CAP, setEstHours, specSectionFor, workflowNodeSummary, } from "./build-estimate.js";
4
5
  export { CLAUDE_CONFIG_DIR_ENV, type ClaudeHoursExportOptions, type ClaudeHoursExportResult, type ClaudeHoursSummaryRow, compactClaudeHoursExport, type DeliverClaudeHoursExportOptions, type DeliverClaudeHoursExportResult, deliverClaudeHoursExport, exportClaudeHours, HOURS_EXPORT_DIR, HOURS_EXPORT_SCHEMA, HOURS_EXPORT_SECRET_ENV, HOURS_EXPORT_SECRET_HEADER, HOURS_EXPORT_WEBHOOK_URL, PROMPT_WINDOW_MINUTES, parseLedgerDate, parseMinuteIso, type SaveClaudeHoursExportOptions, type SendClaudeHoursExportOptions, saveClaudeHoursExport, sendClaudeHoursExport, TOOL_INPUT_PATH_KEYS, UNATTRIBUTED_SLUG, } from "./claude-hours.js";
5
6
  export { ClientBuildAuthError, type ClientBuildDoc, type ClientBuildOptions, type ClientBuildResult, clientBuild, GITHUB_API_TOKEN_ENV, } from "./client-build.js";
6
7
  export { type ClientCall, type ClientContextOptions, type ClientContextResult, clientContext, } from "./client-context.js";
7
- export { CLIENT_DRIFT_SILENCE_DAYS, type ClientDriftClient, type ClientDriftOptions, type ClientDriftResult, clientDrift, type DriftCheck, type DriftFinding, type DriftLevel, formatClientDriftSlack, type PostClientDriftOptions, type PostClientDriftResult, postClientDriftReport, type RepoStatusInfo, type StatusFn, } from "./client-drift.js";
8
+ export { CLIENT_DRIFT_SILENCE_DAYS, type ClientDriftClient, type ClientDriftOptions, type ClientDriftResult, clientDrift, type DriftCheck, type DriftFinding, type DriftLevel, FOLLOWUPS_INS_FROM, formatClientDriftSlack, type PostClientDriftOptions, type PostClientDriftResult, postClientDriftReport, type RepoStatusInfo, type StatusFn, } from "./client-drift.js";
8
9
  export { AIRTABLE_API_TOKEN_ENV, buildAssertionClaims, ClientDriveAuthError, type ClientDriveDoc, type ClientDriveSearchOptions, type ClientDriveSearchResult, clientDriveSearch, GOOGLE_SERVICE_ACCOUNT_KEY_ENV, parseServiceAccountKey, } from "./client-drive.js";
9
10
  export { ClientIntakeAuthError, type ClientIntakeInput, type ClientIntakeOptions, type ClientIntakeResult, type ClientIntakeStep, clientIntake, LINEAR_CLIENT_TEAM_ID_ENV, } from "./client-intake.js";
10
11
  export { ClientLinearAuthError, type ClientLinearProjectOptions, clientLinearProject, parseLinearProjectSlugId, type ResolvedClientLinearProject, resolveClientLinearProject, } from "./client-linear.js";
@@ -42,10 +43,12 @@ export { detectPlatform, detectPlatformInfo, detectShell, opNeedsAnotherShell, t
42
43
  export { DEFAULT_PORTAL_URL, PORTAL_ADMIN_SECRET_ENV, PORTAL_BUILD_TYPES, PORTAL_PASSWORD_WARNING, PORTAL_SYNC_MAX_DAYS, PORTAL_URL_ENV, type PortalAddUserInput, type PortalAddUserResult, PortalAdminAuthError, type PortalAdminOptions, type PortalAgent, type PortalAgentSyncRow, type PortalBuild, type PortalBuildType, type PortalCreateAgentInput, type PortalCreateBuildInput, type PortalCreateOrgInput, type PortalCreateOrgResult, type PortalListAgentsResult, type PortalListBuildsResult, type PortalListOrgsResult, type PortalOrg, type PortalOrgUser, PortalRequestError, type PortalSetAgentNameInput, type PortalSetAgentNameResult, type PortalSetAgentStatusInput, type PortalSetAgentStatusResult, type PortalSetAgentTriageResult, type PortalSetAgentWorkflowInput, type PortalSetAgentWorkflowResult, type PortalSetBuildDetailsInput, type PortalSetBuildDetailsResult, type PortalSetBuildStatusInput, type PortalSetDriveFolderResult, type PortalSetPasswordResult, type PortalSetUserInput, type PortalSetUserResult, type PortalSyncRunsResult, type PortalTriageBackfillResult, type PortalTriageProvider, type PortalTriageRecordsPage, portalAddUser, portalBackfillTriageRecords, portalBuildType, portalBuildWorkflowId, portalCreateAgent, portalCreateBuild, portalCreateOrg, portalListAgents, portalListBuilds, portalListOrgs, portalReadTriageRecords, portalSetAgentName, portalSetAgentStatus, portalSetAgentTriage, portalSetAgentWorkflow, portalSetBuildDetails, portalSetBuildName, portalSetBuildStatus, portalSetBuildTriage, portalSetBuildWorkflow, portalSetDriveFolder, portalSetOrgSlackChannel, portalSetPassword, portalSetUser, portalSyncRuns, validatePortalBuildFields, } from "./portal-admin.js";
43
44
  export { BUILD_DESCRIPTION_MAX, BUILD_NAME_MAX, BUILDS_MANIFEST_END, BUILDS_MANIFEST_START, type BuildsManifest, type BuildsManifestSource, type BuildsManifestState, type BuildsSyncAction, type BuildsSyncActionResult, type BuildsSyncOptions, type BuildsSyncOrgResult, type BuildsSyncPlan, type BuildsSyncResult, type ManifestBuild, type ManifestBuildStatus, parseBuildsManifest, planBuildsSync, type RemoteClientMdReader, syncBuilds, } from "./portal-sync-builds.js";
44
45
  export { expectedGithubAccount, type PrOpenOptions, type PrOpenResult, parseGithubRemote, prOpen, } from "./pr-open.js";
46
+ export { CLIENT_LINE_MAX, parseRoadmapRows, ROADMAP_LABELS, ROADMAP_SOURCES, type RoadmapMigrateClient, type RoadmapMigrateOptions, type RoadmapMigrateResult, type RoadmapMigrateRow, type RoadmapRow, roadmapMigrate, } from "./roadmap-migrate.js";
47
+ export { type OnboardingChange, type OnboardingRetirePlan, planOnboardingRetire, ROADMAP_ARCHIVE, ROADMAP_FILE, type RoadmapRetireClient, type RoadmapRetireOptions, type RoadmapRetireResult, roadmapRetire, } from "./roadmap-retire.js";
45
48
  export { type StandupCallPrep, type StandupCallPrepStatus, type StandupGitState, type StandupIssueRef, type StandupLinear, type StandupOptions, type StandupRepo, type StandupRepoLint, type StandupResult, type StandupStaleTodo, standup, } from "./standup.js";
46
49
  export { type SyncRepoResult, type SyncRepoStatus, type SyncReposOptions, type SyncReposResult, syncRepos, workspaceRepoNames, } from "./sync-repos.js";
47
50
  export { type SyncTemplatesFileResult, type SyncTemplatesFileStatus, type SyncTemplatesOptions, type SyncTemplatesResult, syncTemplates, TEMPLATE_CLAUDE_SETTINGS, TEMPLATE_ROOT_DOCS, } from "./sync-templates.js";
48
- export { TEMPLATE_SYNC_EXCLUDED, TEMPLATE_SYNCED_FILES, type TemplateSyncFileResult, type TemplateSyncFileStatus, type TemplateSyncOptions, type TemplateSyncRepoResult, type TemplateSyncResult, templateSync, } from "./template-sync.js";
51
+ export { adhocReason, selectClientSlugs, TEMPLATE_RETIRED_FILES, TEMPLATE_SYNCED_FILES, type TemplateSyncFileResult, type TemplateSyncFileStatus, type TemplateSyncOptions, type TemplateSyncRepoResult, type TemplateSyncResult, templateSync, } from "./template-sync.js";
49
52
  export { TRIAGE_BACKFILL_CHUNK, type TriageBackfillOptions, type TriageBackfillResult, triageBackfill, } from "./triage-backfill.js";
50
53
  export { checkTriageRecordWiring, detectWorkflowProvider, PORTAL_INGEST_CREDENTIAL_NAME, TRIAGE_RECORDS_PATH, type TriageEnableOptions, type TriageEnableResult, type TriageWiringCheck, type TriageWiringCheckId, type TriageWiringReport, triageEnable, } from "./triage-enable.js";
51
54
  export { CRITICAL_PRIORITIES, CRITICAL_URGENCIES, detectProvider, GMAIL_HEADERS, GMAIL_LANE_BY_DISPOSITION, laneFor, OUTLOOK_HEADERS, OUTLOOK_LANE_BY_CATEGORY, parseCsv, parseLaneOverrides, type RecordTable, readRecordSheetTable, resolveRecordSheetId, SHEETS_SCOPE, seededRandom, TRIAGE_GATES, TRIAGE_LANES, TRIAGE_STAGES, type TriageGateSampleOptions, type TriageGateSampleResult, type TriageHealthOptions, type TriageHealthResult, type TriageLane, type TriageProvider, type TriageRecordRow, type TriageSampleRow, type TriageSoakReportOptions, type TriageSoakReportResult, type TriageSourceOptions, type TriageStage, type TriageWindow, triageGateSample, triageHealth, triageSoakReport, } from "./triage-gates.js";
package/dist/index.js CHANGED
@@ -4,10 +4,11 @@
4
4
  export { accessCheck, classifyKey, clientVaultFor, } from "./access-check.js";
5
5
  export { checkAgentMirror, fetchLiveWorkflows, } from "./agent-mirror.js";
6
6
  export { createFromAgentTemplate, listAgentTemplates, N8N_API_KEY_ENV, N8N_API_URL_ENV, N8nAuthError, sanitizeN8nWorkflow, saveAgentTemplate, searchAgentTemplates, } from "./agent-templates.js";
7
+ export { BASIS_CHAR_CAP, BUILD_ESTIMATE_MODEL, buildEstimate, buildEstimatePrompt, isBuildSpecFile, parseEstimateReply, redactContactDetails, removeMoney, SPEC_CHAR_CAP, setEstHours, specSectionFor, workflowNodeSummary, } from "./build-estimate.js";
7
8
  export { CLAUDE_CONFIG_DIR_ENV, compactClaudeHoursExport, deliverClaudeHoursExport, exportClaudeHours, HOURS_EXPORT_DIR, HOURS_EXPORT_SCHEMA, HOURS_EXPORT_SECRET_ENV, HOURS_EXPORT_SECRET_HEADER, HOURS_EXPORT_WEBHOOK_URL, PROMPT_WINDOW_MINUTES, parseLedgerDate, parseMinuteIso, saveClaudeHoursExport, sendClaudeHoursExport, TOOL_INPUT_PATH_KEYS, UNATTRIBUTED_SLUG, } from "./claude-hours.js";
8
9
  export { ClientBuildAuthError, clientBuild, GITHUB_API_TOKEN_ENV, } from "./client-build.js";
9
10
  export { clientContext, } from "./client-context.js";
10
- export { CLIENT_DRIFT_SILENCE_DAYS, clientDrift, formatClientDriftSlack, postClientDriftReport, } from "./client-drift.js";
11
+ export { CLIENT_DRIFT_SILENCE_DAYS, clientDrift, FOLLOWUPS_INS_FROM, formatClientDriftSlack, postClientDriftReport, } from "./client-drift.js";
11
12
  export { AIRTABLE_API_TOKEN_ENV, buildAssertionClaims, ClientDriveAuthError, clientDriveSearch, GOOGLE_SERVICE_ACCOUNT_KEY_ENV, parseServiceAccountKey, } from "./client-drive.js";
12
13
  export { ClientIntakeAuthError, clientIntake, LINEAR_CLIENT_TEAM_ID_ENV, } from "./client-intake.js";
13
14
  export { ClientLinearAuthError, clientLinearProject, parseLinearProjectSlugId, resolveClientLinearProject, } from "./client-linear.js";
@@ -45,10 +46,12 @@ export { detectPlatform, detectPlatformInfo, detectShell, opNeedsAnotherShell, }
45
46
  export { DEFAULT_PORTAL_URL, PORTAL_ADMIN_SECRET_ENV, PORTAL_BUILD_TYPES, PORTAL_PASSWORD_WARNING, PORTAL_SYNC_MAX_DAYS, PORTAL_URL_ENV, PortalAdminAuthError, PortalRequestError, portalAddUser, portalBackfillTriageRecords, portalBuildType, portalBuildWorkflowId, portalCreateAgent, portalCreateBuild, portalCreateOrg, portalListAgents, portalListBuilds, portalListOrgs, portalReadTriageRecords, portalSetAgentName, portalSetAgentStatus, portalSetAgentTriage, portalSetAgentWorkflow, portalSetBuildDetails, portalSetBuildName, portalSetBuildStatus, portalSetBuildTriage, portalSetBuildWorkflow, portalSetDriveFolder, portalSetOrgSlackChannel, portalSetPassword, portalSetUser, portalSyncRuns, validatePortalBuildFields, } from "./portal-admin.js";
46
47
  export { BUILD_DESCRIPTION_MAX, BUILD_NAME_MAX, BUILDS_MANIFEST_END, BUILDS_MANIFEST_START, parseBuildsManifest, planBuildsSync, syncBuilds, } from "./portal-sync-builds.js";
47
48
  export { expectedGithubAccount, parseGithubRemote, prOpen, } from "./pr-open.js";
49
+ export { CLIENT_LINE_MAX, parseRoadmapRows, ROADMAP_LABELS, ROADMAP_SOURCES, roadmapMigrate, } from "./roadmap-migrate.js";
50
+ export { planOnboardingRetire, ROADMAP_ARCHIVE, ROADMAP_FILE, roadmapRetire, } from "./roadmap-retire.js";
48
51
  export { standup, } from "./standup.js";
49
52
  export { syncRepos, workspaceRepoNames, } from "./sync-repos.js";
50
53
  export { syncTemplates, TEMPLATE_CLAUDE_SETTINGS, TEMPLATE_ROOT_DOCS, } from "./sync-templates.js";
51
- export { TEMPLATE_SYNC_EXCLUDED, TEMPLATE_SYNCED_FILES, templateSync, } from "./template-sync.js";
54
+ export { adhocReason, selectClientSlugs, TEMPLATE_RETIRED_FILES, TEMPLATE_SYNCED_FILES, templateSync, } from "./template-sync.js";
52
55
  export { TRIAGE_BACKFILL_CHUNK, triageBackfill, } from "./triage-backfill.js";
53
56
  export { checkTriageRecordWiring, detectWorkflowProvider, PORTAL_INGEST_CREDENTIAL_NAME, TRIAGE_RECORDS_PATH, triageEnable, } from "./triage-enable.js";
54
57
  export { CRITICAL_PRIORITIES, CRITICAL_URGENCIES, detectProvider, GMAIL_HEADERS, GMAIL_LANE_BY_DISPOSITION, laneFor, OUTLOOK_HEADERS, OUTLOOK_LANE_BY_CATEGORY, parseCsv, parseLaneOverrides, readRecordSheetTable, resolveRecordSheetId, SHEETS_SCOPE, seededRandom, TRIAGE_GATES, TRIAGE_LANES, TRIAGE_STAGES, triageGateSample, triageHealth, triageSoakReport, } from "./triage-gates.js";
@@ -68,6 +68,12 @@ export interface PortalBuild {
68
68
  url?: string | null;
69
69
  /** ISO time the build was registered (its go-live date). Absent on portals older than 2026-10-16. */
70
70
  createdAt?: string;
71
+ /**
72
+ * Market hours to build it, [low, high] (CLIENT.md `est_hours`); null = no
73
+ * estimate. Hours only: the rate lives in the portal. Absent on portals
74
+ * older than INS-1380.
75
+ */
76
+ estHours?: [number, number] | null;
71
77
  }
72
78
  /** Old name of `PortalBuild`, kept as an alias until the full rename. */
73
79
  export type PortalAgent = PortalBuild;
@@ -272,6 +278,8 @@ export interface PortalSetBuildDetailsInput {
272
278
  description?: string;
273
279
  /** Omit to leave as is; null clears the Open link. https only. */
274
280
  url?: string | null;
281
+ /** Omit to leave as is; null clears it. [low, high]: whole hours, 1 or more, low ≤ high. */
282
+ estHours?: [number, number] | null;
275
283
  }
276
284
  export interface PortalSetBuildDetailsResult {
277
285
  org: string;
@@ -279,16 +287,21 @@ export interface PortalSetBuildDetailsResult {
279
287
  previous: {
280
288
  description: string;
281
289
  url: string | null;
290
+ estHours?: [number, number] | null;
282
291
  };
283
292
  description: string;
284
293
  url: string | null;
294
+ /** Absent on portals older than INS-1380. */
295
+ estHours?: [number, number] | null;
285
296
  /** False when nothing differed — the call is idempotent. */
286
297
  changed: boolean;
287
298
  }
288
299
  /**
289
300
  * Change the card text under a build's name: its description and/or its url
290
- * (an app's Open link). Before this route (team-web, 2026-10-31) only the
291
- * create could set either. A portal without the route answers 404.
301
+ * (an app's Open link), and its market-hours estimate (`estHours`, never a
302
+ * dollar figure). Before this route (team-web, 2026-10-31) only the create
303
+ * could set either. A portal without the route answers 404; a portal older
304
+ * than INS-1380 refuses a call that sends only `estHours`.
292
305
  */
293
306
  export declare function portalSetBuildDetails(input: PortalSetBuildDetailsInput, options?: PortalAdminOptions): Promise<PortalSetBuildDetailsResult>;
294
307
  /**
@@ -239,10 +239,19 @@ export async function portalSetBuildName(input, options = {}) {
239
239
  export async function portalSetAgentName(input, options = {}) {
240
240
  return portalSetBuildName({ slug: input.slug, build: input.agent, name: input.name }, options);
241
241
  }
242
+ /** [low, high]: two whole numbers of hours, 1 or more, low ≤ high. */
243
+ function isHoursRange(value) {
244
+ return (Array.isArray(value) &&
245
+ value.length === 2 &&
246
+ value.every((hours) => Number.isSafeInteger(hours) && hours > 0) &&
247
+ value[0] <= value[1]);
248
+ }
242
249
  /**
243
250
  * Change the card text under a build's name: its description and/or its url
244
- * (an app's Open link). Before this route (team-web, 2026-10-31) only the
245
- * create could set either. A portal without the route answers 404.
251
+ * (an app's Open link), and its market-hours estimate (`estHours`, never a
252
+ * dollar figure). Before this route (team-web, 2026-10-31) only the create
253
+ * could set either. A portal without the route answers 404; a portal older
254
+ * than INS-1380 refuses a call that sends only `estHours`.
246
255
  */
247
256
  export async function portalSetBuildDetails(input, options = {}) {
248
257
  const slug = normalizeSlug(input.slug, "org");
@@ -253,14 +262,18 @@ export async function portalSetBuildDetails(input, options = {}) {
253
262
  const url = input.url === null ? null : input.url?.trim();
254
263
  if (url && !isHttpsUrl(url))
255
264
  throw new Error(`url must be an https:// address (got "${url}")`);
256
- if (description === undefined && url === undefined) {
257
- throw new Error("give a description and/or a url to change");
265
+ if (input.estHours !== undefined && input.estHours !== null && !isHoursRange(input.estHours)) {
266
+ throw new Error("estHours must be [low, high]: two whole numbers of hours, 1 or more, low ≤ high");
267
+ }
268
+ if (description === undefined && url === undefined && input.estHours === undefined) {
269
+ throw new Error("give a description, a url and/or estHours to change");
258
270
  }
259
271
  return portalRequest("POST", `${BUILDS_PATH}/details`, options, {
260
272
  slug,
261
273
  agent: build,
262
274
  ...(description !== undefined ? { description } : {}),
263
275
  ...(url !== undefined ? { url: url || null } : {}),
276
+ ...(input.estHours !== undefined ? { estHours: input.estHours } : {}),
264
277
  });
265
278
  }
266
279
  /**
@@ -19,6 +19,12 @@ export interface ManifestBuild {
19
19
  status: ManifestBuildStatus;
20
20
  /** Absent = not managed here; null = explicitly not a triage agent. */
21
21
  triage?: PortalTriageProvider | null;
22
+ /**
23
+ * Market hours to build it, [low, high], from `ia build-estimate`. Never a
24
+ * dollar figure: the portal turns it into a cost range when it renders.
25
+ * Absent = no estimate yet.
26
+ */
27
+ estHours?: [number, number];
22
28
  }
23
29
  export type BuildsManifestState =
24
30
  /** No markers: the repo predates the manifest. Skipped. */
@@ -46,6 +52,8 @@ export type BuildsSyncAction = {
46
52
  url: string | null;
47
53
  status: ManifestBuildStatus;
48
54
  triage: PortalTriageProvider | null;
55
+ /** Set after the create, through the details route. */
56
+ estHours: [number, number] | null;
49
57
  } | {
50
58
  kind: "repoint";
51
59
  build: string;
@@ -67,6 +75,11 @@ export type BuildsSyncAction = {
67
75
  from: string | null;
68
76
  to: string | null;
69
77
  };
78
+ /** Market hours, never dollars. */
79
+ estHours?: {
80
+ from: [number, number] | null;
81
+ to: [number, number] | null;
82
+ };
70
83
  } | {
71
84
  kind: "status";
72
85
  build: string;
@@ -117,6 +130,8 @@ export interface BuildsSyncOrgResult {
117
130
  actions: BuildsSyncActionResult[];
118
131
  registryOnly: BuildsSyncPlan["registryOnly"];
119
132
  conflicts: string[];
133
+ /** Active manifest rows with no `est_hours` (an info line, never a change). */
134
+ unestimated: number;
120
135
  }
121
136
  export interface BuildsSyncResult {
122
137
  applied: boolean;
@@ -127,6 +142,8 @@ export interface BuildsSyncResult {
127
142
  actionCount: number;
128
143
  /** Apply only: actions the portal refused. */
129
144
  failedCount: number;
145
+ /** Active builds, across all orgs, whose row has no `est_hours`. */
146
+ unestimatedCount: number;
130
147
  }
131
148
  /** Reads `clients/client-<slug>/CLIENT.md` from GitHub when the repo is not cloned. Null = not there. */
132
149
  export type RemoteClientMdReader = (slug: string) => Promise<string | null>;
@@ -149,7 +166,7 @@ export interface BuildsSyncOptions {
149
166
  /**
150
167
  * Compares every client repo's `## Builds` manifest with the portal's builds
151
168
  * registry and, with `apply`, moves the registry to match: create, rename,
152
- * description/url, status, triage, repoint. Never deletes, never touches
169
+ * description/url/est_hours, status, triage, repoint. Never deletes, never touches
153
170
  * Install Agent's own org, never writes a client repo. A second run after an
154
171
  * apply plans nothing.
155
172
  */
@@ -12,8 +12,10 @@ import { portalBuildType, portalBuildWorkflowId, portalCreateBuild, portalListBu
12
12
  // manifest does not name is reported, not changed.
13
13
  //
14
14
  // The validator below has a twin in client-template (`ci/builds-manifest.mjs`,
15
- // repo-lint rule 11). The repos never import each other, so a rule change
16
- // lands in both files in the same piece of work.
15
+ // repo-lint rule 11) and a read-only copy in the portal
16
+ // (team-web/apps/portal/lib/builds-manifest.ts, whose drift test runs all
17
+ // three). The repos never import each other, so a rule change lands in all
18
+ // three files in the same piece of work.
17
19
  export const BUILDS_MANIFEST_START = "<!-- BUILDS:START -->";
18
20
  export const BUILDS_MANIFEST_END = "<!-- BUILDS:END -->";
19
21
  export const BUILD_NAME_MAX = 120;
@@ -29,7 +31,15 @@ const ROW_KEYS = new Set([
29
31
  "url",
30
32
  "status",
31
33
  "triage",
34
+ "est_hours",
32
35
  ]);
36
+ /** `est_hours`: [low, high], two positive whole numbers, low ≤ high. */
37
+ function isHoursRange(value) {
38
+ return (Array.isArray(value) &&
39
+ value.length === 2 &&
40
+ value.every((hours) => Number.isSafeInteger(hours) && hours > 0) &&
41
+ value[0] <= value[1]);
42
+ }
33
43
  function isHttps(value) {
34
44
  try {
35
45
  return new URL(value).protocol === "https:" && value.startsWith("https://");
@@ -95,6 +105,8 @@ function readRow(raw, index, errors) {
95
105
  row.triage !== "gmail" &&
96
106
  row.triage !== "outlook")
97
107
  fail("triage must be gmail|outlook (or null)");
108
+ if (row.est_hours !== undefined && !isHoursRange(row.est_hours))
109
+ fail("est_hours must be [low, high]: two positive whole numbers, low ≤ high");
98
110
  if (errors.length > before)
99
111
  return null;
100
112
  return {
@@ -106,6 +118,9 @@ function readRow(raw, index, errors) {
106
118
  url,
107
119
  status: row.status,
108
120
  ...(row.triage !== undefined ? { triage: row.triage } : {}),
121
+ ...(isHoursRange(row.est_hours)
122
+ ? { estHours: [row.est_hours[0], row.est_hours[1]] }
123
+ : {}),
109
124
  };
110
125
  }
111
126
  /** Reads and validates the `## Builds` block of a CLIENT.md. Pure. */
@@ -163,6 +178,9 @@ export function parseBuildsManifest(clientMd) {
163
178
  }
164
179
  return errors.length > 0 ? { state: "invalid", rows: [], errors } : { state: "ok", rows, errors };
165
180
  }
181
+ function sameHours(a, b) {
182
+ return a === null || b === null ? a === b : a[0] === b[0] && a[1] === b[1];
183
+ }
166
184
  /**
167
185
  * Plans one org. Pure: `registry` is every build in the registry (all orgs),
168
186
  * because an n8n workflow id is unique across the whole registry.
@@ -222,6 +240,7 @@ export function planBuildsSync(org, manifest, registry) {
222
240
  url: row.url,
223
241
  status: row.status,
224
242
  triage: row.triage ?? null,
243
+ estHours: row.estHours ?? null,
225
244
  });
226
245
  continue;
227
246
  }
@@ -240,7 +259,16 @@ export function planBuildsSync(org, manifest, registry) {
240
259
  if (row.type === "app" && currentUrl !== row.url) {
241
260
  details.url = { from: currentUrl, to: row.url };
242
261
  }
243
- if (details.description || details.url)
262
+ // A portal older than INS-1380 does not report the field: leave it alone.
263
+ // The manifest is the only writer, so a row with no est_hours clears it.
264
+ if (current.estHours !== undefined) {
265
+ const currentHours = current.estHours ?? null;
266
+ const wantedHours = row.estHours ?? null;
267
+ if (!sameHours(currentHours, wantedHours)) {
268
+ details.estHours = { from: currentHours, to: wantedHours };
269
+ }
270
+ }
271
+ if (details.description || details.url || details.estHours)
244
272
  followUps.push(details);
245
273
  if (current.status !== row.status) {
246
274
  followUps.push({ kind: "status", build: row.build, from: current.status, to: row.status });
@@ -311,6 +339,8 @@ async function applyAction(action, org, portal) {
311
339
  await portalSetBuildStatus({ ...ref, status: action.status }, portal);
312
340
  if (action.triage)
313
341
  await portalSetBuildTriage({ ...ref, provider: action.triage }, portal);
342
+ if (action.estHours)
343
+ await portalSetBuildDetails({ ...ref, estHours: action.estHours }, portal);
314
344
  return;
315
345
  case "repoint":
316
346
  await portalSetBuildWorkflow({ ...ref, workflowId: action.to }, portal);
@@ -323,6 +353,7 @@ async function applyAction(action, org, portal) {
323
353
  ...ref,
324
354
  ...(action.description ? { description: action.description.to } : {}),
325
355
  ...(action.url ? { url: action.url.to } : {}),
356
+ ...(action.estHours ? { estHours: action.estHours.to } : {}),
326
357
  }, portal);
327
358
  return;
328
359
  case "status":
@@ -336,7 +367,7 @@ async function applyAction(action, org, portal) {
336
367
  /**
337
368
  * Compares every client repo's `## Builds` manifest with the portal's builds
338
369
  * registry and, with `apply`, moves the registry to match: create, rename,
339
- * description/url, status, triage, repoint. Never deletes, never touches
370
+ * description/url/est_hours, status, triage, repoint. Never deletes, never touches
340
371
  * Install Agent's own org, never writes a client repo. A second run after an
341
372
  * apply plans nothing.
342
373
  */
@@ -375,7 +406,7 @@ export async function syncBuilds(options) {
375
406
  errors.push(error instanceof Error ? error.message : String(error));
376
407
  }
377
408
  }
378
- const empty = { actions: [], registryOnly: [], conflicts: [] };
409
+ const empty = { actions: [], registryOnly: [], conflicts: [], unestimated: 0 };
379
410
  if (clientMd === null) {
380
411
  orgs.push({ org, source, manifest: "no-repo", errors, ...empty });
381
412
  continue;
@@ -411,6 +442,7 @@ export async function syncBuilds(options) {
411
442
  actions,
412
443
  registryOnly: plan.registryOnly,
413
444
  conflicts: plan.conflicts,
445
+ unestimated: manifest.rows.filter((row) => row.status === "active" && !row.estHours).length,
414
446
  });
415
447
  }
416
448
  const all = orgs.flatMap((org) => org.actions);
@@ -420,5 +452,6 @@ export async function syncBuilds(options) {
420
452
  skippedOrgs,
421
453
  actionCount: all.length,
422
454
  failedCount: all.filter((a) => typeof a.outcome === "object").length,
455
+ unestimatedCount: orgs.reduce((sum, org) => sum + org.unestimated, 0),
423
456
  };
424
457
  }
@@ -0,0 +1,75 @@
1
+ export declare const ROADMAP_SOURCES: string[];
2
+ export declare const CLIENT_LINE_MAX = 140;
3
+ export declare const ROADMAP_LABELS: readonly ["value", "client-ask", "parked"];
4
+ export interface RoadmapRow {
5
+ rank: string;
6
+ work: string;
7
+ tag: string;
8
+ status: string;
9
+ clientLine: string;
10
+ /** The first INS id in the Work column: the row's issue. */
11
+ id: string | null;
12
+ /** Every other INS id the row names, for a person to check. */
13
+ alsoNamed: string[];
14
+ }
15
+ export interface RoadmapMigrateRow extends RoadmapRow {
16
+ /** The issue's state type in Linear, or null when there is no issue to read. */
17
+ linearState: string | null;
18
+ /** null when there is nothing to compare (no issue). */
19
+ stateMatches: boolean | null;
20
+ labelsToAdd: string[];
21
+ clientLineToAdd: string | null;
22
+ /** Why the row's Client line is not added. */
23
+ refused: string | null;
24
+ /** Why the row cannot be migrated as it is (no INS id, not in the project). */
25
+ problem: string | null;
26
+ /** apply only: this row's labels / description were written. */
27
+ applied?: boolean;
28
+ }
29
+ export interface RoadmapMigrateClient {
30
+ slug: string;
31
+ dir: string;
32
+ /** The roadmap file that was read, repo-relative. */
33
+ source: string | null;
34
+ project: {
35
+ name: string;
36
+ url: string;
37
+ } | null;
38
+ rows: RoadmapMigrateRow[];
39
+ /** Set when this client was not migrated, with the reason. */
40
+ skipped: string | null;
41
+ }
42
+ export interface RoadmapMigrateResult {
43
+ workspaceDir: string;
44
+ clients: RoadmapMigrateClient[];
45
+ /** --all only: the ad hoc repos left out (see adhocReason). */
46
+ adhocSkipped: string[];
47
+ /** Labels the planned writes need that Linear does not have yet. */
48
+ labelsToCreate: string[];
49
+ /** apply only: the labels created. */
50
+ createdLabels: string[];
51
+ applied: boolean;
52
+ /** apply only: the number of Linear mutations sent. */
53
+ writes: number;
54
+ notes: string[];
55
+ }
56
+ export interface RoadmapMigrateOptions {
57
+ /** The installagent/ workspace root (contains clients/). */
58
+ workspaceDir?: string;
59
+ /** One client, without the `client-` prefix. Give this or `all`. */
60
+ slug?: string;
61
+ all?: boolean;
62
+ /** Write labels and descriptions. Default false: report only. */
63
+ apply?: boolean;
64
+ /** Linear API key; defaults to $LINEAR_API_TOKEN. */
65
+ token?: string;
66
+ env?: NodeJS.ProcessEnv;
67
+ fetchImpl?: typeof fetch;
68
+ }
69
+ /** The rows of the roadmap's "## Ranked list" table. Fenced examples are skipped. */
70
+ export declare function parseRoadmapRows(md: string): RoadmapRow[];
71
+ /**
72
+ * Plan (and, with `apply`, write) the move of each client's roadmap rows into
73
+ * Linear. See the header of this file for what is read and what is written.
74
+ */
75
+ export declare function roadmapMigrate(options: RoadmapMigrateOptions): Promise<RoadmapMigrateResult>;