@integrity-labs/agt-cli 0.23.1 → 0.24.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.
@@ -8,7 +8,7 @@ import {
8
8
  parseDeliveryTarget,
9
9
  registerFramework,
10
10
  wrapScheduledTaskPrompt
11
- } from "./chunk-2TOCO5D2.js";
11
+ } from "./chunk-HSIESZMZ.js";
12
12
 
13
13
  // ../../packages/core/dist/integrations/registry.js
14
14
  var INTEGRATION_REGISTRY = [
@@ -2284,158 +2284,6 @@ function extractAllowedDomains(input) {
2284
2284
  }
2285
2285
  registerFramework(nemoClawAdapter);
2286
2286
 
2287
- // ../../packages/core/dist/provisioning/frameworks/claudecode/index.js
2288
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync5, chmodSync as chmodSync4, readdirSync, rmSync, copyFileSync } from "fs";
2289
- import { join as join4, relative, dirname as dirname4 } from "path";
2290
- import { homedir as homedir3 } from "os";
2291
- import { execFile as execFile3 } from "child_process";
2292
-
2293
- // ../../packages/core/dist/provisioning/mcp-config-guards.js
2294
- import { existsSync as existsSync4, readFileSync as readFileSync4, renameSync as renameSync3, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3 } from "fs";
2295
- var REQUIRED_ENV_RULES_BY_SERVER = {
2296
- "cloud-broker": [
2297
- { key: "AGT_HOST", mustBeConcrete: false },
2298
- { key: "AGT_API_KEY", mustBeConcrete: false },
2299
- // ENG-4744: this is the bug shape — writer used to omit this
2300
- // entirely, or render it as a literal `${AGT_AGENT_ID}` instead
2301
- // of the agent's real UUID. The broker has no way to substitute
2302
- // it post-spawn, so a placeholder here = silently broken agent.
2303
- { key: "AGT_AGENT_ID", mustBeConcrete: true }
2304
- ]
2305
- };
2306
- var PLACEHOLDER_RE = /\$\{[^}]+\}/;
2307
- function validateRenderedMcpConfig(config) {
2308
- const errors = [];
2309
- if (typeof config !== "object" || config === null || Array.isArray(config)) {
2310
- return {
2311
- ok: false,
2312
- errors: [
2313
- {
2314
- kind: "invalid_json_shape",
2315
- server: "*",
2316
- message: "config root must be a non-null object"
2317
- }
2318
- ]
2319
- };
2320
- }
2321
- const root = config;
2322
- if (root.mcpServers === void 0) {
2323
- return { ok: true };
2324
- }
2325
- if (typeof root.mcpServers !== "object" || root.mcpServers === null) {
2326
- return {
2327
- ok: false,
2328
- errors: [
2329
- {
2330
- kind: "invalid_json_shape",
2331
- server: "*",
2332
- message: "mcpServers must be an object"
2333
- }
2334
- ]
2335
- };
2336
- }
2337
- if (Array.isArray(root.mcpServers)) {
2338
- return {
2339
- ok: false,
2340
- errors: [
2341
- {
2342
- kind: "invalid_json_shape",
2343
- server: "*",
2344
- message: "mcpServers must be an object"
2345
- }
2346
- ]
2347
- };
2348
- }
2349
- for (const [serverKey, raw] of Object.entries(root.mcpServers)) {
2350
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
2351
- errors.push({
2352
- kind: "invalid_json_shape",
2353
- server: serverKey,
2354
- message: `entry must be an object`
2355
- });
2356
- continue;
2357
- }
2358
- const entry = raw;
2359
- const entryRecord = entry;
2360
- if (typeof entryRecord["url"] === "string") {
2361
- const type = entryRecord["type"];
2362
- if (type !== "http" && type !== "sse") {
2363
- errors.push({
2364
- kind: "remote_mcp_missing_type",
2365
- server: serverKey,
2366
- message: `url-based entry must include \`type: "http"\` or \`type: "sse"\` (Claude Code MCP schema requires it)`
2367
- });
2368
- }
2369
- }
2370
- const rules = REQUIRED_ENV_RULES_BY_SERVER[serverKey];
2371
- if (rules) {
2372
- const env = entry.env ?? {};
2373
- for (const rule of rules) {
2374
- const value = env[rule.key];
2375
- if (typeof value !== "string" || value.length === 0) {
2376
- errors.push({
2377
- kind: "missing_required_env",
2378
- server: serverKey,
2379
- message: `missing required env key: ${rule.key}`
2380
- });
2381
- continue;
2382
- }
2383
- if (rule.mustBeConcrete && PLACEHOLDER_RE.test(value)) {
2384
- errors.push({
2385
- kind: "unexpanded_placeholder",
2386
- server: serverKey,
2387
- message: `env.${rule.key} contains an unexpanded \${...} placeholder; expected a concrete value`
2388
- });
2389
- }
2390
- }
2391
- }
2392
- }
2393
- return errors.length === 0 ? { ok: true } : { ok: false, errors };
2394
- }
2395
- function formatValidationErrors(errors) {
2396
- return errors.map((e) => `${e.server}:${e.kind}=${e.message}`).join("; ");
2397
- }
2398
- function safeWriteJsonAtomic(path, content, opts = {}) {
2399
- const keepBackup = opts.keepBackup !== false;
2400
- const rename = opts.renamer ?? renameSync3;
2401
- const tmpPath = `${path}.new`;
2402
- const bakPath = `${path}.bak`;
2403
- let movedOriginalToBackup = false;
2404
- try {
2405
- writeFileSync4(tmpPath, content);
2406
- } catch (err) {
2407
- throw err;
2408
- }
2409
- try {
2410
- if (keepBackup && existsSync4(path)) {
2411
- rename(path, bakPath);
2412
- movedOriginalToBackup = true;
2413
- }
2414
- rename(tmpPath, path);
2415
- } catch (err) {
2416
- try {
2417
- if (existsSync4(tmpPath))
2418
- unlinkSync3(tmpPath);
2419
- } catch {
2420
- }
2421
- if (movedOriginalToBackup && !existsSync4(path) && existsSync4(bakPath)) {
2422
- try {
2423
- renameSync3(bakPath, path);
2424
- } catch {
2425
- }
2426
- }
2427
- throw err;
2428
- }
2429
- }
2430
- function safeWriteMcpJson(path, config) {
2431
- const validation = validateRenderedMcpConfig(config);
2432
- if (!validation.ok) {
2433
- return { written: false, errors: validation.errors };
2434
- }
2435
- safeWriteJsonAtomic(path, JSON.stringify(config, null, 2));
2436
- return { written: true, errors: [] };
2437
- }
2438
-
2439
2287
  // ../../packages/core/dist/provisioning/frameworks/claudecode/identity.js
2440
2288
  function buildMemorySection(hasQmd) {
2441
2289
  const recall = hasQmd ? `### Recall
@@ -2625,6 +2473,46 @@ later tick:
2625
2473
 
2626
2474
  `;
2627
2475
  }
2476
+ var ACTIVE_TASKS_MAX_CHARS = 800;
2477
+ var ACTIVE_TASKS_TRUNCATION_SUFFIX = "\u2026 (truncated)\n\n";
2478
+ function sanitizePromptText(value) {
2479
+ return value.replace(/[-]+/g, " ").replace(/\s+/g, " ").trim();
2480
+ }
2481
+ function buildActiveTasksSection(activeTasks) {
2482
+ if (!activeTasks || activeTasks.length === 0)
2483
+ return "";
2484
+ const lines = [
2485
+ `## Active tasks (${activeTasks.length})`,
2486
+ "",
2487
+ `You have ${activeTasks.length} kanban task(s) still open from previous`,
2488
+ `sessions. If an incoming conversation maps to one of them, keep it in`,
2489
+ `mind; close it with \`kanban_done\` and reply to the originating thread`,
2490
+ `before stopping.`,
2491
+ ""
2492
+ ];
2493
+ for (const t of activeTasks) {
2494
+ const status = sanitizePromptText(t.status);
2495
+ const id = sanitizePromptText(t.id);
2496
+ const title = sanitizePromptText(t.title);
2497
+ const sourceParts = [];
2498
+ if (t.source_channel && t.source_thread_id) {
2499
+ sourceParts.push(`${sanitizePromptText(t.source_channel)} thread ${sanitizePromptText(t.source_thread_id)}`);
2500
+ }
2501
+ if (t.source_url)
2502
+ sourceParts.push(sanitizePromptText(t.source_url));
2503
+ const source = sourceParts.length > 0 ? ` \u2014 ${sourceParts.join(" \u2022 ")}` : "";
2504
+ lines.push(`- [${status}] ${id}: "${title}"${source}`);
2505
+ }
2506
+ let rendered = lines.join("\n") + "\n\n";
2507
+ if (rendered.length > ACTIVE_TASKS_MAX_CHARS) {
2508
+ rendered = rendered.slice(0, ACTIVE_TASKS_MAX_CHARS - ACTIVE_TASKS_TRUNCATION_SUFFIX.length) + ACTIVE_TASKS_TRUNCATION_SUFFIX;
2509
+ }
2510
+ return rendered;
2511
+ }
2512
+ function estimateActiveTasksTokens(activeTasks) {
2513
+ const rendered = buildActiveTasksSection(activeTasks);
2514
+ return Math.ceil(rendered.length / 4);
2515
+ }
2628
2516
  function buildSkillAuthoringSection() {
2629
2517
  return `## Skill authoring
2630
2518
 
@@ -2975,7 +2863,7 @@ function buildGuardrailsSection(guardrails) {
2975
2863
  return blocks.join("\n") + "\n";
2976
2864
  }
2977
2865
  function generateClaudeMd(input) {
2978
- const { frontmatter, role, description, resolvedChannels, team, organization, hasQmd, integrations, knowledge, timezone, reportsTo, personalitySeed, teamMembers, people, peerGates, guardrails } = input;
2866
+ const { frontmatter, role, description, resolvedChannels, team, organization, hasQmd, integrations, knowledge, timezone, reportsTo, personalitySeed, teamMembers, people, peerGates, guardrails, activeTasks } = input;
2979
2867
  const consoleUrl = input.consoleUrl ?? "https://app.augmented.team";
2980
2868
  const channelList = resolvedChannels?.length ? resolvedChannels.join(", ") : "none";
2981
2869
  const roleDisplay = role ?? "Agent";
@@ -2992,6 +2880,7 @@ function generateClaudeMd(input) {
2992
2880
  const peopleSection = buildPeopleSection(people);
2993
2881
  const multiAgentSection = buildMultiAgentSection(frontmatter, peerGates);
2994
2882
  const guardrailsSection = buildGuardrailsSection(guardrails);
2883
+ const activeTasksSection = buildActiveTasksSection(activeTasks);
2995
2884
  return `# ${frontmatter.display_name}
2996
2885
 
2997
2886
  You are **${frontmatter.display_name}**, **${roleDisplay}**${// ENG-5009: render org context alongside team so introductions are
@@ -3047,7 +2936,7 @@ If the work turns out to be unexpectedly slow after you started inline,
3047
2936
  finish the current sub-step, then dispatch the rest. Don't apologise for
3048
2937
  mid-task switching \u2014 operators care about responsiveness, not consistency.
3049
2938
  ${buildProgressHeartbeatSection(resolvedChannels)}
3050
- ${personalitySection}## Identity
2939
+ ${activeTasksSection}${personalitySection}## Identity
3051
2940
 
3052
2941
  - Code Name: ${frontmatter.code_name}
3053
2942
  - Owner: ${frontmatter.owner.name}
@@ -3352,6 +3241,158 @@ The marginal cost of completeness is near zero. Do the whole thing.
3352
3241
  ${frontmatter.environment === "prod" ? "- Production environment: exercise extra caution with all operations.\n" : ""}`;
3353
3242
  }
3354
3243
 
3244
+ // ../../packages/core/dist/provisioning/frameworks/claudecode/index.js
3245
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync5, mkdirSync as mkdirSync4, existsSync as existsSync5, chmodSync as chmodSync4, readdirSync, rmSync, copyFileSync } from "fs";
3246
+ import { join as join4, relative, dirname as dirname4 } from "path";
3247
+ import { homedir as homedir3 } from "os";
3248
+ import { execFile as execFile3 } from "child_process";
3249
+
3250
+ // ../../packages/core/dist/provisioning/mcp-config-guards.js
3251
+ import { existsSync as existsSync4, readFileSync as readFileSync4, renameSync as renameSync3, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3 } from "fs";
3252
+ var REQUIRED_ENV_RULES_BY_SERVER = {
3253
+ "cloud-broker": [
3254
+ { key: "AGT_HOST", mustBeConcrete: false },
3255
+ { key: "AGT_API_KEY", mustBeConcrete: false },
3256
+ // ENG-4744: this is the bug shape — writer used to omit this
3257
+ // entirely, or render it as a literal `${AGT_AGENT_ID}` instead
3258
+ // of the agent's real UUID. The broker has no way to substitute
3259
+ // it post-spawn, so a placeholder here = silently broken agent.
3260
+ { key: "AGT_AGENT_ID", mustBeConcrete: true }
3261
+ ]
3262
+ };
3263
+ var PLACEHOLDER_RE = /\$\{[^}]+\}/;
3264
+ function validateRenderedMcpConfig(config) {
3265
+ const errors = [];
3266
+ if (typeof config !== "object" || config === null || Array.isArray(config)) {
3267
+ return {
3268
+ ok: false,
3269
+ errors: [
3270
+ {
3271
+ kind: "invalid_json_shape",
3272
+ server: "*",
3273
+ message: "config root must be a non-null object"
3274
+ }
3275
+ ]
3276
+ };
3277
+ }
3278
+ const root = config;
3279
+ if (root.mcpServers === void 0) {
3280
+ return { ok: true };
3281
+ }
3282
+ if (typeof root.mcpServers !== "object" || root.mcpServers === null) {
3283
+ return {
3284
+ ok: false,
3285
+ errors: [
3286
+ {
3287
+ kind: "invalid_json_shape",
3288
+ server: "*",
3289
+ message: "mcpServers must be an object"
3290
+ }
3291
+ ]
3292
+ };
3293
+ }
3294
+ if (Array.isArray(root.mcpServers)) {
3295
+ return {
3296
+ ok: false,
3297
+ errors: [
3298
+ {
3299
+ kind: "invalid_json_shape",
3300
+ server: "*",
3301
+ message: "mcpServers must be an object"
3302
+ }
3303
+ ]
3304
+ };
3305
+ }
3306
+ for (const [serverKey, raw] of Object.entries(root.mcpServers)) {
3307
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
3308
+ errors.push({
3309
+ kind: "invalid_json_shape",
3310
+ server: serverKey,
3311
+ message: `entry must be an object`
3312
+ });
3313
+ continue;
3314
+ }
3315
+ const entry = raw;
3316
+ const entryRecord = entry;
3317
+ if (typeof entryRecord["url"] === "string") {
3318
+ const type = entryRecord["type"];
3319
+ if (type !== "http" && type !== "sse") {
3320
+ errors.push({
3321
+ kind: "remote_mcp_missing_type",
3322
+ server: serverKey,
3323
+ message: `url-based entry must include \`type: "http"\` or \`type: "sse"\` (Claude Code MCP schema requires it)`
3324
+ });
3325
+ }
3326
+ }
3327
+ const rules = REQUIRED_ENV_RULES_BY_SERVER[serverKey];
3328
+ if (rules) {
3329
+ const env = entry.env ?? {};
3330
+ for (const rule of rules) {
3331
+ const value = env[rule.key];
3332
+ if (typeof value !== "string" || value.length === 0) {
3333
+ errors.push({
3334
+ kind: "missing_required_env",
3335
+ server: serverKey,
3336
+ message: `missing required env key: ${rule.key}`
3337
+ });
3338
+ continue;
3339
+ }
3340
+ if (rule.mustBeConcrete && PLACEHOLDER_RE.test(value)) {
3341
+ errors.push({
3342
+ kind: "unexpanded_placeholder",
3343
+ server: serverKey,
3344
+ message: `env.${rule.key} contains an unexpanded \${...} placeholder; expected a concrete value`
3345
+ });
3346
+ }
3347
+ }
3348
+ }
3349
+ }
3350
+ return errors.length === 0 ? { ok: true } : { ok: false, errors };
3351
+ }
3352
+ function formatValidationErrors(errors) {
3353
+ return errors.map((e) => `${e.server}:${e.kind}=${e.message}`).join("; ");
3354
+ }
3355
+ function safeWriteJsonAtomic(path, content, opts = {}) {
3356
+ const keepBackup = opts.keepBackup !== false;
3357
+ const rename = opts.renamer ?? renameSync3;
3358
+ const tmpPath = `${path}.new`;
3359
+ const bakPath = `${path}.bak`;
3360
+ let movedOriginalToBackup = false;
3361
+ try {
3362
+ writeFileSync4(tmpPath, content);
3363
+ } catch (err) {
3364
+ throw err;
3365
+ }
3366
+ try {
3367
+ if (keepBackup && existsSync4(path)) {
3368
+ rename(path, bakPath);
3369
+ movedOriginalToBackup = true;
3370
+ }
3371
+ rename(tmpPath, path);
3372
+ } catch (err) {
3373
+ try {
3374
+ if (existsSync4(tmpPath))
3375
+ unlinkSync3(tmpPath);
3376
+ } catch {
3377
+ }
3378
+ if (movedOriginalToBackup && !existsSync4(path) && existsSync4(bakPath)) {
3379
+ try {
3380
+ renameSync3(bakPath, path);
3381
+ } catch {
3382
+ }
3383
+ }
3384
+ throw err;
3385
+ }
3386
+ }
3387
+ function safeWriteMcpJson(path, config) {
3388
+ const validation = validateRenderedMcpConfig(config);
3389
+ if (!validation.ok) {
3390
+ return { written: false, errors: validation.errors };
3391
+ }
3392
+ safeWriteJsonAtomic(path, JSON.stringify(config, null, 2));
3393
+ return { written: true, errors: [] };
3394
+ }
3395
+
3355
3396
  // ../../packages/core/dist/integrations/oauth-providers.js
3356
3397
  var OAUTH_PROVIDERS = {
3357
3398
  "google-workspace": {
@@ -4518,7 +4559,11 @@ var claudeCodeAdapter = {
4518
4559
  // Effective guardrails (org → team → agent), pre-joined with
4519
4560
  // definitions server-side. Renders into the Guardrails section
4520
4561
  // right after Governance. Omit / empty array → section skipped.
4521
- guardrails: input.guardrails
4562
+ guardrails: input.guardrails,
4563
+ // ENG-5380: active kanban tasks (todo/in_progress) the manager
4564
+ // chose to inject. `undefined` when the feature flag is off; the
4565
+ // identity generator short-circuits the section in that case.
4566
+ activeTasks: input.activeTasks
4522
4567
  };
4523
4568
  const mcpJson = buildMcpJson(input);
4524
4569
  const initialMcpServerKeys = Object.keys(mcpJson.mcpServers ?? {});
@@ -6523,7 +6568,7 @@ async function managerInstallCommand(opts = {}) {
6523
6568
  };
6524
6569
  const apiKey = getApiKey();
6525
6570
  if (apiKey) env.AGT_API_KEY = apiKey;
6526
- for (const k of ["AGT_TEAM", "PATH", "CLAUDE_PATH"]) {
6571
+ for (const k of ["AGT_TEAM", "AGT_CLI_RELEASE_CHANNEL", "PATH", "CLAUDE_PATH"]) {
6527
6572
  const v = process.env[k];
6528
6573
  if (v != null) env[k] = v;
6529
6574
  }
@@ -6597,7 +6642,7 @@ async function managerInstallSystemUnitCommand(opts = {}) {
6597
6642
  };
6598
6643
  const apiKey = getApiKey();
6599
6644
  if (apiKey) env.AGT_API_KEY = apiKey;
6600
- for (const k of ["AGT_TEAM", "PATH", "CLAUDE_PATH"]) {
6645
+ for (const k of ["AGT_TEAM", "AGT_CLI_RELEASE_CHANNEL", "PATH", "CLAUDE_PATH"]) {
6601
6646
  const v = process.env[k];
6602
6647
  if (v != null) env[k] = v;
6603
6648
  }
@@ -6639,6 +6684,7 @@ async function managerUninstallSystemUnitCommand() {
6639
6684
  export {
6640
6685
  getIntegration,
6641
6686
  extractCommandNotFound,
6687
+ estimateActiveTasksTokens,
6642
6688
  provisionStopHook,
6643
6689
  provisionIsolationHook,
6644
6690
  provisionOrientHook,
@@ -6671,4 +6717,4 @@ export {
6671
6717
  managerInstallSystemUnitCommand,
6672
6718
  managerUninstallSystemUnitCommand
6673
6719
  };
6674
- //# sourceMappingURL=chunk-Q4QD3TAC.js.map
6720
+ //# sourceMappingURL=chunk-WZTRMJM4.js.map