@tomismeta/paperclip-aperture 0.3.2 → 0.4.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/dist/worker.js CHANGED
@@ -4,17 +4,17 @@ var __export = (target, all) => {
4
4
  __defProp(target, name, { get: all[name], enumerable: true });
5
5
  };
6
6
 
7
- // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.318.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/define-plugin.js
7
+ // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.403.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/define-plugin.js
8
8
  function definePlugin(definition) {
9
9
  return Object.freeze({ definition });
10
10
  }
11
11
 
12
- // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.318.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.js
12
+ // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.403.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.js
13
13
  import path from "node:path";
14
14
  import { createInterface } from "node:readline";
15
15
  import { fileURLToPath } from "node:url";
16
16
 
17
- // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.318.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/protocol.js
17
+ // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.403.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/protocol.js
18
18
  var JSONRPC_VERSION = "2.0";
19
19
  var JSONRPC_ERROR_CODES = {
20
20
  /** Invalid JSON was received by the server. */
@@ -144,7 +144,7 @@ var JsonRpcCallError = class extends Error {
144
144
  }
145
145
  };
146
146
 
147
- // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.318.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.js
147
+ // node_modules/.pnpm/@paperclipai+plugin-sdk@2026.403.0_react@19.2.4/node_modules/@paperclipai/plugin-sdk/dist/worker-rpc-host.js
148
148
  var DEFAULT_RPC_TIMEOUT_MS = 3e4;
149
149
  function runWorker(plugin2, moduleUrl, options) {
150
150
  if (options?.stdin != null && options?.stdout != null) {
@@ -444,6 +444,7 @@ function startWorkerRpcHost(options) {
444
444
  projectId: input.projectId,
445
445
  goalId: input.goalId,
446
446
  parentId: input.parentId,
447
+ inheritExecutionWorkspaceFromIssueId: input.inheritExecutionWorkspaceFromIssueId,
447
448
  title: input.title,
448
449
  description: input.description,
449
450
  priority: input.priority,
@@ -611,6 +612,11 @@ function startWorkerRpcHost(options) {
611
612
  await callHost("metrics.write", { name, value, tags });
612
613
  }
613
614
  },
615
+ telemetry: {
616
+ async track(eventName, dimensions) {
617
+ await callHost("telemetry.track", { eventName, dimensions });
618
+ }
619
+ },
614
620
  logger: {
615
621
  info(message, meta) {
616
622
  notifyHost("log", { level: "info", message, meta });
@@ -4936,7 +4942,7 @@ var coerce = {
4936
4942
  };
4937
4943
  var NEVER = INVALID;
4938
4944
 
4939
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/constants.js
4945
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/constants.js
4940
4946
  var COMPANY_STATUSES = ["active", "paused", "archived"];
4941
4947
  var DEPLOYMENT_MODES = ["local_trusted", "authenticated"];
4942
4948
  var DEPLOYMENT_EXPOSURES = ["private", "public"];
@@ -4955,6 +4961,7 @@ var AGENT_ADAPTER_TYPES = [
4955
4961
  "http",
4956
4962
  "claude_local",
4957
4963
  "codex_local",
4964
+ "gemini_local",
4958
4965
  "opencode_local",
4959
4966
  "pi_local",
4960
4967
  "cursor",
@@ -5026,6 +5033,15 @@ var ISSUE_STATUSES = [
5026
5033
  "blocked",
5027
5034
  "cancelled"
5028
5035
  ];
5036
+ var INBOX_MINE_ISSUE_STATUSES = [
5037
+ "backlog",
5038
+ "todo",
5039
+ "in_progress",
5040
+ "in_review",
5041
+ "blocked",
5042
+ "done"
5043
+ ];
5044
+ var INBOX_MINE_ISSUE_STATUS_FILTER = INBOX_MINE_ISSUE_STATUSES.join(",");
5029
5045
  var ISSUE_PRIORITIES = ["critical", "high", "medium", "low"];
5030
5046
  var GOAL_LEVELS = ["company", "team", "agent", "task"];
5031
5047
  var GOAL_STATUSES = ["planned", "active", "achieved", "cancelled"];
@@ -5036,6 +5052,11 @@ var PROJECT_STATUSES = [
5036
5052
  "completed",
5037
5053
  "cancelled"
5038
5054
  ];
5055
+ var ROUTINE_STATUSES = ["active", "paused", "archived"];
5056
+ var ROUTINE_CONCURRENCY_POLICIES = ["coalesce_if_active", "always_enqueue", "skip_if_active"];
5057
+ var ROUTINE_CATCH_UP_POLICIES = ["skip_missed", "enqueue_missed_with_cap"];
5058
+ var ROUTINE_TRIGGER_SIGNING_MODES = ["bearer", "hmac_sha256"];
5059
+ var ROUTINE_VARIABLE_TYPES = ["text", "textarea", "number", "boolean", "select"];
5039
5060
  var APPROVAL_TYPES = ["hire_agent", "approve_ceo_strategy", "budget_override_required"];
5040
5061
  var SECRET_PROVIDERS = [
5041
5062
  "local_encrypted",
@@ -5142,6 +5163,7 @@ var PLUGIN_CAPABILITIES = [
5142
5163
  "agent.sessions.close",
5143
5164
  "activity.log.write",
5144
5165
  "metrics.write",
5166
+ "telemetry.track",
5145
5167
  // Plugin State
5146
5168
  "plugin.state.read",
5147
5169
  "plugin.state.write",
@@ -5253,13 +5275,40 @@ var PLUGIN_STATE_SCOPE_KINDS = [
5253
5275
  "run"
5254
5276
  ];
5255
5277
 
5256
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/instance.js
5278
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/types/feedback.js
5279
+ var FEEDBACK_TARGET_TYPES = ["issue_comment", "issue_document_revision"];
5280
+ var FEEDBACK_VOTE_VALUES = ["up", "down"];
5281
+ var FEEDBACK_DATA_SHARING_PREFERENCES = ["allowed", "not_allowed", "prompt"];
5282
+ var DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE = "prompt";
5283
+ var FEEDBACK_TRACE_STATUSES = ["local_only", "pending", "sent", "failed"];
5284
+
5285
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/feedback.js
5286
+ var feedbackTargetTypeSchema = external_exports.enum(FEEDBACK_TARGET_TYPES);
5287
+ var feedbackTraceStatusSchema = external_exports.enum(FEEDBACK_TRACE_STATUSES);
5288
+ var feedbackVoteValueSchema = external_exports.enum(FEEDBACK_VOTE_VALUES);
5289
+ var feedbackDataSharingPreferenceSchema = external_exports.enum(FEEDBACK_DATA_SHARING_PREFERENCES);
5290
+ var upsertIssueFeedbackVoteSchema = external_exports.object({
5291
+ targetType: feedbackTargetTypeSchema,
5292
+ targetId: external_exports.string().uuid(),
5293
+ vote: feedbackVoteValueSchema,
5294
+ reason: external_exports.string().trim().max(1e3).optional(),
5295
+ allowSharing: external_exports.boolean().optional()
5296
+ });
5297
+
5298
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/instance.js
5299
+ var instanceGeneralSettingsSchema = external_exports.object({
5300
+ censorUsernameInLogs: external_exports.boolean().default(false),
5301
+ keyboardShortcuts: external_exports.boolean().default(false),
5302
+ feedbackDataSharingPreference: feedbackDataSharingPreferenceSchema.default(DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE)
5303
+ }).strict();
5304
+ var patchInstanceGeneralSettingsSchema = instanceGeneralSettingsSchema.partial();
5257
5305
  var instanceExperimentalSettingsSchema = external_exports.object({
5258
- enableIsolatedWorkspaces: external_exports.boolean().default(false)
5306
+ enableIsolatedWorkspaces: external_exports.boolean().default(false),
5307
+ autoRestartDevServerWhenIdle: external_exports.boolean().default(false)
5259
5308
  }).strict();
5260
5309
  var patchInstanceExperimentalSettingsSchema = instanceExperimentalSettingsSchema.partial();
5261
5310
 
5262
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/budget.js
5311
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/budget.js
5263
5312
  var upsertBudgetPolicySchema = external_exports.object({
5264
5313
  scopeType: external_exports.enum(BUDGET_SCOPE_TYPES),
5265
5314
  scopeId: external_exports.string().uuid(),
@@ -5285,8 +5334,10 @@ var resolveBudgetIncidentSchema = external_exports.object({
5285
5334
  }
5286
5335
  });
5287
5336
 
5288
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/company.js
5337
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/company.js
5289
5338
  var logoAssetIdSchema = external_exports.string().uuid().nullable().optional();
5339
+ var brandColorSchema = external_exports.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
5340
+ var feedbackDataSharingTermsVersionSchema = external_exports.string().min(1).nullable().optional();
5290
5341
  var createCompanySchema = external_exports.object({
5291
5342
  name: external_exports.string().min(1),
5292
5343
  description: external_exports.string().optional().nullable(),
@@ -5296,32 +5347,400 @@ var updateCompanySchema = createCompanySchema.partial().extend({
5296
5347
  status: external_exports.enum(COMPANY_STATUSES).optional(),
5297
5348
  spentMonthlyCents: external_exports.number().int().nonnegative().optional(),
5298
5349
  requireBoardApprovalForNewAgents: external_exports.boolean().optional(),
5299
- brandColor: external_exports.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional(),
5350
+ feedbackDataSharingEnabled: external_exports.boolean().optional(),
5351
+ feedbackDataSharingConsentAt: external_exports.coerce.date().nullable().optional(),
5352
+ feedbackDataSharingConsentByUserId: external_exports.string().min(1).nullable().optional(),
5353
+ feedbackDataSharingTermsVersion: feedbackDataSharingTermsVersionSchema,
5354
+ brandColor: brandColorSchema,
5300
5355
  logoAssetId: logoAssetIdSchema
5301
5356
  });
5357
+ var updateCompanyBrandingSchema = external_exports.object({
5358
+ name: external_exports.string().min(1).optional(),
5359
+ description: external_exports.string().nullable().optional(),
5360
+ brandColor: brandColorSchema,
5361
+ logoAssetId: logoAssetIdSchema
5362
+ }).strict().refine((value) => value.name !== void 0 || value.description !== void 0 || value.brandColor !== void 0 || value.logoAssetId !== void 0, "At least one branding field must be provided");
5363
+
5364
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/company-skill.js
5365
+ var companySkillSourceTypeSchema = external_exports.enum(["local_path", "github", "url", "catalog", "skills_sh"]);
5366
+ var companySkillTrustLevelSchema = external_exports.enum(["markdown_only", "assets", "scripts_executables"]);
5367
+ var companySkillCompatibilitySchema = external_exports.enum(["compatible", "unknown", "invalid"]);
5368
+ var companySkillSourceBadgeSchema = external_exports.enum(["paperclip", "github", "local", "url", "catalog", "skills_sh"]);
5369
+ var companySkillFileInventoryEntrySchema = external_exports.object({
5370
+ path: external_exports.string().min(1),
5371
+ kind: external_exports.enum(["skill", "markdown", "reference", "script", "asset", "other"])
5372
+ });
5373
+ var companySkillSchema = external_exports.object({
5374
+ id: external_exports.string().uuid(),
5375
+ companyId: external_exports.string().uuid(),
5376
+ key: external_exports.string().min(1),
5377
+ slug: external_exports.string().min(1),
5378
+ name: external_exports.string().min(1),
5379
+ description: external_exports.string().nullable(),
5380
+ markdown: external_exports.string(),
5381
+ sourceType: companySkillSourceTypeSchema,
5382
+ sourceLocator: external_exports.string().nullable(),
5383
+ sourceRef: external_exports.string().nullable(),
5384
+ trustLevel: companySkillTrustLevelSchema,
5385
+ compatibility: companySkillCompatibilitySchema,
5386
+ fileInventory: external_exports.array(companySkillFileInventoryEntrySchema).default([]),
5387
+ metadata: external_exports.record(external_exports.unknown()).nullable(),
5388
+ createdAt: external_exports.coerce.date(),
5389
+ updatedAt: external_exports.coerce.date()
5390
+ });
5391
+ var companySkillListItemSchema = companySkillSchema.extend({
5392
+ attachedAgentCount: external_exports.number().int().nonnegative(),
5393
+ editable: external_exports.boolean(),
5394
+ editableReason: external_exports.string().nullable(),
5395
+ sourceLabel: external_exports.string().nullable(),
5396
+ sourceBadge: companySkillSourceBadgeSchema
5397
+ });
5398
+ var companySkillUsageAgentSchema = external_exports.object({
5399
+ id: external_exports.string().uuid(),
5400
+ name: external_exports.string().min(1),
5401
+ urlKey: external_exports.string().min(1),
5402
+ adapterType: external_exports.string().min(1),
5403
+ desired: external_exports.boolean(),
5404
+ actualState: external_exports.string().nullable()
5405
+ });
5406
+ var companySkillDetailSchema = companySkillSchema.extend({
5407
+ attachedAgentCount: external_exports.number().int().nonnegative(),
5408
+ usedByAgents: external_exports.array(companySkillUsageAgentSchema).default([]),
5409
+ editable: external_exports.boolean(),
5410
+ editableReason: external_exports.string().nullable(),
5411
+ sourceLabel: external_exports.string().nullable(),
5412
+ sourceBadge: companySkillSourceBadgeSchema
5413
+ });
5414
+ var companySkillUpdateStatusSchema = external_exports.object({
5415
+ supported: external_exports.boolean(),
5416
+ reason: external_exports.string().nullable(),
5417
+ trackingRef: external_exports.string().nullable(),
5418
+ currentRef: external_exports.string().nullable(),
5419
+ latestRef: external_exports.string().nullable(),
5420
+ hasUpdate: external_exports.boolean()
5421
+ });
5422
+ var companySkillImportSchema = external_exports.object({
5423
+ source: external_exports.string().min(1)
5424
+ });
5425
+ var companySkillProjectScanRequestSchema = external_exports.object({
5426
+ projectIds: external_exports.array(external_exports.string().uuid()).optional(),
5427
+ workspaceIds: external_exports.array(external_exports.string().uuid()).optional()
5428
+ });
5429
+ var companySkillProjectScanSkippedSchema = external_exports.object({
5430
+ projectId: external_exports.string().uuid(),
5431
+ projectName: external_exports.string().min(1),
5432
+ workspaceId: external_exports.string().uuid().nullable(),
5433
+ workspaceName: external_exports.string().nullable(),
5434
+ path: external_exports.string().nullable(),
5435
+ reason: external_exports.string().min(1)
5436
+ });
5437
+ var companySkillProjectScanConflictSchema = external_exports.object({
5438
+ slug: external_exports.string().min(1),
5439
+ key: external_exports.string().min(1),
5440
+ projectId: external_exports.string().uuid(),
5441
+ projectName: external_exports.string().min(1),
5442
+ workspaceId: external_exports.string().uuid(),
5443
+ workspaceName: external_exports.string().min(1),
5444
+ path: external_exports.string().min(1),
5445
+ existingSkillId: external_exports.string().uuid(),
5446
+ existingSkillKey: external_exports.string().min(1),
5447
+ existingSourceLocator: external_exports.string().nullable(),
5448
+ reason: external_exports.string().min(1)
5449
+ });
5450
+ var companySkillProjectScanResultSchema = external_exports.object({
5451
+ scannedProjects: external_exports.number().int().nonnegative(),
5452
+ scannedWorkspaces: external_exports.number().int().nonnegative(),
5453
+ discovered: external_exports.number().int().nonnegative(),
5454
+ imported: external_exports.array(companySkillSchema),
5455
+ updated: external_exports.array(companySkillSchema),
5456
+ skipped: external_exports.array(companySkillProjectScanSkippedSchema),
5457
+ conflicts: external_exports.array(companySkillProjectScanConflictSchema),
5458
+ warnings: external_exports.array(external_exports.string())
5459
+ });
5460
+ var companySkillCreateSchema = external_exports.object({
5461
+ name: external_exports.string().min(1),
5462
+ slug: external_exports.string().min(1).nullable().optional(),
5463
+ description: external_exports.string().nullable().optional(),
5464
+ markdown: external_exports.string().nullable().optional()
5465
+ });
5466
+ var companySkillFileDetailSchema = external_exports.object({
5467
+ skillId: external_exports.string().uuid(),
5468
+ path: external_exports.string().min(1),
5469
+ kind: external_exports.enum(["skill", "markdown", "reference", "script", "asset", "other"]),
5470
+ content: external_exports.string(),
5471
+ language: external_exports.string().nullable(),
5472
+ markdown: external_exports.boolean(),
5473
+ editable: external_exports.boolean()
5474
+ });
5475
+ var companySkillFileUpdateSchema = external_exports.object({
5476
+ path: external_exports.string().min(1),
5477
+ content: external_exports.string()
5478
+ });
5302
5479
 
5303
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/company-portability.js
5480
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/adapter-skills.js
5481
+ var agentSkillStateSchema = external_exports.enum([
5482
+ "available",
5483
+ "configured",
5484
+ "installed",
5485
+ "missing",
5486
+ "stale",
5487
+ "external"
5488
+ ]);
5489
+ var agentSkillOriginSchema = external_exports.enum([
5490
+ "company_managed",
5491
+ "paperclip_required",
5492
+ "user_installed",
5493
+ "external_unknown"
5494
+ ]);
5495
+ var agentSkillSyncModeSchema = external_exports.enum([
5496
+ "unsupported",
5497
+ "persistent",
5498
+ "ephemeral"
5499
+ ]);
5500
+ var agentSkillEntrySchema = external_exports.object({
5501
+ key: external_exports.string().min(1),
5502
+ runtimeName: external_exports.string().min(1).nullable(),
5503
+ desired: external_exports.boolean(),
5504
+ managed: external_exports.boolean(),
5505
+ required: external_exports.boolean().optional(),
5506
+ requiredReason: external_exports.string().nullable().optional(),
5507
+ state: agentSkillStateSchema,
5508
+ origin: agentSkillOriginSchema.optional(),
5509
+ originLabel: external_exports.string().nullable().optional(),
5510
+ locationLabel: external_exports.string().nullable().optional(),
5511
+ readOnly: external_exports.boolean().optional(),
5512
+ sourcePath: external_exports.string().nullable().optional(),
5513
+ targetPath: external_exports.string().nullable().optional(),
5514
+ detail: external_exports.string().nullable().optional()
5515
+ });
5516
+ var agentSkillSnapshotSchema = external_exports.object({
5517
+ adapterType: external_exports.string().min(1),
5518
+ supported: external_exports.boolean(),
5519
+ mode: agentSkillSyncModeSchema,
5520
+ desiredSkills: external_exports.array(external_exports.string().min(1)),
5521
+ entries: external_exports.array(agentSkillEntrySchema),
5522
+ warnings: external_exports.array(external_exports.string())
5523
+ });
5524
+ var agentSkillSyncSchema = external_exports.object({
5525
+ desiredSkills: external_exports.array(external_exports.string().min(1))
5526
+ });
5527
+
5528
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/issue.js
5529
+ var ISSUE_EXECUTION_WORKSPACE_PREFERENCES = [
5530
+ "inherit",
5531
+ "shared_workspace",
5532
+ "isolated_workspace",
5533
+ "operator_branch",
5534
+ "reuse_existing",
5535
+ "agent_default"
5536
+ ];
5537
+ var executionWorkspaceStrategySchema = external_exports.object({
5538
+ type: external_exports.enum(["project_primary", "git_worktree", "adapter_managed", "cloud_sandbox"]).optional(),
5539
+ baseRef: external_exports.string().optional().nullable(),
5540
+ branchTemplate: external_exports.string().optional().nullable(),
5541
+ worktreeParentDir: external_exports.string().optional().nullable(),
5542
+ provisionCommand: external_exports.string().optional().nullable(),
5543
+ teardownCommand: external_exports.string().optional().nullable()
5544
+ }).strict();
5545
+ var issueExecutionWorkspaceSettingsSchema = external_exports.object({
5546
+ mode: external_exports.enum(ISSUE_EXECUTION_WORKSPACE_PREFERENCES).optional(),
5547
+ workspaceStrategy: executionWorkspaceStrategySchema.optional().nullable(),
5548
+ workspaceRuntime: external_exports.record(external_exports.unknown()).optional().nullable()
5549
+ }).strict();
5550
+ var issueAssigneeAdapterOverridesSchema = external_exports.object({
5551
+ adapterConfig: external_exports.record(external_exports.unknown()).optional(),
5552
+ useProjectWorkspace: external_exports.boolean().optional()
5553
+ }).strict();
5554
+ var createIssueSchema = external_exports.object({
5555
+ projectId: external_exports.string().uuid().optional().nullable(),
5556
+ projectWorkspaceId: external_exports.string().uuid().optional().nullable(),
5557
+ goalId: external_exports.string().uuid().optional().nullable(),
5558
+ parentId: external_exports.string().uuid().optional().nullable(),
5559
+ inheritExecutionWorkspaceFromIssueId: external_exports.string().uuid().optional().nullable(),
5560
+ title: external_exports.string().min(1),
5561
+ description: external_exports.string().optional().nullable(),
5562
+ status: external_exports.enum(ISSUE_STATUSES).optional().default("backlog"),
5563
+ priority: external_exports.enum(ISSUE_PRIORITIES).optional().default("medium"),
5564
+ assigneeAgentId: external_exports.string().uuid().optional().nullable(),
5565
+ assigneeUserId: external_exports.string().optional().nullable(),
5566
+ requestDepth: external_exports.number().int().nonnegative().optional().default(0),
5567
+ billingCode: external_exports.string().optional().nullable(),
5568
+ assigneeAdapterOverrides: issueAssigneeAdapterOverridesSchema.optional().nullable(),
5569
+ executionWorkspaceId: external_exports.string().uuid().optional().nullable(),
5570
+ executionWorkspacePreference: external_exports.enum(ISSUE_EXECUTION_WORKSPACE_PREFERENCES).optional().nullable(),
5571
+ executionWorkspaceSettings: issueExecutionWorkspaceSettingsSchema.optional().nullable(),
5572
+ labelIds: external_exports.array(external_exports.string().uuid()).optional()
5573
+ });
5574
+ var createIssueLabelSchema = external_exports.object({
5575
+ name: external_exports.string().trim().min(1).max(48),
5576
+ color: external_exports.string().regex(/^#(?:[0-9a-fA-F]{6})$/, "Color must be a 6-digit hex value")
5577
+ });
5578
+ var updateIssueSchema = createIssueSchema.partial().extend({
5579
+ comment: external_exports.string().min(1).optional(),
5580
+ reopen: external_exports.boolean().optional(),
5581
+ interrupt: external_exports.boolean().optional(),
5582
+ hiddenAt: external_exports.string().datetime().nullable().optional()
5583
+ });
5584
+ var checkoutIssueSchema = external_exports.object({
5585
+ agentId: external_exports.string().uuid(),
5586
+ expectedStatuses: external_exports.array(external_exports.enum(ISSUE_STATUSES)).nonempty()
5587
+ });
5588
+ var addIssueCommentSchema = external_exports.object({
5589
+ body: external_exports.string().min(1),
5590
+ reopen: external_exports.boolean().optional(),
5591
+ interrupt: external_exports.boolean().optional()
5592
+ });
5593
+ var linkIssueApprovalSchema = external_exports.object({
5594
+ approvalId: external_exports.string().uuid()
5595
+ });
5596
+ var createIssueAttachmentMetadataSchema = external_exports.object({
5597
+ issueCommentId: external_exports.string().uuid().optional().nullable()
5598
+ });
5599
+ var ISSUE_DOCUMENT_FORMATS = ["markdown"];
5600
+ var issueDocumentFormatSchema = external_exports.enum(ISSUE_DOCUMENT_FORMATS);
5601
+ var issueDocumentKeySchema = external_exports.string().trim().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/, "Document key must be lowercase letters, numbers, _ or -");
5602
+ var upsertIssueDocumentSchema = external_exports.object({
5603
+ title: external_exports.string().trim().max(200).nullable().optional(),
5604
+ format: issueDocumentFormatSchema,
5605
+ body: external_exports.string().max(524288),
5606
+ changeSummary: external_exports.string().trim().max(500).nullable().optional(),
5607
+ baseRevisionId: external_exports.string().uuid().nullable().optional()
5608
+ });
5609
+ var restoreIssueDocumentRevisionSchema = external_exports.object({});
5610
+
5611
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/routine.js
5612
+ var routineVariableValueSchema = external_exports.union([external_exports.string(), external_exports.number().finite(), external_exports.boolean()]);
5613
+ var routineVariableSchema = external_exports.object({
5614
+ name: external_exports.string().trim().regex(/^[A-Za-z][A-Za-z0-9_]*$/),
5615
+ label: external_exports.string().trim().max(120).optional().nullable(),
5616
+ type: external_exports.enum(ROUTINE_VARIABLE_TYPES).optional().default("text"),
5617
+ defaultValue: routineVariableValueSchema.optional().nullable(),
5618
+ required: external_exports.boolean().optional().default(true),
5619
+ options: external_exports.array(external_exports.string().trim().min(1).max(120)).max(50).optional().default([])
5620
+ }).superRefine((value, ctx) => {
5621
+ if (value.type === "select" && value.options.length === 0) {
5622
+ ctx.addIssue({
5623
+ code: external_exports.ZodIssueCode.custom,
5624
+ path: ["options"],
5625
+ message: "Select variables require at least one option"
5626
+ });
5627
+ }
5628
+ if (value.type !== "select" && value.options.length > 0) {
5629
+ ctx.addIssue({
5630
+ code: external_exports.ZodIssueCode.custom,
5631
+ path: ["options"],
5632
+ message: "Only select variables can define options"
5633
+ });
5634
+ }
5635
+ if (value.type === "select" && value.defaultValue != null) {
5636
+ if (typeof value.defaultValue !== "string" || !value.options.includes(value.defaultValue)) {
5637
+ ctx.addIssue({
5638
+ code: external_exports.ZodIssueCode.custom,
5639
+ path: ["defaultValue"],
5640
+ message: "Select variable defaults must match one of the allowed options"
5641
+ });
5642
+ }
5643
+ }
5644
+ });
5645
+ var createRoutineSchema = external_exports.object({
5646
+ projectId: external_exports.string().uuid(),
5647
+ goalId: external_exports.string().uuid().optional().nullable(),
5648
+ parentIssueId: external_exports.string().uuid().optional().nullable(),
5649
+ title: external_exports.string().trim().min(1).max(200),
5650
+ description: external_exports.string().optional().nullable(),
5651
+ assigneeAgentId: external_exports.string().uuid(),
5652
+ priority: external_exports.enum(ISSUE_PRIORITIES).optional().default("medium"),
5653
+ status: external_exports.enum(ROUTINE_STATUSES).optional().default("active"),
5654
+ concurrencyPolicy: external_exports.enum(ROUTINE_CONCURRENCY_POLICIES).optional().default("coalesce_if_active"),
5655
+ catchUpPolicy: external_exports.enum(ROUTINE_CATCH_UP_POLICIES).optional().default("skip_missed"),
5656
+ variables: external_exports.array(routineVariableSchema).optional().default([])
5657
+ });
5658
+ var updateRoutineSchema = createRoutineSchema.partial();
5659
+ var baseTriggerSchema = external_exports.object({
5660
+ label: external_exports.string().trim().max(120).optional().nullable(),
5661
+ enabled: external_exports.boolean().optional().default(true)
5662
+ });
5663
+ var createRoutineTriggerSchema = external_exports.discriminatedUnion("kind", [
5664
+ baseTriggerSchema.extend({
5665
+ kind: external_exports.literal("schedule"),
5666
+ cronExpression: external_exports.string().trim().min(1),
5667
+ timezone: external_exports.string().trim().min(1).default("UTC")
5668
+ }),
5669
+ baseTriggerSchema.extend({
5670
+ kind: external_exports.literal("webhook"),
5671
+ signingMode: external_exports.enum(ROUTINE_TRIGGER_SIGNING_MODES).optional().default("bearer"),
5672
+ replayWindowSec: external_exports.number().int().min(30).max(86400).optional().default(300)
5673
+ }),
5674
+ baseTriggerSchema.extend({
5675
+ kind: external_exports.literal("api")
5676
+ })
5677
+ ]);
5678
+ var updateRoutineTriggerSchema = external_exports.object({
5679
+ label: external_exports.string().trim().max(120).optional().nullable(),
5680
+ enabled: external_exports.boolean().optional(),
5681
+ cronExpression: external_exports.string().trim().min(1).optional().nullable(),
5682
+ timezone: external_exports.string().trim().min(1).optional().nullable(),
5683
+ signingMode: external_exports.enum(ROUTINE_TRIGGER_SIGNING_MODES).optional().nullable(),
5684
+ replayWindowSec: external_exports.number().int().min(30).max(86400).optional().nullable()
5685
+ });
5686
+ var runRoutineSchema = external_exports.object({
5687
+ triggerId: external_exports.string().uuid().optional().nullable(),
5688
+ payload: external_exports.record(external_exports.unknown()).optional().nullable(),
5689
+ variables: external_exports.record(routineVariableValueSchema).optional().nullable(),
5690
+ idempotencyKey: external_exports.string().trim().max(255).optional().nullable(),
5691
+ source: external_exports.enum(["manual", "api"]).optional().default("manual"),
5692
+ executionWorkspaceId: external_exports.string().uuid().optional().nullable(),
5693
+ executionWorkspacePreference: external_exports.enum(ISSUE_EXECUTION_WORKSPACE_PREFERENCES).optional().nullable(),
5694
+ executionWorkspaceSettings: issueExecutionWorkspaceSettingsSchema.optional().nullable()
5695
+ });
5696
+ var rotateRoutineTriggerSecretSchema = external_exports.object({});
5697
+
5698
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/company-portability.js
5304
5699
  var portabilityIncludeSchema = external_exports.object({
5305
5700
  company: external_exports.boolean().optional(),
5306
- agents: external_exports.boolean().optional()
5701
+ agents: external_exports.boolean().optional(),
5702
+ projects: external_exports.boolean().optional(),
5703
+ issues: external_exports.boolean().optional(),
5704
+ skills: external_exports.boolean().optional()
5307
5705
  }).partial();
5308
- var portabilitySecretRequirementSchema = external_exports.object({
5706
+ var portabilityEnvInputSchema = external_exports.object({
5309
5707
  key: external_exports.string().min(1),
5310
5708
  description: external_exports.string().nullable(),
5311
5709
  agentSlug: external_exports.string().min(1).nullable(),
5312
- providerHint: external_exports.string().nullable()
5710
+ kind: external_exports.enum(["secret", "plain"]),
5711
+ requirement: external_exports.enum(["required", "optional"]),
5712
+ defaultValue: external_exports.string().nullable(),
5713
+ portability: external_exports.enum(["portable", "system_dependent"])
5313
5714
  });
5715
+ var portabilityFileEntrySchema = external_exports.union([
5716
+ external_exports.string(),
5717
+ external_exports.object({
5718
+ encoding: external_exports.literal("base64"),
5719
+ data: external_exports.string(),
5720
+ contentType: external_exports.string().min(1).optional().nullable()
5721
+ })
5722
+ ]);
5314
5723
  var portabilityCompanyManifestEntrySchema = external_exports.object({
5315
5724
  path: external_exports.string().min(1),
5316
5725
  name: external_exports.string().min(1),
5317
5726
  description: external_exports.string().nullable(),
5318
5727
  brandColor: external_exports.string().nullable(),
5319
- requireBoardApprovalForNewAgents: external_exports.boolean()
5728
+ logoPath: external_exports.string().nullable(),
5729
+ requireBoardApprovalForNewAgents: external_exports.boolean(),
5730
+ feedbackDataSharingEnabled: external_exports.boolean().default(false),
5731
+ feedbackDataSharingConsentAt: external_exports.string().datetime().nullable().default(null),
5732
+ feedbackDataSharingConsentByUserId: external_exports.string().nullable().default(null),
5733
+ feedbackDataSharingTermsVersion: external_exports.string().nullable().default(null)
5734
+ });
5735
+ var portabilitySidebarOrderSchema = external_exports.object({
5736
+ agents: external_exports.array(external_exports.string().min(1)).default([]),
5737
+ projects: external_exports.array(external_exports.string().min(1)).default([])
5320
5738
  });
5321
5739
  var portabilityAgentManifestEntrySchema = external_exports.object({
5322
5740
  slug: external_exports.string().min(1),
5323
5741
  name: external_exports.string().min(1),
5324
5742
  path: external_exports.string().min(1),
5743
+ skills: external_exports.array(external_exports.string().min(1)).default([]),
5325
5744
  role: external_exports.string().min(1),
5326
5745
  title: external_exports.string().nullable(),
5327
5746
  icon: external_exports.string().nullable(),
@@ -5334,6 +5753,84 @@ var portabilityAgentManifestEntrySchema = external_exports.object({
5334
5753
  budgetMonthlyCents: external_exports.number().int().nonnegative(),
5335
5754
  metadata: external_exports.record(external_exports.unknown()).nullable()
5336
5755
  });
5756
+ var portabilitySkillManifestEntrySchema = external_exports.object({
5757
+ key: external_exports.string().min(1),
5758
+ slug: external_exports.string().min(1),
5759
+ name: external_exports.string().min(1),
5760
+ path: external_exports.string().min(1),
5761
+ description: external_exports.string().nullable(),
5762
+ sourceType: external_exports.string().min(1),
5763
+ sourceLocator: external_exports.string().nullable(),
5764
+ sourceRef: external_exports.string().nullable(),
5765
+ trustLevel: external_exports.string().nullable(),
5766
+ compatibility: external_exports.string().nullable(),
5767
+ metadata: external_exports.record(external_exports.unknown()).nullable(),
5768
+ fileInventory: external_exports.array(external_exports.object({
5769
+ path: external_exports.string().min(1),
5770
+ kind: external_exports.string().min(1)
5771
+ })).default([])
5772
+ });
5773
+ var portabilityProjectManifestEntrySchema = external_exports.object({
5774
+ slug: external_exports.string().min(1),
5775
+ name: external_exports.string().min(1),
5776
+ path: external_exports.string().min(1),
5777
+ description: external_exports.string().nullable(),
5778
+ ownerAgentSlug: external_exports.string().min(1).nullable(),
5779
+ leadAgentSlug: external_exports.string().min(1).nullable(),
5780
+ targetDate: external_exports.string().nullable(),
5781
+ color: external_exports.string().nullable(),
5782
+ status: external_exports.string().nullable(),
5783
+ executionWorkspacePolicy: external_exports.record(external_exports.unknown()).nullable(),
5784
+ workspaces: external_exports.array(external_exports.object({
5785
+ key: external_exports.string().min(1),
5786
+ name: external_exports.string().min(1),
5787
+ sourceType: external_exports.string().nullable(),
5788
+ repoUrl: external_exports.string().nullable(),
5789
+ repoRef: external_exports.string().nullable(),
5790
+ defaultRef: external_exports.string().nullable(),
5791
+ visibility: external_exports.string().nullable(),
5792
+ setupCommand: external_exports.string().nullable(),
5793
+ cleanupCommand: external_exports.string().nullable(),
5794
+ metadata: external_exports.record(external_exports.unknown()).nullable(),
5795
+ isPrimary: external_exports.boolean()
5796
+ })).default([]),
5797
+ metadata: external_exports.record(external_exports.unknown()).nullable()
5798
+ });
5799
+ var portabilityIssueRoutineTriggerManifestEntrySchema = external_exports.object({
5800
+ kind: external_exports.string().min(1),
5801
+ label: external_exports.string().nullable(),
5802
+ enabled: external_exports.boolean(),
5803
+ cronExpression: external_exports.string().nullable(),
5804
+ timezone: external_exports.string().nullable(),
5805
+ signingMode: external_exports.string().nullable(),
5806
+ replayWindowSec: external_exports.number().int().nullable()
5807
+ });
5808
+ var portabilityIssueRoutineManifestEntrySchema = external_exports.object({
5809
+ concurrencyPolicy: external_exports.string().nullable(),
5810
+ catchUpPolicy: external_exports.string().nullable(),
5811
+ variables: external_exports.array(routineVariableSchema).nullable().optional(),
5812
+ triggers: external_exports.array(portabilityIssueRoutineTriggerManifestEntrySchema).default([])
5813
+ });
5814
+ var portabilityIssueManifestEntrySchema = external_exports.object({
5815
+ slug: external_exports.string().min(1),
5816
+ identifier: external_exports.string().min(1).nullable(),
5817
+ title: external_exports.string().min(1),
5818
+ path: external_exports.string().min(1),
5819
+ projectSlug: external_exports.string().min(1).nullable(),
5820
+ projectWorkspaceKey: external_exports.string().min(1).nullable(),
5821
+ assigneeAgentSlug: external_exports.string().min(1).nullable(),
5822
+ description: external_exports.string().nullable(),
5823
+ recurring: external_exports.boolean().default(false),
5824
+ routine: portabilityIssueRoutineManifestEntrySchema.nullable(),
5825
+ legacyRecurrence: external_exports.record(external_exports.unknown()).nullable(),
5826
+ status: external_exports.string().nullable(),
5827
+ priority: external_exports.string().nullable(),
5828
+ labelIds: external_exports.array(external_exports.string().min(1)).default([]),
5829
+ billingCode: external_exports.string().nullable(),
5830
+ executionWorkspaceSettings: external_exports.record(external_exports.unknown()).nullable(),
5831
+ assigneeAdapterOverrides: external_exports.record(external_exports.unknown()).nullable(),
5832
+ metadata: external_exports.record(external_exports.unknown()).nullable()
5833
+ });
5337
5834
  var portabilityManifestSchema = external_exports.object({
5338
5835
  schemaVersion: external_exports.number().int().positive(),
5339
5836
  generatedAt: external_exports.string().datetime(),
@@ -5343,21 +5840,24 @@ var portabilityManifestSchema = external_exports.object({
5343
5840
  }).nullable(),
5344
5841
  includes: external_exports.object({
5345
5842
  company: external_exports.boolean(),
5346
- agents: external_exports.boolean()
5843
+ agents: external_exports.boolean(),
5844
+ projects: external_exports.boolean(),
5845
+ issues: external_exports.boolean(),
5846
+ skills: external_exports.boolean()
5347
5847
  }),
5348
5848
  company: portabilityCompanyManifestEntrySchema.nullable(),
5849
+ sidebar: portabilitySidebarOrderSchema.nullable(),
5349
5850
  agents: external_exports.array(portabilityAgentManifestEntrySchema),
5350
- requiredSecrets: external_exports.array(portabilitySecretRequirementSchema).default([])
5851
+ skills: external_exports.array(portabilitySkillManifestEntrySchema).default([]),
5852
+ projects: external_exports.array(portabilityProjectManifestEntrySchema).default([]),
5853
+ issues: external_exports.array(portabilityIssueManifestEntrySchema).default([]),
5854
+ envInputs: external_exports.array(portabilityEnvInputSchema).default([])
5351
5855
  });
5352
5856
  var portabilitySourceSchema = external_exports.discriminatedUnion("type", [
5353
5857
  external_exports.object({
5354
5858
  type: external_exports.literal("inline"),
5355
- manifest: portabilityManifestSchema,
5356
- files: external_exports.record(external_exports.string())
5357
- }),
5358
- external_exports.object({
5359
- type: external_exports.literal("url"),
5360
- url: external_exports.string().url()
5859
+ rootPath: external_exports.string().min(1).optional().nullable(),
5860
+ files: external_exports.record(portabilityFileEntrySchema)
5361
5861
  }),
5362
5862
  external_exports.object({
5363
5863
  type: external_exports.literal("github"),
@@ -5380,17 +5880,34 @@ var portabilityAgentSelectionSchema = external_exports.union([
5380
5880
  ]);
5381
5881
  var portabilityCollisionStrategySchema = external_exports.enum(["rename", "skip", "replace"]);
5382
5882
  var companyPortabilityExportSchema = external_exports.object({
5383
- include: portabilityIncludeSchema.optional()
5883
+ include: portabilityIncludeSchema.optional(),
5884
+ agents: external_exports.array(external_exports.string().min(1)).optional(),
5885
+ skills: external_exports.array(external_exports.string().min(1)).optional(),
5886
+ projects: external_exports.array(external_exports.string().min(1)).optional(),
5887
+ issues: external_exports.array(external_exports.string().min(1)).optional(),
5888
+ projectIssues: external_exports.array(external_exports.string().min(1)).optional(),
5889
+ selectedFiles: external_exports.array(external_exports.string().min(1)).optional(),
5890
+ expandReferencedSkills: external_exports.boolean().optional(),
5891
+ sidebarOrder: portabilitySidebarOrderSchema.partial().optional()
5384
5892
  });
5385
5893
  var companyPortabilityPreviewSchema = external_exports.object({
5386
5894
  source: portabilitySourceSchema,
5387
5895
  include: portabilityIncludeSchema.optional(),
5388
5896
  target: portabilityTargetSchema,
5389
5897
  agents: portabilityAgentSelectionSchema.optional(),
5390
- collisionStrategy: portabilityCollisionStrategySchema.optional()
5898
+ collisionStrategy: portabilityCollisionStrategySchema.optional(),
5899
+ nameOverrides: external_exports.record(external_exports.string().min(1), external_exports.string().min(1)).optional(),
5900
+ selectedFiles: external_exports.array(external_exports.string().min(1)).optional()
5901
+ });
5902
+ var portabilityAdapterOverrideSchema = external_exports.object({
5903
+ adapterType: external_exports.string().min(1),
5904
+ adapterConfig: external_exports.record(external_exports.unknown()).optional()
5905
+ });
5906
+ var companyPortabilityImportSchema = companyPortabilityPreviewSchema.extend({
5907
+ adapterOverrides: external_exports.record(external_exports.string().min(1), portabilityAdapterOverrideSchema).optional()
5391
5908
  });
5392
5909
 
5393
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/secret.js
5910
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/secret.js
5394
5911
  var envBindingPlainSchema = external_exports.object({
5395
5912
  type: external_exports.literal("plain"),
5396
5913
  value: external_exports.string()
@@ -5423,10 +5940,22 @@ var updateSecretSchema = external_exports.object({
5423
5940
  externalRef: external_exports.string().optional().nullable()
5424
5941
  });
5425
5942
 
5426
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/agent.js
5943
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/agent.js
5427
5944
  var agentPermissionsSchema = external_exports.object({
5428
5945
  canCreateAgents: external_exports.boolean().optional().default(false)
5429
5946
  });
5947
+ var agentInstructionsBundleModeSchema = external_exports.enum(["managed", "external"]);
5948
+ var updateAgentInstructionsBundleSchema = external_exports.object({
5949
+ mode: agentInstructionsBundleModeSchema.optional(),
5950
+ rootPath: external_exports.string().trim().min(1).nullable().optional(),
5951
+ entryFile: external_exports.string().trim().min(1).optional(),
5952
+ clearLegacyPromptTemplate: external_exports.boolean().optional().default(false)
5953
+ });
5954
+ var upsertAgentInstructionsFileSchema = external_exports.object({
5955
+ path: external_exports.string().trim().min(1),
5956
+ content: external_exports.string(),
5957
+ clearLegacyPromptTemplate: external_exports.boolean().optional().default(false)
5958
+ });
5430
5959
  var adapterConfigSchema = external_exports.record(external_exports.unknown()).superRefine((value, ctx) => {
5431
5960
  const envValue = value.env;
5432
5961
  if (envValue === void 0)
@@ -5447,6 +5976,7 @@ var createAgentSchema = external_exports.object({
5447
5976
  icon: external_exports.enum(AGENT_ICON_NAMES).optional().nullable(),
5448
5977
  reportsTo: external_exports.string().uuid().optional().nullable(),
5449
5978
  capabilities: external_exports.string().optional().nullable(),
5979
+ desiredSkills: external_exports.array(external_exports.string().min(1)).optional(),
5450
5980
  adapterType: external_exports.enum(AGENT_ADAPTER_TYPES).optional().default("process"),
5451
5981
  adapterConfig: adapterConfigSchema.optional().default({}),
5452
5982
  runtimeConfig: external_exports.record(external_exports.unknown()).optional().default({}),
@@ -5460,6 +5990,7 @@ var createAgentHireSchema = createAgentSchema.extend({
5460
5990
  });
5461
5991
  var updateAgentSchema = createAgentSchema.omit({ permissions: true }).partial().extend({
5462
5992
  permissions: external_exports.never().optional(),
5993
+ replaceAdapterConfig: external_exports.boolean().optional(),
5463
5994
  status: external_exports.enum(AGENT_STATUSES).optional(),
5464
5995
  spentMonthlyCents: external_exports.number().int().nonnegative().optional()
5465
5996
  });
@@ -5470,6 +6001,10 @@ var updateAgentInstructionsPathSchema = external_exports.object({
5470
6001
  var createAgentKeySchema = external_exports.object({
5471
6002
  name: external_exports.string().min(1).default("default")
5472
6003
  });
6004
+ var agentMineInboxQuerySchema = external_exports.object({
6005
+ userId: external_exports.string().trim().min(1),
6006
+ status: external_exports.string().trim().min(1).optional().default(INBOX_MINE_ISSUE_STATUS_FILTER)
6007
+ });
5473
6008
  var wakeAgentSchema = external_exports.object({
5474
6009
  source: external_exports.enum(["timer", "assignment", "on_demand", "automation"]).optional().default("on_demand"),
5475
6010
  triggerDetail: external_exports.enum(["manual", "ping", "callback", "system"]).optional(),
@@ -5485,11 +6020,12 @@ var testAdapterEnvironmentSchema = external_exports.object({
5485
6020
  adapterConfig: adapterConfigSchema.optional().default({})
5486
6021
  });
5487
6022
  var updateAgentPermissionsSchema = external_exports.object({
5488
- canCreateAgents: external_exports.boolean()
6023
+ canCreateAgents: external_exports.boolean(),
6024
+ canAssignTasks: external_exports.boolean()
5489
6025
  });
5490
6026
 
5491
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/project.js
5492
- var executionWorkspaceStrategySchema = external_exports.object({
6027
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/project.js
6028
+ var executionWorkspaceStrategySchema2 = external_exports.object({
5493
6029
  type: external_exports.enum(["project_primary", "git_worktree", "adapter_managed", "cloud_sandbox"]).optional(),
5494
6030
  baseRef: external_exports.string().optional().nullable(),
5495
6031
  branchTemplate: external_exports.string().optional().nullable(),
@@ -5502,13 +6038,17 @@ var projectExecutionWorkspacePolicySchema = external_exports.object({
5502
6038
  defaultMode: external_exports.enum(["shared_workspace", "isolated_workspace", "operator_branch", "adapter_default"]).optional(),
5503
6039
  allowIssueOverride: external_exports.boolean().optional(),
5504
6040
  defaultProjectWorkspaceId: external_exports.string().uuid().optional().nullable(),
5505
- workspaceStrategy: executionWorkspaceStrategySchema.optional().nullable(),
6041
+ workspaceStrategy: executionWorkspaceStrategySchema2.optional().nullable(),
5506
6042
  workspaceRuntime: external_exports.record(external_exports.unknown()).optional().nullable(),
5507
6043
  branchPolicy: external_exports.record(external_exports.unknown()).optional().nullable(),
5508
6044
  pullRequestPolicy: external_exports.record(external_exports.unknown()).optional().nullable(),
5509
6045
  runtimePolicy: external_exports.record(external_exports.unknown()).optional().nullable(),
5510
6046
  cleanupPolicy: external_exports.record(external_exports.unknown()).optional().nullable()
5511
6047
  }).strict();
6048
+ var projectWorkspaceRuntimeConfigSchema = external_exports.object({
6049
+ workspaceRuntime: external_exports.record(external_exports.unknown()).optional().nullable(),
6050
+ desiredState: external_exports.enum(["running", "stopped"]).optional().nullable()
6051
+ }).strict();
5512
6052
  var projectWorkspaceSourceTypeSchema = external_exports.enum(["local_path", "git_repo", "remote_managed", "non_git_path"]);
5513
6053
  var projectWorkspaceVisibilitySchema = external_exports.enum(["default", "advanced"]);
5514
6054
  var projectWorkspaceFields = {
@@ -5524,7 +6064,8 @@ var projectWorkspaceFields = {
5524
6064
  remoteProvider: external_exports.string().optional().nullable(),
5525
6065
  remoteWorkspaceRef: external_exports.string().optional().nullable(),
5526
6066
  sharedWorkspaceKey: external_exports.string().optional().nullable(),
5527
- metadata: external_exports.record(external_exports.unknown()).optional().nullable()
6067
+ metadata: external_exports.record(external_exports.unknown()).optional().nullable(),
6068
+ runtimeConfig: projectWorkspaceRuntimeConfigSchema.optional().nullable()
5528
6069
  };
5529
6070
  function validateProjectWorkspace(value, ctx) {
5530
6071
  const sourceType = value.sourceType ?? "local_path";
@@ -5576,85 +6117,7 @@ var createProjectSchema = external_exports.object({
5576
6117
  });
5577
6118
  var updateProjectSchema = external_exports.object(projectFields).partial();
5578
6119
 
5579
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/issue.js
5580
- var executionWorkspaceStrategySchema2 = external_exports.object({
5581
- type: external_exports.enum(["project_primary", "git_worktree", "adapter_managed", "cloud_sandbox"]).optional(),
5582
- baseRef: external_exports.string().optional().nullable(),
5583
- branchTemplate: external_exports.string().optional().nullable(),
5584
- worktreeParentDir: external_exports.string().optional().nullable(),
5585
- provisionCommand: external_exports.string().optional().nullable(),
5586
- teardownCommand: external_exports.string().optional().nullable()
5587
- }).strict();
5588
- var issueExecutionWorkspaceSettingsSchema = external_exports.object({
5589
- mode: external_exports.enum(["inherit", "shared_workspace", "isolated_workspace", "operator_branch", "reuse_existing", "agent_default"]).optional(),
5590
- workspaceStrategy: executionWorkspaceStrategySchema2.optional().nullable(),
5591
- workspaceRuntime: external_exports.record(external_exports.unknown()).optional().nullable()
5592
- }).strict();
5593
- var issueAssigneeAdapterOverridesSchema = external_exports.object({
5594
- adapterConfig: external_exports.record(external_exports.unknown()).optional(),
5595
- useProjectWorkspace: external_exports.boolean().optional()
5596
- }).strict();
5597
- var createIssueSchema = external_exports.object({
5598
- projectId: external_exports.string().uuid().optional().nullable(),
5599
- projectWorkspaceId: external_exports.string().uuid().optional().nullable(),
5600
- goalId: external_exports.string().uuid().optional().nullable(),
5601
- parentId: external_exports.string().uuid().optional().nullable(),
5602
- title: external_exports.string().min(1),
5603
- description: external_exports.string().optional().nullable(),
5604
- status: external_exports.enum(ISSUE_STATUSES).optional().default("backlog"),
5605
- priority: external_exports.enum(ISSUE_PRIORITIES).optional().default("medium"),
5606
- assigneeAgentId: external_exports.string().uuid().optional().nullable(),
5607
- assigneeUserId: external_exports.string().optional().nullable(),
5608
- requestDepth: external_exports.number().int().nonnegative().optional().default(0),
5609
- billingCode: external_exports.string().optional().nullable(),
5610
- assigneeAdapterOverrides: issueAssigneeAdapterOverridesSchema.optional().nullable(),
5611
- executionWorkspaceId: external_exports.string().uuid().optional().nullable(),
5612
- executionWorkspacePreference: external_exports.enum([
5613
- "inherit",
5614
- "shared_workspace",
5615
- "isolated_workspace",
5616
- "operator_branch",
5617
- "reuse_existing",
5618
- "agent_default"
5619
- ]).optional().nullable(),
5620
- executionWorkspaceSettings: issueExecutionWorkspaceSettingsSchema.optional().nullable(),
5621
- labelIds: external_exports.array(external_exports.string().uuid()).optional()
5622
- });
5623
- var createIssueLabelSchema = external_exports.object({
5624
- name: external_exports.string().trim().min(1).max(48),
5625
- color: external_exports.string().regex(/^#(?:[0-9a-fA-F]{6})$/, "Color must be a 6-digit hex value")
5626
- });
5627
- var updateIssueSchema = createIssueSchema.partial().extend({
5628
- comment: external_exports.string().min(1).optional(),
5629
- hiddenAt: external_exports.string().datetime().nullable().optional()
5630
- });
5631
- var checkoutIssueSchema = external_exports.object({
5632
- agentId: external_exports.string().uuid(),
5633
- expectedStatuses: external_exports.array(external_exports.enum(ISSUE_STATUSES)).nonempty()
5634
- });
5635
- var addIssueCommentSchema = external_exports.object({
5636
- body: external_exports.string().min(1),
5637
- reopen: external_exports.boolean().optional(),
5638
- interrupt: external_exports.boolean().optional()
5639
- });
5640
- var linkIssueApprovalSchema = external_exports.object({
5641
- approvalId: external_exports.string().uuid()
5642
- });
5643
- var createIssueAttachmentMetadataSchema = external_exports.object({
5644
- issueCommentId: external_exports.string().uuid().optional().nullable()
5645
- });
5646
- var ISSUE_DOCUMENT_FORMATS = ["markdown"];
5647
- var issueDocumentFormatSchema = external_exports.enum(ISSUE_DOCUMENT_FORMATS);
5648
- var issueDocumentKeySchema = external_exports.string().trim().min(1).max(64).regex(/^[a-z0-9][a-z0-9_-]*$/, "Document key must be lowercase letters, numbers, _ or -");
5649
- var upsertIssueDocumentSchema = external_exports.object({
5650
- title: external_exports.string().trim().max(200).nullable().optional(),
5651
- format: issueDocumentFormatSchema,
5652
- body: external_exports.string().max(524288),
5653
- changeSummary: external_exports.string().trim().max(500).nullable().optional(),
5654
- baseRevisionId: external_exports.string().uuid().nullable().optional()
5655
- });
5656
-
5657
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/work-product.js
6120
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/work-product.js
5658
6121
  var issueWorkProductTypeSchema = external_exports.enum([
5659
6122
  "preview_url",
5660
6123
  "runtime_service",
@@ -5700,7 +6163,7 @@ var createIssueWorkProductSchema = external_exports.object({
5700
6163
  });
5701
6164
  var updateIssueWorkProductSchema = createIssueWorkProductSchema.partial();
5702
6165
 
5703
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/execution-workspace.js
6166
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/execution-workspace.js
5704
6167
  var executionWorkspaceStatusSchema = external_exports.enum([
5705
6168
  "active",
5706
6169
  "idle",
@@ -5708,14 +6171,111 @@ var executionWorkspaceStatusSchema = external_exports.enum([
5708
6171
  "archived",
5709
6172
  "cleanup_failed"
5710
6173
  ]);
6174
+ var executionWorkspaceConfigSchema = external_exports.object({
6175
+ provisionCommand: external_exports.string().optional().nullable(),
6176
+ teardownCommand: external_exports.string().optional().nullable(),
6177
+ cleanupCommand: external_exports.string().optional().nullable(),
6178
+ workspaceRuntime: external_exports.record(external_exports.unknown()).optional().nullable(),
6179
+ desiredState: external_exports.enum(["running", "stopped"]).optional().nullable()
6180
+ }).strict();
6181
+ var executionWorkspaceCloseReadinessStateSchema = external_exports.enum([
6182
+ "ready",
6183
+ "ready_with_warnings",
6184
+ "blocked"
6185
+ ]);
6186
+ var executionWorkspaceCloseActionKindSchema = external_exports.enum([
6187
+ "archive_record",
6188
+ "stop_runtime_services",
6189
+ "cleanup_command",
6190
+ "teardown_command",
6191
+ "git_worktree_remove",
6192
+ "git_branch_delete",
6193
+ "remove_local_directory"
6194
+ ]);
6195
+ var executionWorkspaceCloseActionSchema = external_exports.object({
6196
+ kind: executionWorkspaceCloseActionKindSchema,
6197
+ label: external_exports.string(),
6198
+ description: external_exports.string(),
6199
+ command: external_exports.string().nullable()
6200
+ }).strict();
6201
+ var executionWorkspaceCloseLinkedIssueSchema = external_exports.object({
6202
+ id: external_exports.string().uuid(),
6203
+ identifier: external_exports.string().nullable(),
6204
+ title: external_exports.string(),
6205
+ status: external_exports.string(),
6206
+ isTerminal: external_exports.boolean()
6207
+ }).strict();
6208
+ var executionWorkspaceCloseGitReadinessSchema = external_exports.object({
6209
+ repoRoot: external_exports.string().nullable(),
6210
+ workspacePath: external_exports.string().nullable(),
6211
+ branchName: external_exports.string().nullable(),
6212
+ baseRef: external_exports.string().nullable(),
6213
+ hasDirtyTrackedFiles: external_exports.boolean(),
6214
+ hasUntrackedFiles: external_exports.boolean(),
6215
+ dirtyEntryCount: external_exports.number().int().nonnegative(),
6216
+ untrackedEntryCount: external_exports.number().int().nonnegative(),
6217
+ aheadCount: external_exports.number().int().nonnegative().nullable(),
6218
+ behindCount: external_exports.number().int().nonnegative().nullable(),
6219
+ isMergedIntoBase: external_exports.boolean().nullable(),
6220
+ createdByRuntime: external_exports.boolean()
6221
+ }).strict();
6222
+ var workspaceRuntimeServiceSchema = external_exports.object({
6223
+ id: external_exports.string(),
6224
+ companyId: external_exports.string().uuid(),
6225
+ projectId: external_exports.string().uuid().nullable(),
6226
+ projectWorkspaceId: external_exports.string().uuid().nullable(),
6227
+ executionWorkspaceId: external_exports.string().uuid().nullable(),
6228
+ issueId: external_exports.string().uuid().nullable(),
6229
+ scopeType: external_exports.enum(["project_workspace", "execution_workspace", "run", "agent"]),
6230
+ scopeId: external_exports.string().nullable(),
6231
+ serviceName: external_exports.string(),
6232
+ status: external_exports.enum(["starting", "running", "stopped", "failed"]),
6233
+ lifecycle: external_exports.enum(["shared", "ephemeral"]),
6234
+ reuseKey: external_exports.string().nullable(),
6235
+ command: external_exports.string().nullable(),
6236
+ cwd: external_exports.string().nullable(),
6237
+ port: external_exports.number().int().nullable(),
6238
+ url: external_exports.string().nullable(),
6239
+ provider: external_exports.enum(["local_process", "adapter_managed"]),
6240
+ providerRef: external_exports.string().nullable(),
6241
+ ownerAgentId: external_exports.string().uuid().nullable(),
6242
+ startedByRunId: external_exports.string().uuid().nullable(),
6243
+ lastUsedAt: external_exports.coerce.date(),
6244
+ startedAt: external_exports.coerce.date(),
6245
+ stoppedAt: external_exports.coerce.date().nullable(),
6246
+ stopPolicy: external_exports.record(external_exports.unknown()).nullable(),
6247
+ healthStatus: external_exports.enum(["unknown", "healthy", "unhealthy"]),
6248
+ createdAt: external_exports.coerce.date(),
6249
+ updatedAt: external_exports.coerce.date()
6250
+ }).strict();
6251
+ var executionWorkspaceCloseReadinessSchema = external_exports.object({
6252
+ workspaceId: external_exports.string().uuid(),
6253
+ state: executionWorkspaceCloseReadinessStateSchema,
6254
+ blockingReasons: external_exports.array(external_exports.string()),
6255
+ warnings: external_exports.array(external_exports.string()),
6256
+ linkedIssues: external_exports.array(executionWorkspaceCloseLinkedIssueSchema),
6257
+ plannedActions: external_exports.array(executionWorkspaceCloseActionSchema),
6258
+ isDestructiveCloseAllowed: external_exports.boolean(),
6259
+ isSharedWorkspace: external_exports.boolean(),
6260
+ isProjectPrimaryWorkspace: external_exports.boolean(),
6261
+ git: executionWorkspaceCloseGitReadinessSchema.nullable(),
6262
+ runtimeServices: external_exports.array(workspaceRuntimeServiceSchema)
6263
+ }).strict();
5711
6264
  var updateExecutionWorkspaceSchema = external_exports.object({
6265
+ name: external_exports.string().min(1).optional(),
6266
+ cwd: external_exports.string().optional().nullable(),
6267
+ repoUrl: external_exports.string().optional().nullable(),
6268
+ baseRef: external_exports.string().optional().nullable(),
6269
+ branchName: external_exports.string().optional().nullable(),
6270
+ providerRef: external_exports.string().optional().nullable(),
5712
6271
  status: executionWorkspaceStatusSchema.optional(),
5713
6272
  cleanupEligibleAt: external_exports.string().datetime().optional().nullable(),
5714
6273
  cleanupReason: external_exports.string().optional().nullable(),
6274
+ config: executionWorkspaceConfigSchema.optional().nullable(),
5715
6275
  metadata: external_exports.record(external_exports.unknown()).optional().nullable()
5716
6276
  }).strict();
5717
6277
 
5718
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/goal.js
6278
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/goal.js
5719
6279
  var createGoalSchema = external_exports.object({
5720
6280
  title: external_exports.string().min(1),
5721
6281
  description: external_exports.string().optional().nullable(),
@@ -5726,7 +6286,7 @@ var createGoalSchema = external_exports.object({
5726
6286
  });
5727
6287
  var updateGoalSchema = createGoalSchema.partial();
5728
6288
 
5729
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/approval.js
6289
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/approval.js
5730
6290
  var createApprovalSchema = external_exports.object({
5731
6291
  type: external_exports.enum(APPROVAL_TYPES),
5732
6292
  requestedByAgentId: external_exports.string().uuid().optional().nullable(),
@@ -5748,7 +6308,7 @@ var addApprovalCommentSchema = external_exports.object({
5748
6308
  body: external_exports.string().min(1)
5749
6309
  });
5750
6310
 
5751
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/cost.js
6311
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/cost.js
5752
6312
  var createCostEventSchema = external_exports.object({
5753
6313
  agentId: external_exports.string().uuid(),
5754
6314
  issueId: external_exports.string().uuid().optional().nullable(),
@@ -5773,7 +6333,7 @@ var updateBudgetSchema = external_exports.object({
5773
6333
  budgetMonthlyCents: external_exports.number().int().nonnegative()
5774
6334
  });
5775
6335
 
5776
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/finance.js
6336
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/finance.js
5777
6337
  var createFinanceEventSchema = external_exports.object({
5778
6338
  agentId: external_exports.string().uuid().optional().nullable(),
5779
6339
  issueId: external_exports.string().uuid().optional().nullable(),
@@ -5804,12 +6364,12 @@ var createFinanceEventSchema = external_exports.object({
5804
6364
  currency: value.currency.toUpperCase()
5805
6365
  }));
5806
6366
 
5807
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/asset.js
6367
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/asset.js
5808
6368
  var createAssetImageMetadataSchema = external_exports.object({
5809
6369
  namespace: external_exports.string().trim().min(1).max(120).regex(/^[a-zA-Z0-9/_-]+$/).optional()
5810
6370
  });
5811
6371
 
5812
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/access.js
6372
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/access.js
5813
6373
  var createCompanyInviteSchema = external_exports.object({
5814
6374
  allowedJoinTypes: external_exports.enum(INVITE_JOIN_TYPES).default("both"),
5815
6375
  defaultsPayload: external_exports.record(external_exports.string(), external_exports.unknown()).optional().nullable(),
@@ -5838,6 +6398,19 @@ var listJoinRequestsQuerySchema = external_exports.object({
5838
6398
  var claimJoinRequestApiKeySchema = external_exports.object({
5839
6399
  claimSecret: external_exports.string().min(16).max(256)
5840
6400
  });
6401
+ var boardCliAuthAccessLevelSchema = external_exports.enum([
6402
+ "board",
6403
+ "instance_admin_required"
6404
+ ]);
6405
+ var createCliAuthChallengeSchema = external_exports.object({
6406
+ command: external_exports.string().min(1).max(240),
6407
+ clientName: external_exports.string().max(120).optional().nullable(),
6408
+ requestedAccess: boardCliAuthAccessLevelSchema.default("board"),
6409
+ requestedCompanyId: external_exports.string().uuid().optional().nullable()
6410
+ });
6411
+ var resolveCliAuthChallengeSchema = external_exports.object({
6412
+ token: external_exports.string().min(16).max(256)
6413
+ });
5841
6414
  var updateMemberPermissionsSchema = external_exports.object({
5842
6415
  grants: external_exports.array(external_exports.object({
5843
6416
  permissionKey: external_exports.enum(PERMISSION_KEYS),
@@ -5848,7 +6421,7 @@ var updateUserCompanyAccessSchema = external_exports.object({
5848
6421
  companyIds: external_exports.array(external_exports.string().uuid()).default([])
5849
6422
  });
5850
6423
 
5851
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/validators/plugin.js
6424
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/validators/plugin.js
5852
6425
  var jsonSchemaSchema = external_exports.record(external_exports.unknown()).refine((val) => {
5853
6426
  if (Object.keys(val).length === 0)
5854
6427
  return true;
@@ -6217,7 +6790,7 @@ var listPluginStateSchema = external_exports.object({
6217
6790
  namespace: external_exports.string().min(1).optional()
6218
6791
  });
6219
6792
 
6220
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/api.js
6793
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/api.js
6221
6794
  var API_PREFIX = "/api";
6222
6795
  var API = {
6223
6796
  health: `${API_PREFIX}/health`,
@@ -6238,7 +6811,7 @@ var API = {
6238
6811
  admin: `${API_PREFIX}/admin`
6239
6812
  };
6240
6813
 
6241
- // node_modules/.pnpm/@paperclipai+shared@2026.318.0/node_modules/@paperclipai/shared/dist/config-schema.js
6814
+ // node_modules/.pnpm/@paperclipai+shared@2026.403.0/node_modules/@paperclipai/shared/dist/config-schema.js
6242
6815
  var configMetaSchema = external_exports.object({
6243
6816
  version: external_exports.literal(1),
6244
6817
  updatedAt: external_exports.string(),
@@ -6315,12 +6888,16 @@ var secretsConfigSchema = external_exports.object({
6315
6888
  keyFilePath: "~/.paperclip/instances/default/secrets/master.key"
6316
6889
  })
6317
6890
  });
6891
+ var telemetryConfigSchema = external_exports.object({
6892
+ enabled: external_exports.boolean().default(true)
6893
+ }).default({});
6318
6894
  var paperclipConfigSchema = external_exports.object({
6319
6895
  $meta: configMetaSchema,
6320
6896
  llm: llmConfigSchema.optional(),
6321
6897
  database: databaseConfigSchema,
6322
6898
  logging: loggingConfigSchema,
6323
6899
  server: serverConfigSchema,
6900
+ telemetry: telemetryConfigSchema,
6324
6901
  auth: authConfigSchema.default({
6325
6902
  baseUrlMode: "auto",
6326
6903
  disableSignUp: false
@@ -6378,7 +6955,7 @@ var paperclipConfigSchema = external_exports.object({
6378
6955
  }
6379
6956
  });
6380
6957
 
6381
- // node_modules/.pnpm/@tomismeta+aperture-core@0.4.2/node_modules/@tomismeta/aperture-core/public-dist/index.js
6958
+ // node_modules/.pnpm/@tomismeta+aperture-core@0.5.0/node_modules/@tomismeta/aperture-core/public-dist/index.js
6382
6959
  import { join, dirname } from "path";
6383
6960
  import { readFile, mkdir, writeFile, rename } from "fs/promises";
6384
6961
  function scoreCandidate(candidate) {
@@ -6490,14 +7067,14 @@ function buildAttentionView(taskViews, options = {}) {
6490
7067
  let interruptive = [];
6491
7068
  let ambient = [];
6492
7069
  for (const taskView of taskViews) {
6493
- if (taskView.active) {
6494
- if (isBackground(taskView.active)) {
6495
- ambient.push(taskView.active);
7070
+ if (taskView.now) {
7071
+ if (isBackground(taskView.now)) {
7072
+ ambient.push(taskView.now);
6496
7073
  } else {
6497
- interruptive.push(taskView.active);
7074
+ interruptive.push(taskView.now);
6498
7075
  }
6499
7076
  }
6500
- interruptive.push(...taskView.queued);
7077
+ interruptive.push(...taskView.next);
6501
7078
  ambient.push(...taskView.ambient);
6502
7079
  }
6503
7080
  const referenceNow = options.now ?? latestTimestamp([...interruptive, ...ambient]);
@@ -6518,37 +7095,37 @@ function buildAttentionView(taskViews, options = {}) {
6518
7095
  ambient.sort((left, right) => compareFrames(left, right, referenceNow));
6519
7096
  if (options.operatorPresence === "absent") {
6520
7097
  return {
6521
- active: null,
6522
- queued: interruptive,
7098
+ now: null,
7099
+ next: interruptive,
6523
7100
  ambient
6524
7101
  };
6525
7102
  }
6526
7103
  if (interruptive.length > 0) {
6527
- const [active, ...queued] = interruptive;
7104
+ const [now, ...next] = interruptive;
6528
7105
  return {
6529
- active: active ?? null,
6530
- queued,
7106
+ now: now ?? null,
7107
+ next,
6531
7108
  ambient
6532
7109
  };
6533
7110
  }
6534
7111
  if (ambient.length > 0) {
6535
- const [active, ...rest] = ambient;
6536
- if (active && (scoreAttentionFrame(active, { now: referenceNow }) <= 0 || options.globalAttentionState === "overloaded" && scoreAttentionFrame(active, { now: referenceNow }) < 200)) {
7112
+ const [now, ...rest] = ambient;
7113
+ if (now && (scoreAttentionFrame(now, { now: referenceNow }) <= 0 || options.globalAttentionState === "overloaded" && scoreAttentionFrame(now, { now: referenceNow }) < 200)) {
6537
7114
  return {
6538
- active: null,
6539
- queued: [],
7115
+ now: null,
7116
+ next: [],
6540
7117
  ambient
6541
7118
  };
6542
7119
  }
6543
7120
  return {
6544
- active: active ?? null,
6545
- queued: [],
7121
+ now: now ?? null,
7122
+ next: [],
6546
7123
  ambient: rest
6547
7124
  };
6548
7125
  }
6549
7126
  return {
6550
- active: null,
6551
- queued: [],
7127
+ now: null,
7128
+ next: [],
6552
7129
  ambient: []
6553
7130
  };
6554
7131
  }
@@ -6581,7 +7158,7 @@ function latestTimestamp(frames) {
6581
7158
  function deriveAttentionState(summary) {
6582
7159
  const enoughPresentedForPattern = summary.counts.presented >= 5;
6583
7160
  const enoughObservedForPressure = summary.counts.presented + summary.counts.deferred >= 5;
6584
- if (enoughObservedForPressure && summary.counts.deferred >= 3 && summary.deferred.queued + summary.deferred.suppressed >= 3) {
7161
+ if (enoughObservedForPressure && summary.counts.deferred >= 3 && summary.deferred.next + summary.deferred.suppressed >= 3) {
6585
7162
  return "overloaded";
6586
7163
  }
6587
7164
  if (enoughPresentedForPattern && summary.dismissalRate >= 0.6 && summary.deferred.suppressed >= 2) {
@@ -6853,7 +7430,7 @@ function deriveAttentionBurden(summary, pressure, attentionState, operatorPresen
6853
7430
  reasons.push("recent deferrals are accumulating");
6854
7431
  } else if (deferredCount >= defaults.deferredCount.elevated) {
6855
7432
  score += 1;
6856
- reasons.push("recent deferrals suggest active burden");
7433
+ reasons.push("recent deferrals suggest growing burden");
6857
7434
  }
6858
7435
  if (interruptiveVisible >= defaults.interruptiveVisible.high) {
6859
7436
  score += 2;
@@ -7016,7 +7593,7 @@ function countInterruptiveVisible(attentionView) {
7016
7593
  if (!attentionView) {
7017
7594
  return 0;
7018
7595
  }
7019
- return [attentionView.active, ...attentionView.queued].filter((frame) => frame !== null).filter(isInterruptive).length;
7596
+ return [attentionView.now, ...attentionView.next].filter((frame) => frame !== null).filter(isInterruptive).length;
7020
7597
  }
7021
7598
  function isInterruptive(frame) {
7022
7599
  return frame.mode !== "status" || frame.consequence === "high" || frame.tone === "critical";
@@ -7107,15 +7684,15 @@ function isAttentionEvidenceContext(input) {
7107
7684
  }
7108
7685
  function emptyTaskView() {
7109
7686
  return {
7110
- active: null,
7111
- queued: [],
7687
+ now: null,
7688
+ next: [],
7112
7689
  ambient: []
7113
7690
  };
7114
7691
  }
7115
7692
  function emptyAttentionView() {
7116
7693
  return {
7117
- active: null,
7118
- queued: [],
7694
+ now: null,
7695
+ next: [],
7119
7696
  ambient: []
7120
7697
  };
7121
7698
  }
@@ -7136,7 +7713,7 @@ function emptyAttentionSignalSummary() {
7136
7713
  attentionShifted: 0
7137
7714
  },
7138
7715
  deferred: {
7139
- queued: 0,
7716
+ next: 0,
7140
7717
  suppressed: 0,
7141
7718
  manual: 0
7142
7719
  },
@@ -8144,8 +8721,8 @@ var evaluateBackgroundPolicyGateRule = (input) => {
8144
8721
  autoApprove: false,
8145
8722
  mayInterrupt: false,
8146
8723
  requiresOperatorResponse: false,
8147
- minimumPresentation: "ambient",
8148
- minimumPresentationIsSticky: true,
8724
+ minimumLane: "ambient",
8725
+ minimumLaneIsSticky: true,
8149
8726
  rationale: ["background work should remain peripheral by default"]
8150
8727
  }
8151
8728
  );
@@ -8160,8 +8737,8 @@ var evaluateBlockingPolicyGateRule = (input) => {
8160
8737
  autoApprove: false,
8161
8738
  mayInterrupt: true,
8162
8739
  requiresOperatorResponse: true,
8163
- minimumPresentation: "active",
8164
- minimumPresentationIsSticky: false,
8740
+ minimumLane: "now",
8741
+ minimumLaneIsSticky: false,
8165
8742
  rationale: ["blocking interactions require explicit operator attention"]
8166
8743
  }
8167
8744
  );
@@ -8190,6 +8767,20 @@ function sourceKey(source) {
8190
8767
  }
8191
8768
  return source.kind ?? source.id;
8192
8769
  }
8770
+ function readAttentionLane(value) {
8771
+ switch (value) {
8772
+ case "ambient":
8773
+ return "ambient";
8774
+ case "next":
8775
+ case "queue":
8776
+ return "next";
8777
+ case "now":
8778
+ case "active":
8779
+ return "now";
8780
+ default:
8781
+ return void 0;
8782
+ }
8783
+ }
8193
8784
  function matchPolicyRule(judgmentConfig, candidate) {
8194
8785
  const policy = judgmentConfig?.policy;
8195
8786
  if (!policy) {
@@ -8204,16 +8795,6 @@ function matchPolicyRule(judgmentConfig, candidate) {
8204
8795
  }
8205
8796
  return void 0;
8206
8797
  }
8207
- function readAttentionPresentationFloor(value) {
8208
- switch (value) {
8209
- case "ambient":
8210
- case "queue":
8211
- case "active":
8212
- return value;
8213
- default:
8214
- return void 0;
8215
- }
8216
- }
8217
8798
  function inferConfiguredPolicyToolFamily(candidate) {
8218
8799
  if (!isToolPolicyCandidate(candidate)) {
8219
8800
  return null;
@@ -8278,10 +8859,10 @@ var evaluateConfiguredPolicyGateRule = (input) => {
8278
8859
  const policyRule = matchPolicyRule(judgmentConfig, candidate);
8279
8860
  const requireContextExpansion = toolOverride?.requireContextExpansion === true || policyRule?.requireContextExpansion === true;
8280
8861
  const autoApprove = policyRule?.autoApprove === true && candidate.mode === "approval" && candidate.responseSpec.kind === "approval" && !requireContextExpansion;
8281
- const minimumPresentation = readAttentionPresentationFloor(toolOverride?.defaultPresentation) ?? policyRule?.minimumPresentation ?? (requireContextExpansion ? "active" : void 0);
8862
+ const minimumLane = readAttentionLane(toolOverride?.minimumLane ?? toolOverride?.defaultPresentation) ?? readAttentionLane(policyRule?.minimumLane) ?? (requireContextExpansion ? "now" : void 0);
8282
8863
  const mayInterrupt = policyRule?.mayInterrupt;
8283
- const requiresOperatorResponse = !autoApprove && (candidate.blocking || minimumPresentation === "active" || requireContextExpansion);
8284
- if (minimumPresentation === void 0 && mayInterrupt === void 0 && !toolOverride && !autoApprove) {
8864
+ const requiresOperatorResponse = !autoApprove && (candidate.blocking || minimumLane === "now" || requireContextExpansion);
8865
+ if (minimumLane === void 0 && mayInterrupt === void 0 && !toolOverride && !autoApprove) {
8285
8866
  return noopPolicyGateRule("configured_policy");
8286
8867
  }
8287
8868
  const rationale = [];
@@ -8299,8 +8880,8 @@ var evaluateConfiguredPolicyGateRule = (input) => {
8299
8880
  autoApprove: true,
8300
8881
  mayInterrupt: false,
8301
8882
  requiresOperatorResponse: false,
8302
- minimumPresentation: "ambient",
8303
- minimumPresentationIsSticky: true,
8883
+ minimumLane: "ambient",
8884
+ minimumLaneIsSticky: true,
8304
8885
  rationale
8305
8886
  }
8306
8887
  );
@@ -8313,8 +8894,8 @@ var evaluateConfiguredPolicyGateRule = (input) => {
8313
8894
  autoApprove: false,
8314
8895
  mayInterrupt: true,
8315
8896
  requiresOperatorResponse: true,
8316
- minimumPresentation: "active",
8317
- minimumPresentationIsSticky: false,
8897
+ minimumLane: "now",
8898
+ minimumLaneIsSticky: false,
8318
8899
  rationale
8319
8900
  }
8320
8901
  );
@@ -8325,8 +8906,8 @@ var evaluateConfiguredPolicyGateRule = (input) => {
8325
8906
  autoApprove: false,
8326
8907
  mayInterrupt: mayInterrupt ?? false,
8327
8908
  requiresOperatorResponse,
8328
- minimumPresentation: minimumPresentation ?? (candidate.blocking ? "active" : "queue"),
8329
- minimumPresentationIsSticky: minimumPresentation !== void 0 || mayInterrupt === false,
8909
+ minimumLane: minimumLane ?? (candidate.blocking ? "now" : "next"),
8910
+ minimumLaneIsSticky: minimumLane !== void 0 || mayInterrupt === false,
8330
8911
  rationale
8331
8912
  }
8332
8913
  );
@@ -8337,8 +8918,8 @@ var evaluateInterruptiveDefaultPolicyGateRule = () => verdictPolicyGateRule(
8337
8918
  autoApprove: false,
8338
8919
  mayInterrupt: true,
8339
8920
  requiresOperatorResponse: false,
8340
- minimumPresentation: "queue",
8341
- minimumPresentationIsSticky: false,
8921
+ minimumLane: "next",
8922
+ minimumLaneIsSticky: false,
8342
8923
  rationale: ["urgent non-blocking work may compete for interruptive attention"]
8343
8924
  }
8344
8925
  );
@@ -8412,7 +8993,7 @@ var evaluateInterruptEligibilityCriterionRule = (input) => {
8412
8993
  peripheralResolution,
8413
8994
  evidence
8414
8995
  } = input;
8415
- if (!policyVerdict.mayInterrupt && policyVerdict.minimumPresentationIsSticky) {
8996
+ if (!policyVerdict.mayInterrupt && policyVerdict.minimumLaneIsSticky) {
8416
8997
  return verdictPolicyCriterionRule(
8417
8998
  "interrupt_eligibility",
8418
8999
  preservedPeripheralCriterionVerdict(
@@ -8421,7 +9002,7 @@ var evaluateInterruptEligibilityCriterionRule = (input) => {
8421
9002
  )
8422
9003
  );
8423
9004
  }
8424
- if (candidate.blocking || candidate.episodeState === "actionable" || policyVerdict.autoApprove || policyVerdict.requiresOperatorResponse || policyVerdict.minimumPresentation === "active") {
9005
+ if (candidate.blocking || candidate.episodeState === "actionable" || policyVerdict.autoApprove || policyVerdict.requiresOperatorResponse || policyVerdict.minimumLane === "now") {
8425
9006
  return verdictPolicyCriterionRule(
8426
9007
  "interrupt_eligibility",
8427
9008
  clearCriterionVerdict(criterion)
@@ -8456,8 +9037,8 @@ var evaluateNoActiveFrameCriterionRule = (input) => {
8456
9037
  return noopPolicyCriterionRule("no_active_frame");
8457
9038
  }
8458
9039
  if (candidate.episodeId !== void 0 && [
8459
- evidence.attentionView.active,
8460
- ...evidence.attentionView.queued,
9040
+ evidence.attentionView.now,
9041
+ ...evidence.attentionView.next,
8461
9042
  ...evidence.attentionView.ambient
8462
9043
  ].filter((frame) => frame !== null).some(
8463
9044
  (frame) => frame.interactionId !== candidate.interactionId && readFrameEpisodeId(frame) === candidate.episodeId && !isDormantEpisodeState(readFrameEpisodeState(frame))
@@ -8495,7 +9076,7 @@ var evaluateOperatorAbsenceCriterionRule = (input) => {
8495
9076
  criterion,
8496
9077
  peripheralResolution,
8497
9078
  ambiguity: null,
8498
- rationale: ["operator absence keeps interruptive work peripheral until active attention returns"]
9079
+ rationale: ["operator absence keeps interruptive work peripheral until foreground attention returns"]
8499
9080
  }
8500
9081
  );
8501
9082
  };
@@ -8510,8 +9091,8 @@ var evaluatePeripheralStatusPolicyGateRule = (input) => {
8510
9091
  autoApprove: false,
8511
9092
  mayInterrupt: false,
8512
9093
  requiresOperatorResponse: false,
8513
- minimumPresentation: "ambient",
8514
- minimumPresentationIsSticky: false,
9094
+ minimumLane: "ambient",
9095
+ minimumLaneIsSticky: false,
8515
9096
  rationale: ["non-critical status work should start in the periphery"]
8516
9097
  }
8517
9098
  );
@@ -8668,8 +9249,8 @@ var AttentionPolicy = class {
8668
9249
  autoApprove: false,
8669
9250
  mayInterrupt: true,
8670
9251
  requiresOperatorResponse: false,
8671
- minimumPresentation: "queue",
8672
- minimumPresentationIsSticky: false,
9252
+ minimumLane: "next",
9253
+ minimumLaneIsSticky: false,
8673
9254
  rationale: ["urgent non-blocking work may compete for interruptive attention"]
8674
9255
  };
8675
9256
  return {
@@ -8737,7 +9318,7 @@ var AttentionPolicy = class {
8737
9318
  };
8738
9319
  }
8739
9320
  readPeripheralResolution(policyVerdict) {
8740
- return policyVerdict.minimumPresentation === "ambient" ? "ambient" : "queue";
9321
+ return policyVerdict.minimumLane === "ambient" ? "ambient" : "queue";
8741
9322
  }
8742
9323
  readSourceTrustAdjustment(candidate) {
8743
9324
  const sourceKey2 = candidate.source?.kind ?? candidate.source?.id;
@@ -8861,7 +9442,7 @@ function interruptClassForFrame(frame) {
8861
9442
  return 0;
8862
9443
  }
8863
9444
  function interruptClassForCandidate(candidate, policyVerdict) {
8864
- if (candidate.blocking || policyVerdict.requiresOperatorResponse || policyVerdict.minimumPresentation === "active") {
9445
+ if (candidate.blocking || policyVerdict.requiresOperatorResponse || policyVerdict.minimumLane === "now") {
8865
9446
  return 3;
8866
9447
  }
8867
9448
  if (candidate.tone === "critical" || candidate.consequence === "high") {
@@ -8960,7 +9541,7 @@ function isSameDecisionStream(activeFrame, candidate) {
8960
9541
  }
8961
9542
  var evaluateDeferralEscalationContinuityRule = (input) => {
8962
9543
  const { candidate, context, evidence } = input;
8963
- const activeFrame = evidence.attentionView.active ?? evidence.currentFrame;
9544
+ const activeFrame = evidence.attentionView.now ?? evidence.currentFrame;
8964
9545
  if (!activeFrame) {
8965
9546
  return noopContinuityRule("deferral_escalation");
8966
9547
  }
@@ -9034,7 +9615,7 @@ var evaluateSameEpisodeContinuityRule = (input) => {
9034
9615
  { kind: "activate", candidate },
9035
9616
  priorityForFrame(activeFrame),
9036
9617
  context.currentScore,
9037
- ["the active episode has progressed into an interruptive step"]
9618
+ ["the current episode has progressed into an interruptive step that belongs in now"]
9038
9619
  );
9039
9620
  }
9040
9621
  if (candidate.blocking && hasSemanticRelationKind(candidate.relationHints, "supersedes")) {
@@ -9043,7 +9624,7 @@ var evaluateSameEpisodeContinuityRule = (input) => {
9043
9624
  { kind: "activate", candidate },
9044
9625
  priorityForFrame(activeFrame),
9045
9626
  context.currentScore,
9046
- ["the active episode has advanced to a superseding step"]
9627
+ ["the current episode has advanced to a superseding step that belongs in now"]
9047
9628
  );
9048
9629
  }
9049
9630
  if (hasResurfacingPressure(evidence.continuitySignalSummary)) {
@@ -9054,7 +9635,7 @@ var evaluateSameEpisodeContinuityRule = (input) => {
9054
9635
  helpers.peripheralDecision(candidate, context.policyVerdict, evidence.surfaceCapabilities),
9055
9636
  priorityForFrame(activeFrame),
9056
9637
  context.currentScore,
9057
- ["related work stays bundled with the active episode"]
9638
+ ["related work stays bundled with the current episode already in now"]
9058
9639
  );
9059
9640
  };
9060
9641
  var evaluateSameInteractionContinuityRule = (input) => {
@@ -9079,8 +9660,8 @@ var evaluateVisibleEpisodeContinuityRule = (input) => {
9079
9660
  return noopContinuityRule("visible_episode");
9080
9661
  }
9081
9662
  const visibleRelatedFrames = [
9082
- evidence.attentionView.active,
9083
- ...evidence.attentionView.queued,
9663
+ evidence.attentionView.now,
9664
+ ...evidence.attentionView.next,
9084
9665
  ...evidence.attentionView.ambient
9085
9666
  ].filter((frame) => frame !== null).filter(
9086
9667
  (frame) => frame.interactionId !== candidate.interactionId && readFrameEpisodeId(frame) === candidate.episodeId && !isDormantEpisodeState(readFrameEpisodeState(frame))
@@ -9141,7 +9722,7 @@ var AttentionPlanner = class {
9141
9722
  };
9142
9723
  }
9143
9724
  batchedDecision(candidate, policyVerdict, attentionView, surfaceCapabilities) {
9144
- const episodeIsAlreadyInterruptive = candidate.episodeId !== void 0 && [attentionView?.active, ...attentionView?.queued ?? []].filter((frame) => frame !== null).some(
9725
+ const episodeIsAlreadyInterruptive = candidate.episodeId !== void 0 && [attentionView?.now, ...attentionView?.next ?? []].filter((frame) => frame !== null).some(
9145
9726
  (frame) => frame.interactionId !== candidate.interactionId && readFrameEpisodeId(frame) === candidate.episodeId && !isDormantEpisodeState(readFrameEpisodeState(frame))
9146
9727
  );
9147
9728
  if (episodeIsAlreadyInterruptive) {
@@ -9150,7 +9731,7 @@ var AttentionPlanner = class {
9150
9731
  return this.peripheralDecision(candidate, policyVerdict, surfaceCapabilities);
9151
9732
  }
9152
9733
  suppressedDecision(candidate, policyVerdict, utility, surfaceCapabilities) {
9153
- if ((utility.components.deferralAffinity > 0 || utility.components.consequenceCalibration > 0) && policyVerdict.minimumPresentation !== "active") {
9734
+ if ((utility.components.deferralAffinity > 0 || utility.components.consequenceCalibration > 0) && policyVerdict.minimumLane !== "now") {
9154
9735
  return { kind: "queue", candidate };
9155
9736
  }
9156
9737
  return this.peripheralDecision(candidate, policyVerdict, surfaceCapabilities);
@@ -9165,13 +9746,13 @@ var AttentionPlanner = class {
9165
9746
  if (!attentionView) {
9166
9747
  return false;
9167
9748
  }
9168
- const relatedEpisodeVisible = candidate.episodeId !== void 0 && [attentionView.active, ...attentionView.queued].filter((frame) => frame !== null).some(
9749
+ const relatedEpisodeVisible = candidate.episodeId !== void 0 && [attentionView.now, ...attentionView.next].filter((frame) => frame !== null).some(
9169
9750
  (frame) => frame.interactionId !== candidate.interactionId && readFrameEpisodeId(frame) === candidate.episodeId && !isDormantEpisodeState(readFrameEpisodeState(frame))
9170
9751
  );
9171
9752
  if (relatedEpisodeVisible) {
9172
9753
  return true;
9173
9754
  }
9174
- const urgentBacklog = [attentionView.active, ...attentionView.queued].filter((frame) => frame !== null).filter((frame) => {
9755
+ const urgentBacklog = [attentionView.now, ...attentionView.next].filter((frame) => frame !== null).filter((frame) => {
9175
9756
  if (frame.interactionId === candidate.interactionId) {
9176
9757
  return false;
9177
9758
  }
@@ -9186,7 +9767,7 @@ var AttentionPlanner = class {
9186
9767
  if (pressureForecast.overloadRisk === "low") {
9187
9768
  return false;
9188
9769
  }
9189
- if (candidate.blocking || policyVerdict.requiresOperatorResponse || policyVerdict.minimumPresentation === "active") {
9770
+ if (candidate.blocking || policyVerdict.requiresOperatorResponse || policyVerdict.minimumLane === "now") {
9190
9771
  return false;
9191
9772
  }
9192
9773
  if (candidate.consequence === "high" || candidate.tone === "critical") {
@@ -9207,7 +9788,7 @@ var AttentionPlanner = class {
9207
9788
  if (!activeFrame) {
9208
9789
  if (actionableEpisode) {
9209
9790
  if (evidence.pressureForecast.overloadRisk === "high") {
9210
- reasons.push("the episode has become actionable, but predicted overload keeps it queued instead of interrupting");
9791
+ reasons.push("the episode has become actionable, but predicted overload keeps it in next instead of surfacing it now");
9211
9792
  return {
9212
9793
  decision: { kind: "queue", candidate },
9213
9794
  currentPriority: null,
@@ -9246,7 +9827,7 @@ var AttentionPlanner = class {
9246
9827
  reasons
9247
9828
  };
9248
9829
  }
9249
- if (!context.policyVerdict.mayInterrupt && context.policyVerdict.minimumPresentation === "ambient") {
9830
+ if (!context.policyVerdict.mayInterrupt && context.policyVerdict.minimumLane === "ambient") {
9250
9831
  reasons.push("policy keeps this interaction ambient until stronger context arrives");
9251
9832
  return {
9252
9833
  decision: this.peripheralDecision(candidate, context.policyVerdict, evidence.surfaceCapabilities),
@@ -9255,7 +9836,7 @@ var AttentionPlanner = class {
9255
9836
  reasons
9256
9837
  };
9257
9838
  }
9258
- reasons.push("no current frame is active for this task");
9839
+ reasons.push("nothing is in now for this task");
9259
9840
  return {
9260
9841
  decision: { kind: "activate", candidate },
9261
9842
  currentPriority: null,
@@ -9269,7 +9850,7 @@ var AttentionPlanner = class {
9269
9850
  if (actionableEpisode) {
9270
9851
  if (currentBlocking || evidence.pressureForecast.overloadRisk === "high") {
9271
9852
  reasons.push(
9272
- currentBlocking ? "the episode has become actionable, but current blocking work keeps it queued" : "the episode has become actionable, but predicted overload keeps it queued"
9853
+ currentBlocking ? "the episode has become actionable, but current blocking work keeps it in next" : "the episode has become actionable, but predicted overload keeps it in next"
9273
9854
  );
9274
9855
  return {
9275
9856
  decision: { kind: "queue", candidate },
@@ -9296,7 +9877,7 @@ var AttentionPlanner = class {
9296
9877
  reasons
9297
9878
  };
9298
9879
  }
9299
- reasons.push("the episode has become actionable, so it stays queued even though policy still prevents interrupting");
9880
+ reasons.push("the episode has become actionable, so it stays in next even though policy still prevents interrupting");
9300
9881
  return {
9301
9882
  decision: { kind: "queue", candidate },
9302
9883
  currentPriority,
@@ -9306,7 +9887,7 @@ var AttentionPlanner = class {
9306
9887
  }
9307
9888
  if (currentBlocking && !candidate.blocking) {
9308
9889
  if (hasResurfacingPressure(evidence.continuitySignalSummary)) {
9309
- reasons.push("blocking work keeps resurfacing backlog queued so it stays visible until focus can return");
9890
+ reasons.push("blocking work keeps resurfacing backlog in next so it stays visible until focus can return");
9310
9891
  return {
9311
9892
  decision: { kind: "queue", candidate },
9312
9893
  currentPriority,
@@ -9347,7 +9928,7 @@ var AttentionPlanner = class {
9347
9928
  }
9348
9929
  if (this.shouldSuppressForBacklog(candidate, evidence.attentionView, candidate.timestamp)) {
9349
9930
  if (hasResurfacingPressure(evidence.continuitySignalSummary)) {
9350
- reasons.push("existing urgent backlog keeps resurfacing work queued so it remains visible");
9931
+ reasons.push("existing urgent backlog keeps resurfacing work in next so it remains visible");
9351
9932
  return {
9352
9933
  decision: { kind: "queue", candidate },
9353
9934
  currentPriority,
@@ -9356,7 +9937,7 @@ var AttentionPlanner = class {
9356
9937
  };
9357
9938
  }
9358
9939
  reasons.push(
9359
- context.utility.components.deferralAffinity > 0 ? "existing urgent backlog defers this work, but memory keeps it queued because it usually returns after deferral" : "existing urgent backlog keeps lower-value status work queued"
9940
+ context.utility.components.deferralAffinity > 0 ? "existing urgent backlog defers this work, but memory keeps it in next because it usually returns after deferral" : "existing urgent backlog keeps lower-value status work in next"
9360
9941
  );
9361
9942
  return {
9362
9943
  decision: this.suppressedDecision(
@@ -9450,7 +10031,7 @@ function parseReferenceTime(value) {
9450
10031
  return Number.isNaN(timestamp) ? 0 : timestamp;
9451
10032
  }
9452
10033
  function selectPeripheralBucket(candidate, policyVerdict, surfaceCapabilities = baseAttentionSurfaceCapabilities) {
9453
- if (policyVerdict.minimumPresentation === "ambient" && canRemainAmbientOnSurface(candidate, surfaceCapabilities)) {
10034
+ if (policyVerdict.minimumLane === "ambient" && canRemainAmbientOnSurface(candidate, surfaceCapabilities)) {
9454
10035
  return "ambient";
9455
10036
  }
9456
10037
  return "queue";
@@ -9835,7 +10416,7 @@ function summarizeAttentionSignals(signals) {
9835
10416
  attentionShifted: 0
9836
10417
  };
9837
10418
  const deferred = {
9838
- queued: 0,
10419
+ next: 0,
9839
10420
  suppressed: 0,
9840
10421
  manual: 0
9841
10422
  };
@@ -10016,9 +10597,14 @@ function parseJudgmentConfig(content) {
10016
10597
  continue;
10017
10598
  }
10018
10599
  if (section === "Policy" && ruleName) {
10600
+ const scalar = parseScalar(bullet.value);
10601
+ const key = normalizeJudgmentRuleKey(camelKey(bullet.key));
10019
10602
  policy.set(ruleName, {
10020
10603
  ...policy.get(ruleName) ?? {},
10021
- [camelKey(bullet.key)]: parseScalar(bullet.value)
10604
+ ...key === "minimumLane" ? (() => {
10605
+ const lane = readAttentionLane(scalar);
10606
+ return lane === void 0 ? {} : { minimumLane: lane };
10607
+ })() : { [key]: scalar }
10022
10608
  });
10023
10609
  continue;
10024
10610
  }
@@ -10057,6 +10643,14 @@ function parseJudgmentConfig(content) {
10057
10643
  ...plannerDefaults.size > 0 ? { plannerDefaults: Object.fromEntries(plannerDefaults.entries()) } : {}
10058
10644
  };
10059
10645
  }
10646
+ function normalizeJudgmentRuleKey(key) {
10647
+ switch (key) {
10648
+ case "minimumPresentation":
10649
+ return "minimumLane";
10650
+ default:
10651
+ return key;
10652
+ }
10653
+ }
10060
10654
  function readNumber2(value) {
10061
10655
  return value !== void 0 && /^-?\d+(?:\.\d+)?$/.test(value) ? Number(value) : null;
10062
10656
  }
@@ -10388,12 +10982,12 @@ function inferSemanticInterpretation(event) {
10388
10982
  relationHints: [],
10389
10983
  confidence: "high",
10390
10984
  reasons: semanticReasonsForLifecycle("task_started"),
10391
- provenance: {
10392
- intentFrame: "inferred",
10393
- activityClass: "inferred",
10394
- consequence: "inferred",
10395
- confidence: "inferred"
10396
- }
10985
+ provenance: inferredSemanticProvenance([
10986
+ "intentFrame",
10987
+ "activityClass",
10988
+ "consequence",
10989
+ "confidence"
10990
+ ])
10397
10991
  };
10398
10992
  case "task.updated":
10399
10993
  return inferTaskUpdateSemantics(event);
@@ -10408,12 +11002,12 @@ function inferSemanticInterpretation(event) {
10408
11002
  relationHints: [],
10409
11003
  confidence: "high",
10410
11004
  reasons: semanticReasonsForLifecycle("completion"),
10411
- provenance: {
10412
- intentFrame: "inferred",
10413
- activityClass: "inferred",
10414
- consequence: "inferred",
10415
- confidence: "inferred"
10416
- }
11005
+ provenance: inferredSemanticProvenance([
11006
+ "intentFrame",
11007
+ "activityClass",
11008
+ "consequence",
11009
+ "confidence"
11010
+ ])
10417
11011
  };
10418
11012
  case "task.cancelled":
10419
11013
  return {
@@ -10426,11 +11020,13 @@ function inferSemanticInterpretation(event) {
10426
11020
  confidence: "high",
10427
11021
  reasons: semanticReasonsForTaskStatus("completed", { wasCancelled: true }),
10428
11022
  provenance: {
10429
- intentFrame: "inferred",
10430
- activityClass: "inferred",
10431
- consequence: "inferred",
10432
- ...event.reason ? { whyNow: "inferred" } : {},
10433
- confidence: "inferred"
11023
+ ...inferredSemanticProvenance([
11024
+ "intentFrame",
11025
+ "activityClass",
11026
+ "consequence",
11027
+ "confidence"
11028
+ ]),
11029
+ ...event.reason ? inferredSemanticProvenance(["whyNow"]) : {}
10434
11030
  }
10435
11031
  };
10436
11032
  }
@@ -10441,7 +11037,7 @@ function inferTaskUpdateSemantics(event) {
10441
11037
  const relationHints = detectSemanticRelationHints(text);
10442
11038
  const taxonomyInput = buildTaxonomyInput(event.title, event.summary, event.toolFamily);
10443
11039
  const { toolFamily, source: toolFamilySource } = resolveSemanticToolFamily(taxonomyInput, true);
10444
- const relationProvenance = relationHints.length > 0 ? { relationHints: "inferred" } : {};
11040
+ const relationProvenance = relationHints.length > 0 ? inferredSemanticProvenance(["relationHints"]) : {};
10445
11041
  const observationalFailure = event.status === "failed" && detectObservationalFailureStatus(text, toolFamily);
10446
11042
  const routineObservationalFailureLowConsequence = event.status === "failed" && detectRoutineObservationalFailureLowConsequence(text, toolFamily);
10447
11043
  const expectedDiagnosticFailure = event.status === "failed" && detectExpectedDiagnosticFailure(text, toolFamily);
@@ -10464,12 +11060,14 @@ function inferTaskUpdateSemantics(event) {
10464
11060
  "task status indicates failure but the update reads like observational output"
10465
11061
  ],
10466
11062
  provenance: {
10467
- intentFrame: "inferred",
10468
- activityClass: "inferred",
10469
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
10470
- consequence: "inferred",
10471
- ...relationProvenance,
10472
- confidence: "inferred"
11063
+ ...inferredSemanticProvenance([
11064
+ "intentFrame",
11065
+ "activityClass",
11066
+ "consequence",
11067
+ "confidence"
11068
+ ]),
11069
+ ...semanticToolFamilyProvenance(toolFamilySource),
11070
+ ...relationProvenance
10473
11071
  }
10474
11072
  };
10475
11073
  }
@@ -10491,13 +11089,15 @@ function inferTaskUpdateSemantics(event) {
10491
11089
  "failure content looks like expected diagnostic output from repro work"
10492
11090
  ] : semanticReasonsForTaskStatus("failed", { impliedAsk }),
10493
11091
  provenance: {
10494
- intentFrame: "inferred",
10495
- activityClass: "inferred",
10496
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
10497
- consequence: "inferred",
10498
- whyNow: "inferred",
10499
- ...relationProvenance,
10500
- confidence: "inferred"
11092
+ ...inferredSemanticProvenance([
11093
+ "intentFrame",
11094
+ "activityClass",
11095
+ "consequence",
11096
+ "whyNow",
11097
+ "confidence"
11098
+ ]),
11099
+ ...semanticToolFamilyProvenance(toolFamilySource),
11100
+ ...relationProvenance
10501
11101
  }
10502
11102
  };
10503
11103
  case "blocked":
@@ -10512,13 +11112,15 @@ function inferTaskUpdateSemantics(event) {
10512
11112
  confidence: impliedAsk ? "medium" : "high",
10513
11113
  reasons: semanticReasonsForTaskStatus("blocked", { impliedAsk }),
10514
11114
  provenance: {
10515
- intentFrame: "inferred",
10516
- activityClass: "inferred",
10517
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
10518
- consequence: "inferred",
10519
- whyNow: "inferred",
10520
- ...relationProvenance,
10521
- confidence: "inferred"
11115
+ ...inferredSemanticProvenance([
11116
+ "intentFrame",
11117
+ "activityClass",
11118
+ "consequence",
11119
+ "whyNow",
11120
+ "confidence"
11121
+ ]),
11122
+ ...semanticToolFamilyProvenance(toolFamilySource),
11123
+ ...relationProvenance
10522
11124
  }
10523
11125
  };
10524
11126
  case "running":
@@ -10538,13 +11140,15 @@ function inferTaskUpdateSemantics(event) {
10538
11140
  confidence: impliedAsk ? "low" : "high",
10539
11141
  reasons: semanticReasonsForTaskStatus(event.status, { impliedAsk }),
10540
11142
  provenance: {
10541
- intentFrame: "inferred",
10542
- activityClass: "inferred",
10543
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
10544
- consequence: "inferred",
10545
- ...impliedAsk ? { whyNow: "inferred" } : {},
10546
- ...relationProvenance,
10547
- confidence: "inferred"
11143
+ ...inferredSemanticProvenance([
11144
+ "intentFrame",
11145
+ "activityClass",
11146
+ "consequence",
11147
+ "confidence"
11148
+ ]),
11149
+ ...semanticToolFamilyProvenance(toolFamilySource),
11150
+ ...impliedAsk ? inferredSemanticProvenance(["whyNow"]) : {},
11151
+ ...relationProvenance
10548
11152
  }
10549
11153
  };
10550
11154
  }
@@ -10559,8 +11163,7 @@ function inferHumanInputSemantics(event) {
10559
11163
  const relationHints = detectSemanticRelationHints(text);
10560
11164
  const baseConsequence = event.riskHint ?? consequenceFromRequestKind(event.request.kind, toolFamily);
10561
11165
  const consequence = inferConsequenceFromSemanticText(text, baseConsequence, toolFamily);
10562
- const relationProvenance = relationHints.length > 0 ? { relationHints: "inferred" } : {};
10563
- const toolFamilyProvenance = toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {};
11166
+ const relationProvenance = relationHints.length > 0 ? inferredSemanticProvenance(["relationHints"]) : {};
10564
11167
  return {
10565
11168
  intentFrame: semanticIntentFrameForRequestKind(event.request.kind),
10566
11169
  activityClass: semanticActivityClassForRequestKind(event.request.kind),
@@ -10575,16 +11178,32 @@ function inferHumanInputSemantics(event) {
10575
11178
  ...toolFamilySource === "explicit" ? ["tool family was supplied by the source or context"] : toolFamilySource === "inferred" ? ["tool family was inferred from approval wording"] : []
10576
11179
  ],
10577
11180
  provenance: {
10578
- intentFrame: "inferred",
10579
- activityClass: "inferred",
10580
- ...toolFamilyProvenance,
10581
- consequence: event.riskHint ? "source" : "inferred",
10582
- whyNow: "inferred",
10583
- ...relationProvenance,
10584
- confidence: event.riskHint ? "source" : "inferred"
11181
+ ...inferredSemanticProvenance(["intentFrame", "activityClass", "whyNow"]),
11182
+ ...semanticToolFamilyProvenance(toolFamilySource),
11183
+ ...event.riskHint ? sourceSemanticProvenance(["consequence", "confidence"]) : inferredSemanticProvenance(["consequence", "confidence"]),
11184
+ ...relationProvenance
10585
11185
  }
10586
11186
  };
10587
11187
  }
11188
+ function inferredSemanticProvenance(fields) {
11189
+ return semanticFieldProvenance(fields, "inferred");
11190
+ }
11191
+ function sourceSemanticProvenance(fields) {
11192
+ return semanticFieldProvenance(fields, "source");
11193
+ }
11194
+ function semanticFieldProvenance(fields, kind) {
11195
+ return Object.fromEntries(fields.map((field) => [field, kind]));
11196
+ }
11197
+ function semanticToolFamilyProvenance(source) {
11198
+ switch (source) {
11199
+ case "explicit":
11200
+ return sourceSemanticProvenance(["toolFamily"]);
11201
+ case "inferred":
11202
+ return inferredSemanticProvenance(["toolFamily"]);
11203
+ default:
11204
+ return {};
11205
+ }
11206
+ }
10588
11207
  function resolveSemanticToolFamily(input, allowTextInference) {
10589
11208
  const explicit = readExplicitSemanticToolFamily(input);
10590
11209
  if (explicit) {
@@ -10799,9 +11418,14 @@ function parseUserProfile(content) {
10799
11418
  continue;
10800
11419
  }
10801
11420
  if (section === "Tool Overrides" && tool) {
11421
+ const scalar = parseScalar(bullet.value);
11422
+ const key = normalizeToolOverrideKey(camelKey2(bullet.key));
10802
11423
  toolOverrides.set(tool, {
10803
11424
  ...toolOverrides.get(tool) ?? {},
10804
- [camelKey2(bullet.key)]: parseScalar(bullet.value)
11425
+ ...key === "minimumLane" ? (() => {
11426
+ const lane = readAttentionLane(scalar);
11427
+ return lane === void 0 ? {} : { minimumLane: lane };
11428
+ })() : { [key]: scalar }
10805
11429
  });
10806
11430
  }
10807
11431
  }
@@ -10830,6 +11454,15 @@ function parseUserProfile(content) {
10830
11454
  } : {}
10831
11455
  };
10832
11456
  }
11457
+ function normalizeToolOverrideKey(key) {
11458
+ switch (key) {
11459
+ case "defaultPresentation":
11460
+ case "minimumPresentation":
11461
+ return "minimumLane";
11462
+ default:
11463
+ return key;
11464
+ }
11465
+ }
10833
11466
  function parseMemoryProfile(content) {
10834
11467
  const meta = /* @__PURE__ */ new Map();
10835
11468
  const toolFamilies = /* @__PURE__ */ new Map();
@@ -10995,33 +11628,33 @@ var TaskViewStore = class {
10995
11628
  taskViews = /* @__PURE__ */ new Map();
10996
11629
  get(taskId) {
10997
11630
  return this.taskViews.get(taskId) ?? {
10998
- active: null,
10999
- queued: [],
11631
+ now: null,
11632
+ next: [],
11000
11633
  ambient: []
11001
11634
  };
11002
11635
  }
11003
- setActive(taskId, frame) {
11636
+ setNow(taskId, frame) {
11004
11637
  const taskView = this.get(taskId);
11005
- const nextQueued = taskView.queued.filter((item2) => item2.interactionId !== frame.interactionId);
11006
- const previousActive = taskView.active && taskView.active.interactionId !== frame.interactionId ? taskView.active : null;
11638
+ const nextFrames = taskView.next.filter((item2) => item2.interactionId !== frame.interactionId);
11639
+ const previousNow = taskView.now && taskView.now.interactionId !== frame.interactionId ? taskView.now : null;
11007
11640
  const next = {
11008
- active: frame,
11009
- queued: previousActive ? [previousActive, ...nextQueued] : nextQueued,
11641
+ now: frame,
11642
+ next: previousNow ? [previousNow, ...nextFrames] : nextFrames,
11010
11643
  ambient: taskView.ambient.filter((item2) => item2.interactionId !== frame.interactionId)
11011
11644
  };
11012
11645
  this.taskViews.set(taskId, next);
11013
11646
  return next;
11014
11647
  }
11015
- enqueue(taskId, frame) {
11016
- return this.upsert(taskId, "queued", frame);
11648
+ addNext(taskId, frame) {
11649
+ return this.upsert(taskId, "next", frame);
11017
11650
  }
11018
11651
  addAmbient(taskId, frame) {
11019
11652
  return this.upsert(taskId, "ambient", frame);
11020
11653
  }
11021
11654
  clear(taskId) {
11022
11655
  const next = {
11023
- active: null,
11024
- queued: [],
11656
+ now: null,
11657
+ next: [],
11025
11658
  ambient: []
11026
11659
  };
11027
11660
  this.taskViews.set(taskId, next);
@@ -11030,8 +11663,8 @@ var TaskViewStore = class {
11030
11663
  discard(taskId, interactionId) {
11031
11664
  const taskView = this.get(taskId);
11032
11665
  const next = {
11033
- active: taskView.active?.interactionId === interactionId ? null : taskView.active,
11034
- queued: taskView.queued.filter((frame) => frame.interactionId !== interactionId),
11666
+ now: taskView.now?.interactionId === interactionId ? null : taskView.now,
11667
+ next: taskView.next.filter((frame) => frame.interactionId !== interactionId),
11035
11668
  ambient: taskView.ambient.filter((frame) => frame.interactionId !== interactionId)
11036
11669
  };
11037
11670
  this.taskViews.set(taskId, next);
@@ -11039,30 +11672,30 @@ var TaskViewStore = class {
11039
11672
  }
11040
11673
  resolve(taskId, interactionId) {
11041
11674
  const taskView = this.get(taskId);
11042
- const remainingQueued = taskView.queued.filter((frame) => frame.interactionId !== interactionId);
11675
+ const remainingNext = taskView.next.filter((frame) => frame.interactionId !== interactionId);
11043
11676
  const remainingAmbient = taskView.ambient.filter((frame) => frame.interactionId !== interactionId);
11044
- let nextActive = taskView.active;
11045
- if (nextActive?.interactionId === interactionId) {
11046
- nextActive = remainingQueued.shift() ?? null;
11677
+ let nextNow = taskView.now;
11678
+ if (nextNow?.interactionId === interactionId) {
11679
+ nextNow = remainingNext.shift() ?? null;
11047
11680
  }
11048
11681
  const next = {
11049
- active: nextActive,
11050
- queued: remainingQueued,
11682
+ now: nextNow,
11683
+ next: remainingNext,
11051
11684
  ambient: remainingAmbient
11052
11685
  };
11053
11686
  this.taskViews.set(taskId, next);
11054
11687
  return next;
11055
11688
  }
11056
- upsert(taskId, bucket, frame) {
11689
+ upsert(taskId, lane, frame) {
11057
11690
  const taskView = this.get(taskId);
11058
- const dedupedQueued = taskView.queued.filter((item2) => item2.interactionId !== frame.interactionId);
11691
+ const dedupedNext = taskView.next.filter((item2) => item2.interactionId !== frame.interactionId);
11059
11692
  const dedupedAmbient = taskView.ambient.filter((item2) => item2.interactionId !== frame.interactionId);
11060
- const demotingActive = taskView.active?.interactionId === frame.interactionId;
11061
- const nextActive = demotingActive ? dedupedQueued.shift() ?? null : taskView.active;
11693
+ const demotingNow = taskView.now?.interactionId === frame.interactionId;
11694
+ const nextNow = demotingNow ? dedupedNext.shift() ?? null : taskView.now;
11062
11695
  const next = {
11063
- active: nextActive,
11064
- queued: bucket === "queued" ? [frame, ...dedupedQueued] : dedupedQueued,
11065
- ambient: bucket === "ambient" ? [frame, ...dedupedAmbient] : dedupedAmbient
11696
+ now: nextNow,
11697
+ next: lane === "next" ? [frame, ...dedupedNext] : dedupedNext,
11698
+ ambient: lane === "ambient" ? [frame, ...dedupedAmbient] : dedupedAmbient
11066
11699
  };
11067
11700
  this.taskViews.set(taskId, next);
11068
11701
  return next;
@@ -11071,6 +11704,84 @@ var TaskViewStore = class {
11071
11704
  return this.taskViews.values();
11072
11705
  }
11073
11706
  };
11707
+ var APERTURE_INTERNAL_TRACE_SUBSCRIBE = /* @__PURE__ */ Symbol("aperture.internal.subscribeTrace");
11708
+ function isCandidateTraceLike(trace) {
11709
+ return trace.evaluation.kind === "candidate";
11710
+ }
11711
+ function isCandidateTrace(trace) {
11712
+ return isCandidateTraceLike(trace);
11713
+ }
11714
+ function toPublicApertureTrace(trace) {
11715
+ if (trace.evaluation.kind === "noop") {
11716
+ return {
11717
+ timestamp: trace.timestamp,
11718
+ event: trace.event,
11719
+ evaluation: { kind: "noop" }
11720
+ };
11721
+ }
11722
+ if (trace.evaluation.kind === "clear") {
11723
+ return {
11724
+ timestamp: trace.timestamp,
11725
+ event: trace.event,
11726
+ evaluation: {
11727
+ kind: "clear",
11728
+ taskId: trace.evaluation.taskId
11729
+ }
11730
+ };
11731
+ }
11732
+ if (!isCandidateTrace(trace)) {
11733
+ throw new Error("Unexpected internal trace variant");
11734
+ }
11735
+ return {
11736
+ timestamp: trace.timestamp,
11737
+ event: trace.event,
11738
+ evaluation: { kind: "candidate" },
11739
+ ...trace.semantic !== void 0 ? { semantic: trace.semantic } : {},
11740
+ policyRules: {
11741
+ gateEvaluations: trace.policyRules.gateEvaluations.map((evaluation) => ({
11742
+ rule: evaluation.rule,
11743
+ kind: evaluation.kind,
11744
+ rationale: [...evaluation.rationale]
11745
+ })),
11746
+ criterion: trace.policyRules.criterion ? {
11747
+ criterion: {
11748
+ activationThreshold: trace.policyRules.criterion.criterion.activationThreshold,
11749
+ promotionMargin: trace.policyRules.criterion.criterion.promotionMargin
11750
+ },
11751
+ peripheralResolution: trace.policyRules.criterion.peripheralResolution,
11752
+ ambiguity: trace.policyRules.criterion.ambiguity ? {
11753
+ kind: trace.policyRules.criterion.ambiguity.kind,
11754
+ reason: trace.policyRules.criterion.ambiguity.reason,
11755
+ resolution: trace.policyRules.criterion.ambiguity.resolution
11756
+ } : null,
11757
+ rationale: [...trace.policyRules.criterion.rationale]
11758
+ } : null,
11759
+ criterionEvaluations: trace.policyRules.criterionEvaluations.map((evaluation) => ({
11760
+ rule: evaluation.rule,
11761
+ kind: evaluation.kind,
11762
+ rationale: [...evaluation.rationale]
11763
+ }))
11764
+ },
11765
+ coordination: {
11766
+ kind: trace.coordination.kind,
11767
+ resultLane: trace.coordination.resultLane,
11768
+ candidateScore: trace.coordination.candidateScore,
11769
+ currentScore: trace.coordination.currentScore,
11770
+ currentPriority: trace.coordination.currentPriority,
11771
+ ambiguity: trace.coordination.ambiguity ? {
11772
+ kind: trace.coordination.ambiguity.kind,
11773
+ reason: trace.coordination.ambiguity.reason,
11774
+ resolution: trace.coordination.ambiguity.resolution
11775
+ } : null,
11776
+ reasons: [...trace.coordination.reasons],
11777
+ continuityEvaluations: trace.coordination.continuityEvaluations.map((evaluation) => ({
11778
+ rule: evaluation.rule,
11779
+ kind: evaluation.kind,
11780
+ rationale: [...evaluation.rationale]
11781
+ }))
11782
+ }
11783
+ };
11784
+ }
11074
11785
  var TraceRecorder = class {
11075
11786
  recordNoop(snapshot) {
11076
11787
  return {
@@ -11118,7 +11829,7 @@ var TraceRecorder = class {
11118
11829
  },
11119
11830
  coordination: {
11120
11831
  kind: explanation.decision.kind,
11121
- resultBucket: findResultBucket(snapshot.attentionView, adjusted.taskId, adjusted.interactionId, explanation.decision.kind),
11832
+ resultLane: findResultLane(snapshot.attentionView, adjusted.taskId, adjusted.interactionId, explanation.decision.kind),
11122
11833
  candidateScore: explanation.candidateScore,
11123
11834
  currentScore: explanation.currentScore,
11124
11835
  currentPriority: explanation.currentPriority,
@@ -11176,12 +11887,15 @@ function buildSemanticInfluence(event, adjusted) {
11176
11887
  }
11177
11888
  const influence = [];
11178
11889
  if (event.type === "task.updated") {
11179
- influence.push("task status remained authoritative; semantic details stayed bounded to explanation, continuity, and ambiguity handling");
11890
+ influence.push("task status stayed authoritative; semantic details only affected context, continuity, and ambiguity handling");
11891
+ if ("activityClass" in event && event.activityClass === semantic.activityClass && semantic.activityClass !== void 0) {
11892
+ influence.push("activity class enriched canonical status facts");
11893
+ }
11180
11894
  if (event.toolFamily === semantic.toolFamily && semantic.toolFamily !== void 0) {
11181
- influence.push("tool family enriched the canonical status event without changing status routing");
11895
+ influence.push("tool family enriched canonical status facts without changing the route");
11182
11896
  }
11183
11897
  if (semantic.relationHints.length > 0) {
11184
- influence.push("relation hints were available to continuity handling");
11898
+ influence.push("relation hints informed continuity handling");
11185
11899
  }
11186
11900
  if (semantic.abstained === true) {
11187
11901
  influence.push("semantic abstention can keep non-blocking status work peripheral until clearer evidence arrives");
@@ -11191,18 +11905,21 @@ function buildSemanticInfluence(event, adjusted) {
11191
11905
  return influence;
11192
11906
  }
11193
11907
  if (event.type === "human.input.requested") {
11908
+ if ("activityClass" in event && event.activityClass === semantic.activityClass && semantic.activityClass !== void 0) {
11909
+ influence.push("activity class was projected into the canonical request");
11910
+ }
11194
11911
  if (event.consequence === semantic.consequence && semantic.consequence !== void 0) {
11195
- influence.push("semantic consequence shaped the canonical human-input consequence");
11912
+ influence.push("semantic consequence set the canonical human-input consequence");
11196
11913
  }
11197
11914
  if (semantic.toolFamily !== void 0) {
11198
11915
  if (event.request.kind === "approval") {
11199
11916
  influence.push("tool family remained decision-bearing on the approval path");
11200
11917
  } else {
11201
- influence.push("tool family stayed explanatory on the question/form path");
11918
+ influence.push("tool family stayed context-only on the question/form path");
11202
11919
  }
11203
11920
  }
11204
11921
  if (semantic.relationHints.length > 0) {
11205
- influence.push("relation hints were available to continuity handling");
11922
+ influence.push("relation hints informed continuity handling");
11206
11923
  }
11207
11924
  if (semantic.abstained === true) {
11208
11925
  influence.push(
@@ -11214,7 +11931,7 @@ function buildSemanticInfluence(event, adjusted) {
11214
11931
  );
11215
11932
  }
11216
11933
  if (influence.length === 0) {
11217
- influence.push("semantic interpretation mainly stayed explanatory beyond the explicit request");
11934
+ influence.push("semantic interpretation mostly stayed context-only beyond the explicit request");
11218
11935
  }
11219
11936
  return influence;
11220
11937
  }
@@ -11232,6 +11949,9 @@ function buildSemanticImpact(event, adjusted) {
11232
11949
  };
11233
11950
  }
11234
11951
  explanatory.add("intent");
11952
+ if (semantic.activityClass !== void 0) {
11953
+ explanatory.add("activity");
11954
+ }
11235
11955
  if (semantic.toolFamily !== void 0) {
11236
11956
  explanatory.add("tool");
11237
11957
  }
@@ -11252,6 +11972,9 @@ function buildSemanticImpact(event, adjusted) {
11252
11972
  }
11253
11973
  switch (event.type) {
11254
11974
  case "task.updated":
11975
+ if ("activityClass" in event && event.activityClass === semantic.activityClass && semantic.activityClass !== void 0) {
11976
+ promoteSemanticField(explanatory, decisionBearing, "activity", "activity (canonical)");
11977
+ }
11255
11978
  if (semantic.toolFamily !== void 0 && event.toolFamily === semantic.toolFamily) {
11256
11979
  promoteSemanticField(explanatory, decisionBearing, "tool", "tool (bounded)");
11257
11980
  }
@@ -11260,6 +11983,9 @@ function buildSemanticImpact(event, adjusted) {
11260
11983
  }
11261
11984
  break;
11262
11985
  case "human.input.requested":
11986
+ if ("activityClass" in event && event.activityClass === semantic.activityClass && semantic.activityClass !== void 0) {
11987
+ promoteSemanticField(explanatory, decisionBearing, "activity", "activity (canonical)");
11988
+ }
11263
11989
  if (semantic.consequence !== void 0 && event.consequence === semantic.consequence) {
11264
11990
  promoteSemanticField(explanatory, decisionBearing, "consequence", "consequence (canonical)");
11265
11991
  }
@@ -11291,15 +12017,15 @@ function promoteSemanticField(explanatory, decisionBearing, fieldLabel, decision
11291
12017
  explanatory.delete(fieldLabel);
11292
12018
  decisionBearing.add(decisionLabel);
11293
12019
  }
11294
- function findResultBucket(attentionView, taskId, interactionId, decisionKind) {
12020
+ function findResultLane(attentionView, taskId, interactionId, decisionKind) {
11295
12021
  if (decisionKind === "auto_approve" || decisionKind === "clear") {
11296
12022
  return "none";
11297
12023
  }
11298
- if (attentionView.active && attentionView.active.taskId === taskId && attentionView.active.interactionId === interactionId) {
11299
- return "active";
12024
+ if (attentionView.now && attentionView.now.taskId === taskId && attentionView.now.interactionId === interactionId) {
12025
+ return "now";
11300
12026
  }
11301
- if (attentionView.queued.some((frame) => frame.taskId === taskId && frame.interactionId === interactionId)) {
11302
- return "queued";
12027
+ if (attentionView.next.some((frame) => frame.taskId === taskId && frame.interactionId === interactionId)) {
12028
+ return "next";
11303
12029
  }
11304
12030
  if (attentionView.ambient.some((frame) => frame.taskId === taskId && frame.interactionId === interactionId)) {
11305
12031
  return "ambient";
@@ -11313,6 +12039,7 @@ var ApertureCore = class _ApertureCore {
11313
12039
  responseListeners = /* @__PURE__ */ new Set();
11314
12040
  signalListeners = /* @__PURE__ */ new Set();
11315
12041
  traceListeners = /* @__PURE__ */ new Set();
12042
+ internalTraceListeners = /* @__PURE__ */ new Set();
11316
12043
  taskViews = new TaskViewStore();
11317
12044
  signals = new AttentionSignalStore();
11318
12045
  episodes = new EpisodeTracker();
@@ -11567,7 +12294,7 @@ var ApertureCore = class _ApertureCore {
11567
12294
  }
11568
12295
  }
11569
12296
  getFrame(taskId) {
11570
- return this.taskViews.get(taskId).active ?? null;
12297
+ return this.taskViews.get(taskId).now ?? null;
11571
12298
  }
11572
12299
  subscribe(taskId, listener) {
11573
12300
  const listeners = this.frameListeners.get(taskId) ?? /* @__PURE__ */ new Set();
@@ -11618,6 +12345,12 @@ var ApertureCore = class _ApertureCore {
11618
12345
  this.traceListeners.delete(listener);
11619
12346
  };
11620
12347
  }
12348
+ [APERTURE_INTERNAL_TRACE_SUBSCRIBE](listener) {
12349
+ this.internalTraceListeners.add(listener);
12350
+ return () => {
12351
+ this.internalTraceListeners.delete(listener);
12352
+ };
12353
+ }
11621
12354
  submit(response) {
11622
12355
  this.assertValidFrameResponse(response);
11623
12356
  const current = this.findFrameByInteractionId(response.taskId, response.interactionId);
@@ -11635,7 +12368,7 @@ var ApertureCore = class _ApertureCore {
11635
12368
  this.recordSignal(this.signalForResponse(current, response, timestamp));
11636
12369
  this.episodes.resolveInteraction(response.interactionId);
11637
12370
  const taskView = this.taskViews.resolve(response.taskId, response.interactionId);
11638
- const newPrimary = taskView.active;
12371
+ const newPrimary = taskView.now;
11639
12372
  const nextAttentionView = this.getAttentionView();
11640
12373
  this.recordAttentionTransition(previousAttentionView, nextAttentionView, timestamp);
11641
12374
  if (newPrimary) {
@@ -11744,11 +12477,11 @@ var ApertureCore = class _ApertureCore {
11744
12477
  retiredFrame.interactionId
11745
12478
  );
11746
12479
  if (retiredFrame.taskId !== frame.taskId) {
11747
- this.notifyFrame(retiredFrame.taskId, retiredTaskView.active);
12480
+ this.notifyFrame(retiredFrame.taskId, retiredTaskView.now);
11748
12481
  this.notifyTaskView(retiredFrame.taskId, retiredTaskView);
11749
12482
  }
11750
12483
  }
11751
- const taskView = this.taskViews.setActive(frame.taskId, frame);
12484
+ const taskView = this.taskViews.setNow(frame.taskId, frame);
11752
12485
  const nextAttentionView = this.getAttentionView();
11753
12486
  this.recordAttentionTransition(previousAttentionView, nextAttentionView, frame.timing.updatedAt);
11754
12487
  this.recordSignal({
@@ -11790,11 +12523,11 @@ var ApertureCore = class _ApertureCore {
11790
12523
  applyClear(taskId) {
11791
12524
  const previousAttentionView = this.getAttentionView();
11792
12525
  const existingTaskView = this.taskViews.get(taskId);
11793
- const hadAnyVisibleState = existingTaskView.active !== null || existingTaskView.queued.length > 0 || existingTaskView.ambient.length > 0;
12526
+ const hadAnyVisibleState = existingTaskView.now !== null || existingTaskView.next.length > 0 || existingTaskView.ambient.length > 0;
11794
12527
  if (!hadAnyVisibleState) {
11795
12528
  return null;
11796
12529
  }
11797
- for (const frame of [existingTaskView.active, ...existingTaskView.queued, ...existingTaskView.ambient]) {
12530
+ for (const frame of [existingTaskView.now, ...existingTaskView.next, ...existingTaskView.ambient]) {
11798
12531
  if (!frame) {
11799
12532
  continue;
11800
12533
  }
@@ -11809,18 +12542,18 @@ var ApertureCore = class _ApertureCore {
11809
12542
  return null;
11810
12543
  }
11811
12544
  queueFrame(taskId, frame) {
11812
- const taskView = this.taskViews.enqueue(taskId, frame);
11813
- this.recordDeferredSignal(frame, "queued");
12545
+ const taskView = this.taskViews.addNext(taskId, frame);
12546
+ this.recordDeferredSignal(frame, "next");
11814
12547
  this.notifyTaskView(taskId, taskView);
11815
12548
  this.notifyAttentionView();
11816
- return taskView.active ?? frame;
12549
+ return taskView.now ?? frame;
11817
12550
  }
11818
12551
  addAmbientFrame(taskId, frame) {
11819
12552
  const taskView = this.taskViews.addAmbient(taskId, frame);
11820
12553
  this.recordDeferredSignal(frame, "suppressed");
11821
12554
  this.notifyTaskView(taskId, taskView);
11822
12555
  this.notifyAttentionView();
11823
- return taskView.active ?? frame;
12556
+ return taskView.now ?? frame;
11824
12557
  }
11825
12558
  materializePeripheralFrame(candidate, bucket, attentionView) {
11826
12559
  const existing = candidate.episodeId ? this.findPeripheralEpisodeFrame(candidate.episodeId, attentionView) : null;
@@ -11836,8 +12569,8 @@ var ApertureCore = class _ApertureCore {
11836
12569
  };
11837
12570
  const previousTaskView = this.taskViews.discard(existing.frame.taskId, existing.frame.interactionId);
11838
12571
  this.notifyTaskView(existing.frame.taskId, previousTaskView);
11839
- const nextTaskView = nextBucket === "queue" ? this.taskViews.enqueue(merged.taskId, merged) : this.taskViews.addAmbient(merged.taskId, merged);
11840
- this.recordDeferredSignal(merged, nextBucket === "queue" ? "queued" : "suppressed", candidate);
12572
+ const nextTaskView = nextBucket === "queue" ? this.taskViews.addNext(merged.taskId, merged) : this.taskViews.addAmbient(merged.taskId, merged);
12573
+ this.recordDeferredSignal(merged, nextBucket === "queue" ? "next" : "suppressed", candidate);
11841
12574
  this.notifyTaskView(merged.taskId, nextTaskView);
11842
12575
  this.notifyAttentionView();
11843
12576
  return merged;
@@ -11861,8 +12594,8 @@ var ApertureCore = class _ApertureCore {
11861
12594
  return [];
11862
12595
  }
11863
12596
  return [
11864
- attentionView.active,
11865
- ...attentionView.queued,
12597
+ attentionView.now,
12598
+ ...attentionView.next,
11866
12599
  ...attentionView.ambient
11867
12600
  ].filter(
11868
12601
  (frame) => frame !== null && frame.interactionId !== candidate.interactionId && readFrameEpisodeId(frame) === candidate.episodeId && !isDormantEpisodeState(readFrameEpisodeState(frame))
@@ -11897,7 +12630,7 @@ var ApertureCore = class _ApertureCore {
11897
12630
  return expiresAt;
11898
12631
  }
11899
12632
  findPeripheralEpisodeFrame(episodeId, attentionView) {
11900
- const queued = attentionView.queued.find(
12633
+ const queued = attentionView.next.find(
11901
12634
  (frame) => readFrameEpisodeId(frame) === episodeId && !isDormantEpisodeState(readFrameEpisodeState(frame))
11902
12635
  );
11903
12636
  if (queued) {
@@ -11972,9 +12705,13 @@ var ApertureCore = class _ApertureCore {
11972
12705
  }
11973
12706
  }
11974
12707
  notifyTrace(trace) {
11975
- for (const listener of this.traceListeners) {
12708
+ for (const listener of this.internalTraceListeners) {
11976
12709
  listener(trace);
11977
12710
  }
12711
+ const publicTrace = toPublicApertureTrace(trace);
12712
+ for (const listener of this.traceListeners) {
12713
+ listener(publicTrace);
12714
+ }
11978
12715
  }
11979
12716
  signalForResponse(frame, response, timestamp) {
11980
12717
  const latencyMs = this.calculateLatency(frame, timestamp);
@@ -12029,8 +12766,8 @@ var ApertureCore = class _ApertureCore {
12029
12766
  return Math.max(0, completedAt - startedAt);
12030
12767
  }
12031
12768
  recordAttentionTransition(previousAttentionView, nextAttentionView, timestamp) {
12032
- const previous = previousAttentionView.active;
12033
- const next = nextAttentionView.active;
12769
+ const previous = previousAttentionView.now;
12770
+ const next = nextAttentionView.now;
12034
12771
  if (!next) {
12035
12772
  return;
12036
12773
  }
@@ -12066,7 +12803,7 @@ var ApertureCore = class _ApertureCore {
12066
12803
  }
12067
12804
  }
12068
12805
  recordReturnSignal(previousAttentionView, next, timestamp) {
12069
- const from = previousAttentionView.queued.some((frame) => sameFrame(frame, next)) ? "queued" : previousAttentionView.ambient.some((frame) => sameFrame(frame, next)) ? "ambient" : null;
12806
+ const from = previousAttentionView.next.some((frame) => sameFrame(frame, next)) ? "next" : previousAttentionView.ambient.some((frame) => sameFrame(frame, next)) ? "ambient" : null;
12070
12807
  if (!from) {
12071
12808
  return;
12072
12809
  }
@@ -12095,10 +12832,10 @@ var ApertureCore = class _ApertureCore {
12095
12832
  }
12096
12833
  findFrame(taskId, interactionId) {
12097
12834
  const taskView = this.taskViews.get(taskId);
12098
- if (taskView.active?.interactionId === interactionId) {
12099
- return taskView.active;
12835
+ if (taskView.now?.interactionId === interactionId) {
12836
+ return taskView.now;
12100
12837
  }
12101
- const queued = taskView.queued.find((frame) => frame.interactionId === interactionId);
12838
+ const queued = taskView.next.find((frame) => frame.interactionId === interactionId);
12102
12839
  if (queued) {
12103
12840
  return queued;
12104
12841
  }
@@ -12271,12 +13008,12 @@ function createEmptySnapshot(companyId) {
12271
13008
  return {
12272
13009
  companyId,
12273
13010
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
12274
- active: null,
12275
- queued: [],
13011
+ now: null,
13012
+ next: [],
12276
13013
  ambient: [],
12277
13014
  counts: {
12278
- active: 0,
12279
- queued: 0,
13015
+ now: 0,
13016
+ next: 0,
12280
13017
  ambient: 0,
12281
13018
  total: 0
12282
13019
  }
@@ -12293,26 +13030,82 @@ function createEmptyReviewState(companyId) {
12293
13030
  };
12294
13031
  }
12295
13032
  function createAttentionSnapshot(companyId, view, lastEvent, updatedAt) {
12296
- const active = toStoredFrame(view.active);
12297
- const queued = view.queued.map((frame) => toStoredFrame(frame)).filter((frame) => frame !== null);
13033
+ const legacyView = view;
13034
+ const now = toStoredFrame("now" in view ? view.now : legacyView.active ?? null);
13035
+ const next = ("next" in view ? view.next : legacyView.queued ?? []).map((frame) => toStoredFrame(frame)).filter((frame) => frame !== null);
12298
13036
  const ambient = view.ambient.map((frame) => toStoredFrame(frame)).filter((frame) => frame !== null);
12299
13037
  return {
12300
13038
  companyId,
12301
13039
  updatedAt: updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
12302
- active,
12303
- queued,
13040
+ now,
13041
+ next,
12304
13042
  ambient,
12305
13043
  counts: {
12306
- active: active ? 1 : 0,
12307
- queued: queued.length,
13044
+ now: now ? 1 : 0,
13045
+ next: next.length,
12308
13046
  ambient: ambient.length,
12309
- total: (active ? 1 : 0) + queued.length + ambient.length
13047
+ total: (now ? 1 : 0) + next.length + ambient.length
12310
13048
  },
12311
13049
  ...lastEvent ? { lastEvent } : {}
12312
13050
  };
12313
13051
  }
13052
+ function asRecord(value) {
13053
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
13054
+ }
13055
+ function asStoredFrame(value) {
13056
+ const frame = asRecord(value);
13057
+ if (!frame) return null;
13058
+ return typeof frame.taskId === "string" && typeof frame.interactionId === "string" ? frame : null;
13059
+ }
13060
+ function asStoredFrames(value) {
13061
+ if (!Array.isArray(value)) return [];
13062
+ return value.map(asStoredFrame).filter((frame) => frame !== null);
13063
+ }
13064
+ function normalizeAttentionSnapshot(companyId, value) {
13065
+ const snapshot = asRecord(value);
13066
+ if (!snapshot) return null;
13067
+ if (snapshot.companyId !== companyId || typeof snapshot.updatedAt !== "string") return null;
13068
+ const legacyCounts = asRecord(snapshot.counts);
13069
+ const review = asRecord(snapshot.review);
13070
+ const unread = asRecord(review?.unread);
13071
+ const now = asStoredFrame(snapshot.now ?? snapshot.active ?? null);
13072
+ const next = asStoredFrames(snapshot.next ?? snapshot.queued ?? []);
13073
+ const ambient = asStoredFrames(snapshot.ambient);
13074
+ return {
13075
+ companyId,
13076
+ updatedAt: snapshot.updatedAt,
13077
+ now,
13078
+ next,
13079
+ ambient,
13080
+ counts: {
13081
+ now: typeof legacyCounts?.now === "number" ? legacyCounts.now : typeof legacyCounts?.active === "number" ? legacyCounts.active : now ? 1 : 0,
13082
+ next: typeof legacyCounts?.next === "number" ? legacyCounts.next : typeof legacyCounts?.queued === "number" ? legacyCounts.queued : next.length,
13083
+ ambient: typeof legacyCounts?.ambient === "number" ? legacyCounts.ambient : ambient.length,
13084
+ total: typeof legacyCounts?.total === "number" ? legacyCounts.total : (now ? 1 : 0) + next.length + ambient.length
13085
+ },
13086
+ ...review ? {
13087
+ review: {
13088
+ ...typeof review.lastSeenAt === "string" ? { lastSeenAt: review.lastSeenAt } : {},
13089
+ unread: {
13090
+ now: typeof unread?.now === "number" ? unread.now : typeof unread?.active === "number" ? unread.active : 0,
13091
+ next: typeof unread?.next === "number" ? unread.next : typeof unread?.queued === "number" ? unread.queued : 0,
13092
+ ambient: typeof unread?.ambient === "number" ? unread.ambient : 0,
13093
+ total: typeof unread?.total === "number" ? unread.total : 0
13094
+ }
13095
+ }
13096
+ } : {},
13097
+ ...asRecord(snapshot.lastEvent) ? {
13098
+ lastEvent: {
13099
+ eventType: String(snapshot.lastEvent.eventType),
13100
+ ...typeof snapshot.lastEvent.entityId === "string" ? { entityId: snapshot.lastEvent.entityId } : {},
13101
+ ...typeof snapshot.lastEvent.entityType === "string" ? { entityType: snapshot.lastEvent.entityType } : {}
13102
+ }
13103
+ } : {}
13104
+ };
13105
+ }
12314
13106
 
12315
13107
  // src/aperture/core-store.ts
13108
+ var MAX_TRACE_HISTORY = 100;
12316
13109
  var ApertureCompanyStore = class {
12317
13110
  sessions = /* @__PURE__ */ new Map();
12318
13111
  ingest(companyId, event, source) {
@@ -12334,6 +13127,9 @@ var ApertureCompanyStore = class {
12334
13127
  getLedger(companyId) {
12335
13128
  return [...this.sessions.get(companyId)?.ledger ?? []];
12336
13129
  }
13130
+ getTraces(companyId) {
13131
+ return [...this.sessions.get(companyId)?.traces ?? []];
13132
+ }
12337
13133
  appendLedgerEntry(companyId, entry) {
12338
13134
  const session = this.ensureSession(companyId);
12339
13135
  session.ledger = [...session.ledger, entry];
@@ -12387,12 +13183,8 @@ var ApertureCompanyStore = class {
12387
13183
  return this.getLedger(companyId);
12388
13184
  }
12389
13185
  rebuildFromLedger(companyId, ledger) {
12390
- const session = {
12391
- core: new ApertureCore(),
12392
- snapshot: null,
12393
- ledger: [...ledger],
12394
- eventCount: 0
12395
- };
13186
+ const session = this.createSession();
13187
+ session.ledger = [...ledger];
12396
13188
  let lastSource;
12397
13189
  let lastOccurredAt;
12398
13190
  for (const entry of ledger) {
@@ -12415,13 +13207,22 @@ var ApertureCompanyStore = class {
12415
13207
  ensureSession(companyId) {
12416
13208
  let session = this.sessions.get(companyId);
12417
13209
  if (session) return session;
12418
- session = {
12419
- core: new ApertureCore(),
13210
+ session = this.createSession();
13211
+ this.sessions.set(companyId, session);
13212
+ return session;
13213
+ }
13214
+ createSession() {
13215
+ const core = new ApertureCore();
13216
+ const session = {
13217
+ core,
12420
13218
  snapshot: null,
12421
13219
  ledger: createEmptyLedger(),
12422
- eventCount: 0
13220
+ eventCount: 0,
13221
+ traces: []
12423
13222
  };
12424
- this.sessions.set(companyId, session);
13223
+ core.onTrace((trace) => {
13224
+ session.traces = [...session.traces.slice(-(MAX_TRACE_HISTORY - 1)), trace];
13225
+ });
12425
13226
  return session;
12426
13227
  }
12427
13228
  };
@@ -12473,6 +13274,37 @@ function emitAttentionUpdate(ctx, event) {
12473
13274
  ctx.streams.open(ATTENTION_UPDATES_STREAM, event.companyId);
12474
13275
  ctx.streams.emit(ATTENTION_UPDATES_STREAM, event);
12475
13276
  }
13277
+ async function trackFocusTelemetry(ctx, eventName, dimensions) {
13278
+ try {
13279
+ await ctx.telemetry.track(eventName, {
13280
+ surface: "focus",
13281
+ ...dimensions ?? {}
13282
+ });
13283
+ } catch (error) {
13284
+ ctx.logger.warn("Failed to emit Focus telemetry", {
13285
+ eventName,
13286
+ error: error instanceof Error ? error.message : String(error)
13287
+ });
13288
+ }
13289
+ }
13290
+ async function logFocusActivity(ctx, entry) {
13291
+ try {
13292
+ await ctx.activity.log({
13293
+ companyId: entry.companyId,
13294
+ message: entry.message,
13295
+ ...entry.entityType ? { entityType: entry.entityType } : {},
13296
+ ...entry.entityId ? { entityId: entry.entityId } : {},
13297
+ ...entry.metadata ? { metadata: entry.metadata } : {}
13298
+ });
13299
+ } catch (error) {
13300
+ ctx.logger.warn("Failed to write Focus activity log entry", {
13301
+ message: entry.message,
13302
+ entityType: entry.entityType,
13303
+ entityId: entry.entityId,
13304
+ error: error instanceof Error ? error.message : String(error)
13305
+ });
13306
+ }
13307
+ }
12476
13308
  async function runAttentionMutation(ctx, store, companyId, mutation) {
12477
13309
  const prior = companyMutationQueue.get(companyId) ?? Promise.resolve();
12478
13310
  let release;
@@ -12561,12 +13393,46 @@ function buildSeenReviewState(review, companyId, taskIds, suppress = false) {
12561
13393
  function snapshotContainsTask(snapshot, taskId) {
12562
13394
  if (!snapshot) return false;
12563
13395
  const frames = [
12564
- ...snapshot.active ? [snapshot.active] : [],
12565
- ...snapshot.queued,
13396
+ ...snapshot.now ? [snapshot.now] : [],
13397
+ ...snapshot.next,
12566
13398
  ...snapshot.ambient
12567
13399
  ];
12568
13400
  return frames.some((frame) => frame.taskId === taskId);
12569
13401
  }
13402
+ function entityTypeFromTaskId(taskId) {
13403
+ const separatorIndex = taskId.indexOf(":");
13404
+ return separatorIndex > 0 ? taskId.slice(0, separatorIndex) : "unknown";
13405
+ }
13406
+ function defaultCounts() {
13407
+ return {
13408
+ now: 0,
13409
+ next: 0,
13410
+ ambient: 0,
13411
+ total: 0
13412
+ };
13413
+ }
13414
+ function laneForTask(snapshot, taskId) {
13415
+ if (!snapshot) return "ui_only";
13416
+ if (snapshot.now?.taskId === taskId) return "now";
13417
+ if (snapshot.next.some((frame) => frame.taskId === taskId)) return "next";
13418
+ if (snapshot.ambient.some((frame) => frame.taskId === taskId)) return "ambient";
13419
+ return "ui_only";
13420
+ }
13421
+ function focusDimensions(snapshot, taskId) {
13422
+ const lane = laneForTask(snapshot, taskId);
13423
+ const entityType = entityTypeFromTaskId(taskId);
13424
+ const frame = lane === "ui_only" ? null : lane === "now" ? snapshot?.now ?? null : lane === "next" ? snapshot?.next.find((candidate) => candidate.taskId === taskId) ?? null : snapshot?.ambient.find((candidate) => candidate.taskId === taskId) ?? null;
13425
+ return {
13426
+ entityType,
13427
+ lane,
13428
+ ...frame?.mode ? { mode: frame.mode } : {},
13429
+ ...frame?.source?.kind ? { sourceKind: frame.source.kind } : {},
13430
+ ...typeof frame?.metadata?.liveReconciled === "boolean" ? { liveReconciled: frame.metadata.liveReconciled } : {}
13431
+ };
13432
+ }
13433
+ function approvalIdFromTaskId(taskId) {
13434
+ return taskId.startsWith("approval:") ? taskId.slice("approval:".length) : null;
13435
+ }
12570
13436
  function registerActionHandlers(ctx, store) {
12571
13437
  ctx.actions.register("acknowledge-frame", async (params) => {
12572
13438
  const companyId = requireCompanyId(params);
@@ -12583,6 +13449,7 @@ function registerActionHandlers(ctx, store) {
12583
13449
  },
12584
13450
  apertureResponse: response
12585
13451
  };
13452
+ const currentSnapshot = store.getSnapshot(companyId);
12586
13453
  const currentReview = await loadReviewState(ctx, companyId);
12587
13454
  const review = buildSeenReviewState(currentReview, companyId, [taskId], true);
12588
13455
  const { snapshot } = await runAttentionMutation(ctx, store, companyId, () => {
@@ -12596,6 +13463,9 @@ function registerActionHandlers(ctx, store) {
12596
13463
  updatedAt: snapshot.updatedAt,
12597
13464
  counts: snapshot.counts
12598
13465
  });
13466
+ await trackFocusTelemetry(ctx, "frame_acknowledged", {
13467
+ ...focusDimensions(currentSnapshot, taskId)
13468
+ });
12599
13469
  return { ok: true, snapshot };
12600
13470
  });
12601
13471
  ctx.actions.register("comment-on-issue", async (params) => {
@@ -12611,6 +13481,7 @@ function registerActionHandlers(ctx, store) {
12611
13481
  throw new Error("Issue comment target does not match the selected frame.");
12612
13482
  }
12613
13483
  const comment = await ctx.issues.createComment(issueId, body, companyId);
13484
+ const currentSnapshot = store.getSnapshot(companyId);
12614
13485
  const currentReview = await loadReviewState(ctx, companyId);
12615
13486
  const review = buildSeenReviewState(currentReview, companyId, [taskId], false);
12616
13487
  await persistReviewState(ctx, companyId, review);
@@ -12619,11 +13490,20 @@ function registerActionHandlers(ctx, store) {
12619
13490
  reason: "action",
12620
13491
  eventType: "plugin.local.comment",
12621
13492
  updatedAt: review.updatedAt,
12622
- counts: store.getSnapshot(companyId)?.counts ?? {
12623
- active: 0,
12624
- queued: 0,
12625
- ambient: 0,
12626
- total: 0
13493
+ counts: store.getSnapshot(companyId)?.counts ?? defaultCounts()
13494
+ });
13495
+ await trackFocusTelemetry(ctx, "issue_comment_submitted", {
13496
+ ...focusDimensions(currentSnapshot, taskId),
13497
+ actionKind: "comment"
13498
+ });
13499
+ await logFocusActivity(ctx, {
13500
+ companyId,
13501
+ message: "Posted an issue comment from Focus.",
13502
+ entityType: "issue",
13503
+ entityId: issueId,
13504
+ metadata: {
13505
+ source: "focus",
13506
+ taskId
12627
13507
  }
12628
13508
  });
12629
13509
  return { ok: true, comment, review };
@@ -12676,6 +13556,21 @@ function registerActionHandlers(ctx, store) {
12676
13556
  updatedAt: snapshot.updatedAt,
12677
13557
  counts: snapshot.counts
12678
13558
  });
13559
+ await trackFocusTelemetry(ctx, "approval_response_recorded", {
13560
+ ...focusDimensions(currentSnapshot, taskId),
13561
+ decision: decision === "request-revision" ? "request_revision" : decision
13562
+ });
13563
+ await logFocusActivity(ctx, {
13564
+ companyId,
13565
+ message: decision === "approve" ? "Approved a Focus approval." : decision === "reject" ? "Rejected a Focus approval." : "Requested revision on a Focus approval.",
13566
+ entityType: "approval",
13567
+ entityId: approvalIdFromTaskId(taskId) ?? taskId,
13568
+ metadata: {
13569
+ source: "focus",
13570
+ decision,
13571
+ taskId
13572
+ }
13573
+ });
12679
13574
  return { ok: true, snapshot, review };
12680
13575
  });
12681
13576
  ctx.actions.register("mark-attention-seen", async (params) => {
@@ -12692,12 +13587,10 @@ function registerActionHandlers(ctx, store) {
12692
13587
  reason: "action",
12693
13588
  eventType: "plugin.local.seen",
12694
13589
  updatedAt: review.updatedAt,
12695
- counts: store.getSnapshot(companyId)?.counts ?? {
12696
- active: 0,
12697
- queued: 0,
12698
- ambient: 0,
12699
- total: 0
12700
- }
13590
+ counts: store.getSnapshot(companyId)?.counts ?? defaultCounts()
13591
+ });
13592
+ await trackFocusTelemetry(ctx, "attention_seen_marked", {
13593
+ frameCount: taskIds.length
12701
13594
  });
12702
13595
  return { ok: true, review };
12703
13596
  });
@@ -12804,14 +13697,14 @@ function frameSortScore(frame, lane) {
12804
13697
  const toneWeight3 = frame.tone === "critical" ? 40 : frame.tone === "focused" ? 25 : 5;
12805
13698
  const consequenceWeight3 = frame.consequence === "high" ? 30 : frame.consequence === "medium" ? 15 : 0;
12806
13699
  const modeWeight = frame.mode === "approval" ? 12 : frame.mode === "choice" ? 8 : 0;
12807
- const laneWeight = lane === "active" ? 20 : lane === "queued" ? 10 : 0;
13700
+ const laneWeight = lane === "now" ? 20 : lane === "next" ? 10 : 0;
12808
13701
  const budgetWeight = isBudgetOverride(frame) ? 10 : 0;
12809
13702
  return toneWeight3 + consequenceWeight3 + modeWeight + laneWeight + budgetWeight + frameSemanticWeight(frame);
12810
13703
  }
12811
13704
  function emptyLaneCounts() {
12812
13705
  return {
12813
- active: 0,
12814
- queued: 0,
13706
+ now: 0,
13707
+ next: 0,
12815
13708
  ambient: 0,
12816
13709
  total: 0
12817
13710
  };
@@ -12837,10 +13730,10 @@ function isFrameUnread(frame, snapshotUpdatedAt, review) {
12837
13730
  }
12838
13731
  function calculateUnreadCounts(snapshot, review) {
12839
13732
  const unread = emptyLaneCounts();
12840
- if (snapshot.active && isFrameUnread(snapshot.active, snapshot.updatedAt, review)) unread.active += 1;
12841
- unread.queued = snapshot.queued.filter((frame) => isFrameUnread(frame, snapshot.updatedAt, review)).length;
13733
+ if (snapshot.now && isFrameUnread(snapshot.now, snapshot.updatedAt, review)) unread.now += 1;
13734
+ unread.next = snapshot.next.filter((frame) => isFrameUnread(frame, snapshot.updatedAt, review)).length;
12842
13735
  unread.ambient = snapshot.ambient.filter((frame) => isFrameUnread(frame, snapshot.updatedAt, review)).length;
12843
- unread.total = unread.active + unread.queued + unread.ambient;
13736
+ unread.total = unread.now + unread.next + unread.ambient;
12844
13737
  return unread;
12845
13738
  }
12846
13739
  function attachReviewState(snapshot, review) {
@@ -12856,33 +13749,33 @@ function mergeStoredFrames(snapshot, companyId, candidates, review, nowIso = (/*
12856
13749
  const base = snapshot ?? {
12857
13750
  companyId,
12858
13751
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
12859
- active: null,
12860
- queued: [],
13752
+ now: null,
13753
+ next: [],
12861
13754
  ambient: [],
12862
13755
  counts: emptyLaneCounts()
12863
13756
  };
12864
13757
  const candidateTaskIds = new Set(candidates.map((candidate) => candidate.frame.taskId));
12865
13758
  const baseEntries = [
12866
- ...base.active ? [{ frame: base.active, lane: "active" }] : [],
12867
- ...base.queued.map((frame) => ({ frame, lane: "queued" })),
13759
+ ...base.now ? [{ frame: base.now, lane: "now" }] : [],
13760
+ ...base.next.map((frame) => ({ frame, lane: "next" })),
12868
13761
  ...base.ambient.map((frame) => ({ frame, lane: "ambient" }))
12869
13762
  ].filter((candidate) => !candidateTaskIds.has(candidate.frame.taskId));
12870
13763
  const filtered = [...baseEntries, ...candidates].filter((candidate) => !isFrameSuppressed(candidate.frame, base.updatedAt, review));
12871
13764
  const actionable = filtered.filter((candidate) => candidate.lane !== "ambient").sort((left, right) => compareCandidates(left, right, base.updatedAt));
12872
13765
  const ambient = filtered.filter((candidate) => candidate.lane === "ambient").filter((candidate) => !isAmbientExpired(candidate.frame, base.updatedAt, nowIso)).sort((left, right) => compareCandidates(left, right, base.updatedAt));
12873
- const active = actionable.shift()?.frame ?? null;
12874
- const queued = actionable.map((candidate) => candidate.frame);
13766
+ const now = actionable.shift()?.frame ?? null;
13767
+ const next = actionable.map((candidate) => candidate.frame);
12875
13768
  const ambientFrames = ambient.map((candidate) => candidate.frame);
12876
13769
  return attachReviewState({
12877
13770
  ...base,
12878
- active,
12879
- queued,
13771
+ now,
13772
+ next,
12880
13773
  ambient: ambientFrames,
12881
13774
  counts: {
12882
- active: active ? 1 : 0,
12883
- queued: queued.length,
13775
+ now: now ? 1 : 0,
13776
+ next: next.length,
12884
13777
  ambient: ambientFrames.length,
12885
- total: (active ? 1 : 0) + queued.length + ambientFrames.length
13778
+ total: (now ? 1 : 0) + next.length + ambientFrames.length
12886
13779
  }
12887
13780
  }, review);
12888
13781
  }
@@ -13242,8 +14135,8 @@ function issueLane(issue, comment, evidence) {
13242
14135
  if ((issue.status === "blocked" || issue.status === "in_review") && (hasIntent(evidence.analysis, "resolution") || evidence.documentSignal.resolvesArtifactRequest)) {
13243
14136
  return comment || issue.isUnreadForMe || evidence.documentSignal.hasDocuments ? "ambient" : null;
13244
14137
  }
13245
- if (issue.status === "blocked") return issue.priority === "critical" ? "active" : "queued";
13246
- if (issue.status === "in_review") return "queued";
14138
+ if (issue.status === "blocked") return issue.priority === "critical" ? "now" : "next";
14139
+ if (issue.status === "in_review") return "next";
13247
14140
  if (comment || issue.isUnreadForMe) return "ambient";
13248
14141
  return null;
13249
14142
  }
@@ -13318,9 +14211,9 @@ function issueFrame(issue, comment, documents, directory) {
13318
14211
  };
13319
14212
  }
13320
14213
  function agentLane(agent) {
13321
- if (agent.status === "error") return "active";
13322
- if (agent.status === "pending_approval") return "queued";
13323
- if (agent.status === "paused" && agent.pauseReason === "budget") return "queued";
14214
+ if (agent.status === "error") return "now";
14215
+ if (agent.status === "pending_approval") return "next";
14216
+ if (agent.status === "paused" && agent.pauseReason === "budget") return "next";
13324
14217
  if (agent.status === "paused") return "ambient";
13325
14218
  return null;
13326
14219
  }
@@ -13462,11 +14355,6 @@ async function reconcileAttentionSnapshot(ctx, companyId, snapshot, review, conf
13462
14355
  }
13463
14356
 
13464
14357
  // src/handlers/data.ts
13465
- function isAttentionSnapshot(value, companyId) {
13466
- if (!value || typeof value !== "object") return false;
13467
- const snapshot = value;
13468
- return snapshot.companyId === companyId && typeof snapshot.updatedAt === "string" && !!snapshot.counts && typeof snapshot.counts.active === "number" && typeof snapshot.counts.queued === "number" && typeof snapshot.counts.ambient === "number" && typeof snapshot.counts.total === "number" && Array.isArray(snapshot.queued) && Array.isArray(snapshot.ambient);
13469
- }
13470
14358
  function isLedgerSource(value) {
13471
14359
  if (!value || typeof value !== "object") return false;
13472
14360
  const source = value;
@@ -13544,6 +14432,7 @@ async function loadAttentionState(ctx, store, companyId) {
13544
14432
  stateKey: ATTENTION_REVIEW_STATE_KEY
13545
14433
  });
13546
14434
  const baseLedger = inMemoryLedger.length > 0 ? inMemoryLedger : isAttentionLedger(persistedLedger) ? persistedLedger : createEmptyLedger();
14435
+ const normalizedPersistedSnapshot = normalizeAttentionSnapshot(companyId, persistedSnapshot);
13547
14436
  const snapshot = store.rebuildFromLedger(companyId, baseLedger);
13548
14437
  const reviewState = deriveReviewStateFromLedger(
13549
14438
  companyId,
@@ -13552,7 +14441,7 @@ async function loadAttentionState(ctx, store, companyId) {
13552
14441
  );
13553
14442
  return {
13554
14443
  persistedLedger,
13555
- persistedSnapshot,
14444
+ persistedSnapshot: normalizedPersistedSnapshot,
13556
14445
  persistedReview,
13557
14446
  baseLedger,
13558
14447
  snapshot,
@@ -13583,12 +14472,12 @@ function registerDataHandlers(ctx, store) {
13583
14472
  } = await loadAttentionState(ctx, store, companyId);
13584
14473
  const reconciledSnapshot = await loadReconciledAttentionSnapshot(ctx, companyId, snapshot, reviewState);
13585
14474
  const shouldPersistLedger = !isAttentionLedger(persistedLedger) || !sameJson(persistedLedger, baseLedger);
13586
- const shouldPersistSnapshot = !isAttentionSnapshot(persistedSnapshot, companyId) || !sameJson(persistedSnapshot, snapshot);
14475
+ const shouldPersistSnapshot = !persistedSnapshot || !sameJson(persistedSnapshot, snapshot);
13587
14476
  const shouldPersistReview = !isAttentionReviewState(persistedReview, companyId) || !sameJson(persistedReview, reviewState);
13588
14477
  if (shouldPersistLedger) await persistLedger(ctx, companyId, baseLedger);
13589
14478
  if (shouldPersistSnapshot) await persistSnapshot(ctx, companyId, snapshot);
13590
14479
  if (shouldPersistReview) await persistReviewState(ctx, companyId, reviewState);
13591
- if (!isAttentionLedger(persistedLedger) && isAttentionSnapshot(persistedSnapshot, companyId)) {
14480
+ if (!isAttentionLedger(persistedLedger) && persistedSnapshot) {
13592
14481
  ctx.logger.warn("Legacy snapshot found without replay ledger; rebuilt state may be partial until new events arrive.", {
13593
14482
  companyId
13594
14483
  });
@@ -13607,12 +14496,12 @@ function registerDataHandlers(ctx, store) {
13607
14496
  } = await loadAttentionState(ctx, store, companyId);
13608
14497
  const reconciledSnapshot = await loadReconciledAttentionSnapshot(ctx, companyId, snapshot, reviewState);
13609
14498
  const shouldPersistLedger = !isAttentionLedger(persistedLedger) || !sameJson(persistedLedger, baseLedger);
13610
- const shouldPersistSnapshot = !isAttentionSnapshot(persistedSnapshot, companyId) || !sameJson(persistedSnapshot, snapshot);
14499
+ const shouldPersistSnapshot = !persistedSnapshot || !sameJson(persistedSnapshot, snapshot);
13611
14500
  const shouldPersistReview = !isAttentionReviewState(persistedReview, companyId) || !sameJson(persistedReview, reviewState);
13612
14501
  if (shouldPersistLedger) await persistLedger(ctx, companyId, baseLedger);
13613
14502
  if (shouldPersistSnapshot) await persistSnapshot(ctx, companyId, snapshot);
13614
14503
  if (shouldPersistReview) await persistReviewState(ctx, companyId, reviewState);
13615
- if (!isAttentionLedger(persistedLedger) && isAttentionSnapshot(persistedSnapshot, companyId)) {
14504
+ if (!isAttentionLedger(persistedLedger) && persistedSnapshot) {
13616
14505
  ctx.logger.warn("Legacy snapshot found without replay ledger; rebuilt state may be partial until new events arrive.", {
13617
14506
  companyId
13618
14507
  });
@@ -13637,11 +14526,17 @@ function registerDataHandlers(ctx, store) {
13637
14526
  ledger: baseLedger,
13638
14527
  eventEntries: baseLedger.filter((entry) => entry.kind === "event"),
13639
14528
  responseEntries: baseLedger.filter((entry) => entry.kind === "response"),
14529
+ traces: store.getTraces(companyId),
13640
14530
  snapshot,
13641
14531
  reconciledSnapshot,
13642
14532
  review: reviewState
13643
14533
  };
13644
14534
  });
14535
+ ctx.data.register("attention-traces", async (params) => {
14536
+ const companyId = requireCompanyId(params);
14537
+ await loadAttentionState(ctx, store, companyId);
14538
+ return store.getTraces(companyId);
14539
+ });
13645
14540
  ctx.data.register("attention-replay-scenario", async (params) => {
13646
14541
  const companyId = requireCompanyId(params);
13647
14542
  const { baseLedger, snapshot } = await loadAttentionState(ctx, store, companyId);
@@ -13651,12 +14546,12 @@ function registerDataHandlers(ctx, store) {
13651
14546
  description: "Replay scenario exported from the Paperclip Aperture plugin ledger.",
13652
14547
  doctrineTags: ["paperclip", "aperture", "replay-export"],
13653
14548
  expectations: {
13654
- finalActiveInteractionId: snapshot.active?.interactionId ?? null,
13655
- queuedInteractionIds: snapshot.queued.map((frame) => frame.interactionId),
14549
+ finalNowInteractionId: snapshot.now?.interactionId ?? null,
14550
+ nextInteractionIds: snapshot.next.map((frame) => frame.interactionId),
13656
14551
  ambientInteractionIds: snapshot.ambient.map((frame) => frame.interactionId),
13657
- resultBucketCounts: {
13658
- active: snapshot.counts.active,
13659
- queued: snapshot.counts.queued,
14552
+ resultLaneCounts: {
14553
+ now: snapshot.counts.now,
14554
+ next: snapshot.counts.next,
13660
14555
  ambient: snapshot.counts.ambient
13661
14556
  }
13662
14557
  },
@@ -13682,7 +14577,7 @@ function registerDataHandlers(ctx, store) {
13682
14577
  });
13683
14578
  }
13684
14579
 
13685
- // node_modules/.pnpm/@tomismeta+aperture-core@0.4.2/node_modules/@tomismeta/aperture-core/public-dist/semantic.js
14580
+ // node_modules/.pnpm/@tomismeta+aperture-core@0.5.0/node_modules/@tomismeta/aperture-core/public-dist/semantic.js
13686
14581
  function normalizeSemanticText2(value) {
13687
14582
  return value.toLowerCase().replace(/[^a-z0-9/.-]+/g, " ").trim();
13688
14583
  }
@@ -14108,12 +15003,12 @@ function inferSemanticInterpretation2(event) {
14108
15003
  relationHints: [],
14109
15004
  confidence: "high",
14110
15005
  reasons: semanticReasonsForLifecycle2("task_started"),
14111
- provenance: {
14112
- intentFrame: "inferred",
14113
- activityClass: "inferred",
14114
- consequence: "inferred",
14115
- confidence: "inferred"
14116
- }
15006
+ provenance: inferredSemanticProvenance2([
15007
+ "intentFrame",
15008
+ "activityClass",
15009
+ "consequence",
15010
+ "confidence"
15011
+ ])
14117
15012
  };
14118
15013
  case "task.updated":
14119
15014
  return inferTaskUpdateSemantics2(event);
@@ -14128,12 +15023,12 @@ function inferSemanticInterpretation2(event) {
14128
15023
  relationHints: [],
14129
15024
  confidence: "high",
14130
15025
  reasons: semanticReasonsForLifecycle2("completion"),
14131
- provenance: {
14132
- intentFrame: "inferred",
14133
- activityClass: "inferred",
14134
- consequence: "inferred",
14135
- confidence: "inferred"
14136
- }
15026
+ provenance: inferredSemanticProvenance2([
15027
+ "intentFrame",
15028
+ "activityClass",
15029
+ "consequence",
15030
+ "confidence"
15031
+ ])
14137
15032
  };
14138
15033
  case "task.cancelled":
14139
15034
  return {
@@ -14146,11 +15041,13 @@ function inferSemanticInterpretation2(event) {
14146
15041
  confidence: "high",
14147
15042
  reasons: semanticReasonsForTaskStatus2("completed", { wasCancelled: true }),
14148
15043
  provenance: {
14149
- intentFrame: "inferred",
14150
- activityClass: "inferred",
14151
- consequence: "inferred",
14152
- ...event.reason ? { whyNow: "inferred" } : {},
14153
- confidence: "inferred"
15044
+ ...inferredSemanticProvenance2([
15045
+ "intentFrame",
15046
+ "activityClass",
15047
+ "consequence",
15048
+ "confidence"
15049
+ ]),
15050
+ ...event.reason ? inferredSemanticProvenance2(["whyNow"]) : {}
14154
15051
  }
14155
15052
  };
14156
15053
  }
@@ -14161,7 +15058,7 @@ function inferTaskUpdateSemantics2(event) {
14161
15058
  const relationHints = detectSemanticRelationHints2(text);
14162
15059
  const taxonomyInput = buildTaxonomyInput2(event.title, event.summary, event.toolFamily);
14163
15060
  const { toolFamily, source: toolFamilySource } = resolveSemanticToolFamily2(taxonomyInput, true);
14164
- const relationProvenance = relationHints.length > 0 ? { relationHints: "inferred" } : {};
15061
+ const relationProvenance = relationHints.length > 0 ? inferredSemanticProvenance2(["relationHints"]) : {};
14165
15062
  const observationalFailure = event.status === "failed" && detectObservationalFailureStatus2(text, toolFamily);
14166
15063
  const routineObservationalFailureLowConsequence = event.status === "failed" && detectRoutineObservationalFailureLowConsequence2(text, toolFamily);
14167
15064
  const expectedDiagnosticFailure = event.status === "failed" && detectExpectedDiagnosticFailure2(text, toolFamily);
@@ -14184,12 +15081,14 @@ function inferTaskUpdateSemantics2(event) {
14184
15081
  "task status indicates failure but the update reads like observational output"
14185
15082
  ],
14186
15083
  provenance: {
14187
- intentFrame: "inferred",
14188
- activityClass: "inferred",
14189
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
14190
- consequence: "inferred",
14191
- ...relationProvenance,
14192
- confidence: "inferred"
15084
+ ...inferredSemanticProvenance2([
15085
+ "intentFrame",
15086
+ "activityClass",
15087
+ "consequence",
15088
+ "confidence"
15089
+ ]),
15090
+ ...semanticToolFamilyProvenance2(toolFamilySource),
15091
+ ...relationProvenance
14193
15092
  }
14194
15093
  };
14195
15094
  }
@@ -14211,13 +15110,15 @@ function inferTaskUpdateSemantics2(event) {
14211
15110
  "failure content looks like expected diagnostic output from repro work"
14212
15111
  ] : semanticReasonsForTaskStatus2("failed", { impliedAsk }),
14213
15112
  provenance: {
14214
- intentFrame: "inferred",
14215
- activityClass: "inferred",
14216
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
14217
- consequence: "inferred",
14218
- whyNow: "inferred",
14219
- ...relationProvenance,
14220
- confidence: "inferred"
15113
+ ...inferredSemanticProvenance2([
15114
+ "intentFrame",
15115
+ "activityClass",
15116
+ "consequence",
15117
+ "whyNow",
15118
+ "confidence"
15119
+ ]),
15120
+ ...semanticToolFamilyProvenance2(toolFamilySource),
15121
+ ...relationProvenance
14221
15122
  }
14222
15123
  };
14223
15124
  case "blocked":
@@ -14232,13 +15133,15 @@ function inferTaskUpdateSemantics2(event) {
14232
15133
  confidence: impliedAsk ? "medium" : "high",
14233
15134
  reasons: semanticReasonsForTaskStatus2("blocked", { impliedAsk }),
14234
15135
  provenance: {
14235
- intentFrame: "inferred",
14236
- activityClass: "inferred",
14237
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
14238
- consequence: "inferred",
14239
- whyNow: "inferred",
14240
- ...relationProvenance,
14241
- confidence: "inferred"
15136
+ ...inferredSemanticProvenance2([
15137
+ "intentFrame",
15138
+ "activityClass",
15139
+ "consequence",
15140
+ "whyNow",
15141
+ "confidence"
15142
+ ]),
15143
+ ...semanticToolFamilyProvenance2(toolFamilySource),
15144
+ ...relationProvenance
14242
15145
  }
14243
15146
  };
14244
15147
  case "running":
@@ -14258,13 +15161,15 @@ function inferTaskUpdateSemantics2(event) {
14258
15161
  confidence: impliedAsk ? "low" : "high",
14259
15162
  reasons: semanticReasonsForTaskStatus2(event.status, { impliedAsk }),
14260
15163
  provenance: {
14261
- intentFrame: "inferred",
14262
- activityClass: "inferred",
14263
- ...toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {},
14264
- consequence: "inferred",
14265
- ...impliedAsk ? { whyNow: "inferred" } : {},
14266
- ...relationProvenance,
14267
- confidence: "inferred"
15164
+ ...inferredSemanticProvenance2([
15165
+ "intentFrame",
15166
+ "activityClass",
15167
+ "consequence",
15168
+ "confidence"
15169
+ ]),
15170
+ ...semanticToolFamilyProvenance2(toolFamilySource),
15171
+ ...impliedAsk ? inferredSemanticProvenance2(["whyNow"]) : {},
15172
+ ...relationProvenance
14268
15173
  }
14269
15174
  };
14270
15175
  }
@@ -14279,8 +15184,7 @@ function inferHumanInputSemantics2(event) {
14279
15184
  const relationHints = detectSemanticRelationHints2(text);
14280
15185
  const baseConsequence = event.riskHint ?? consequenceFromRequestKind2(event.request.kind, toolFamily);
14281
15186
  const consequence = inferConsequenceFromSemanticText2(text, baseConsequence, toolFamily);
14282
- const relationProvenance = relationHints.length > 0 ? { relationHints: "inferred" } : {};
14283
- const toolFamilyProvenance = toolFamilySource === "explicit" ? { toolFamily: "source" } : toolFamilySource === "inferred" ? { toolFamily: "inferred" } : {};
15187
+ const relationProvenance = relationHints.length > 0 ? inferredSemanticProvenance2(["relationHints"]) : {};
14284
15188
  return {
14285
15189
  intentFrame: semanticIntentFrameForRequestKind2(event.request.kind),
14286
15190
  activityClass: semanticActivityClassForRequestKind2(event.request.kind),
@@ -14295,16 +15199,32 @@ function inferHumanInputSemantics2(event) {
14295
15199
  ...toolFamilySource === "explicit" ? ["tool family was supplied by the source or context"] : toolFamilySource === "inferred" ? ["tool family was inferred from approval wording"] : []
14296
15200
  ],
14297
15201
  provenance: {
14298
- intentFrame: "inferred",
14299
- activityClass: "inferred",
14300
- ...toolFamilyProvenance,
14301
- consequence: event.riskHint ? "source" : "inferred",
14302
- whyNow: "inferred",
14303
- ...relationProvenance,
14304
- confidence: event.riskHint ? "source" : "inferred"
15202
+ ...inferredSemanticProvenance2(["intentFrame", "activityClass", "whyNow"]),
15203
+ ...semanticToolFamilyProvenance2(toolFamilySource),
15204
+ ...event.riskHint ? sourceSemanticProvenance2(["consequence", "confidence"]) : inferredSemanticProvenance2(["consequence", "confidence"]),
15205
+ ...relationProvenance
14305
15206
  }
14306
15207
  };
14307
15208
  }
15209
+ function inferredSemanticProvenance2(fields) {
15210
+ return semanticFieldProvenance2(fields, "inferred");
15211
+ }
15212
+ function sourceSemanticProvenance2(fields) {
15213
+ return semanticFieldProvenance2(fields, "source");
15214
+ }
15215
+ function semanticFieldProvenance2(fields, kind) {
15216
+ return Object.fromEntries(fields.map((field) => [field, kind]));
15217
+ }
15218
+ function semanticToolFamilyProvenance2(source) {
15219
+ switch (source) {
15220
+ case "explicit":
15221
+ return sourceSemanticProvenance2(["toolFamily"]);
15222
+ case "inferred":
15223
+ return inferredSemanticProvenance2(["toolFamily"]);
15224
+ default:
15225
+ return {};
15226
+ }
15227
+ }
14308
15228
  function resolveSemanticToolFamily2(input, allowTextInference) {
14309
15229
  const explicit = readExplicitSemanticToolFamily2(input);
14310
15230
  if (explicit) {
@@ -14847,6 +15767,7 @@ function mapPluginEventToAperture(event) {
14847
15767
 
14848
15768
  // src/handlers/events.ts
14849
15769
  var SUBSCRIBED_EVENTS = [
15770
+ "activity.logged",
14850
15771
  "approval.created",
14851
15772
  "approval.decided",
14852
15773
  "approval.approved",
@@ -14862,6 +15783,11 @@ var SUBSCRIBED_EVENTS = [
14862
15783
  "agent.run.cancelled",
14863
15784
  "agent.status_changed"
14864
15785
  ];
15786
+ var ATTENTION_ACTIVITY_ACTIONS = /* @__PURE__ */ new Set([
15787
+ "issue.document_created",
15788
+ "issue.document_updated",
15789
+ "issue.document_deleted"
15790
+ ]);
14865
15791
  function shouldCaptureEvent(config, eventType) {
14866
15792
  if ((eventType === "issue.created" || eventType === "issue.updated" || eventType === "issue.comment.created" || eventType === "issue.comment_added") && config.captureIssueLifecycle === false) {
14867
15793
  return false;
@@ -14900,6 +15826,32 @@ async function enrichIssuePayload(ctx, event) {
14900
15826
  async function handleEvent(ctx, store, event) {
14901
15827
  const config = await ctx.config.get();
14902
15828
  if (!shouldCaptureEvent(config, event.eventType)) return;
15829
+ if (event.eventType === "activity.logged") {
15830
+ const payload = event.payload && typeof event.payload === "object" ? event.payload : {};
15831
+ const action = typeof payload.action === "string" ? payload.action : void 0;
15832
+ const entityType = typeof payload.entityType === "string" ? payload.entityType : event.entityType;
15833
+ if (entityType === "issue" && action && ATTENTION_ACTIVITY_ACTIONS.has(action)) {
15834
+ emitAttentionUpdate(ctx, {
15835
+ companyId: event.companyId,
15836
+ reason: "event",
15837
+ eventType: `activity.${action}`,
15838
+ updatedAt: event.occurredAt,
15839
+ counts: store.getSnapshot(event.companyId)?.counts ?? {
15840
+ now: 0,
15841
+ next: 0,
15842
+ ambient: 0,
15843
+ total: 0
15844
+ }
15845
+ });
15846
+ ctx.logger.info("Triggered Focus refresh from activity log event", {
15847
+ companyId: event.companyId,
15848
+ action,
15849
+ entityId: event.entityId,
15850
+ entityType
15851
+ });
15852
+ }
15853
+ return;
15854
+ }
14903
15855
  const enriched = await enrichIssuePayload(ctx, event);
14904
15856
  const mapped = mapPluginEventToAperture(enriched);
14905
15857
  if (!mapped) return;