@adhdev/mesh-shared 1.0.82-rc.11 → 1.0.82-rc.13

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.
@@ -15,12 +15,17 @@
15
15
  * belongs in `CANONICAL_MESH_TOOL_NAMES`, and the coordinator/worker MCP modes
16
16
  * never publish them.
17
17
  */
18
- export declare const ASSISTANT_TOOLS: readonly ["projects", "project_status", "project_send", "project_read", "project_add", "discover_repos", "memory", "skill_view", "skill_manage", "project_note"];
18
+ export declare const ASSISTANT_TOOLS: readonly ["projects", "environment", "assistant_action", "project_watch", "project_status", "project_send", "project_read", "project_add", "discover_repos", "memory", "skill_view", "skill_manage", "project_note"];
19
19
  export type AssistantTool = typeof ASSISTANT_TOOLS[number];
20
20
  export declare function isAssistantTool(value: unknown): value is AssistantTool;
21
21
  /** Daemon verb names (§4.4 table + the five verbs below it). */
22
22
  export declare const ASSISTANT_VERB: {
23
23
  readonly projects: "assistant_projects";
24
+ readonly environment: "assistant_environment";
25
+ readonly action: "assistant_action";
26
+ readonly watch: "assistant_project_watch";
27
+ readonly executionState: "assistant_execution_state";
28
+ readonly executionSettings: "assistant_execution_settings";
24
29
  readonly projectStatus: "assistant_project_status";
25
30
  readonly projectSend: "assistant_project_send";
26
31
  readonly projectRead: "assistant_project_read";
package/dist/index.d.ts CHANGED
@@ -41,3 +41,5 @@ export * from './turn-ipc';
41
41
  export * from './path-ownership';
42
42
  export * from './mission-brief';
43
43
  export * from './keyed-doc-delta';
44
+ export * from './provider-approval';
45
+ export * from './provider-question';
package/dist/index.js CHANGED
@@ -144,6 +144,7 @@ __export(index_exports, {
144
144
  WORKER_BRANCH_STATES: () => WORKER_BRANCH_STATES,
145
145
  WORKER_PROTOCOL_FOOTER_MARKER: () => WORKER_PROTOCOL_FOOTER_MARKER,
146
146
  WORKER_REPORT_OUTCOMES: () => WORKER_REPORT_OUTCOMES,
147
+ WORKER_REPORT_SUMMARY_MAX_CHARS: () => WORKER_REPORT_SUMMARY_MAX_CHARS,
147
148
  WORKER_TOOLS: () => WORKER_TOOLS,
148
149
  appendWorkerProtocolFooter: () => appendWorkerProtocolFooter,
149
150
  argsCarryStatusProbeMarker: () => argsCarryStatusProbeMarker,
@@ -228,6 +229,7 @@ __export(index_exports, {
228
229
  hasGitStatusEvidence: () => hasGitStatusEvidence,
229
230
  hasWorkerProtocolFooter: () => hasWorkerProtocolFooter,
230
231
  interpolateString: () => interpolateString,
232
+ isActionableProviderApproval: () => isActionableProviderApproval,
231
233
  isAssistantTool: () => isAssistantTool,
232
234
  isBlockedStatus: () => isBlockedStatus,
233
235
  isBusyStatus: () => isBusyStatus,
@@ -263,12 +265,14 @@ __export(index_exports, {
263
265
  isMessageId: () => isMessageId,
264
266
  isMissionUpsertResponse: () => isMissionUpsertResponse,
265
267
  isModelAxisSource: () => isModelAxisSource,
268
+ isNativeMarkerRef: () => isNativeMarkerRef,
266
269
  isNonEmptyString: () => isNonEmptyString,
267
270
  isNotifyKind: () => isNotifyKind,
268
271
  isOutboundMessage: () => isOutboundMessage,
269
272
  isOutboundMessageOrigin: () => isOutboundMessageOrigin,
270
273
  isP2PSignalType: () => isP2PSignalType,
271
274
  isPhantomDaemonEntry: () => isPhantomDaemonEntry,
275
+ isProviderQuestionBinding: () => isProviderQuestionBinding,
272
276
  isRawDaemonDoId: () => isRawDaemonDoId,
273
277
  isReadyStatus: () => isReadyStatus,
274
278
  isRecord: () => isRecord,
@@ -329,11 +333,13 @@ __export(index_exports, {
329
333
  pickBestTransitGitStatus: () => pickBestTransitGitStatus,
330
334
  projectFileDiffRow: () => projectFileDiffRow,
331
335
  projectTurnEvidenceEntry: () => projectTurnEvidenceEntry,
336
+ providerApprovalSnapshot: () => providerApprovalSnapshot,
332
337
  readBoolean: () => readBoolean,
333
338
  readEnvelopeFields: () => readEnvelopeFields,
334
339
  readGitSubmodules: () => readGitSubmodules,
335
340
  readNumber: () => readNumber,
336
341
  readOptionalRecord: () => readOptionalRecord,
342
+ readProviderDecision: () => readProviderDecision,
337
343
  readRecord: () => readRecord,
338
344
  readString: () => readString,
339
345
  readStringArray: () => readStringArray,
@@ -667,7 +673,7 @@ function hasUsableWindow(window) {
667
673
  return !!window && typeof window.usedPercent === "number" && Number.isFinite(window.usedPercent);
668
674
  }
669
675
  function hasReading(quota) {
670
- if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly)) return true;
676
+ if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly) || hasUsableWindow(quota.monthly)) return true;
671
677
  return Array.isArray(quota.buckets) && quota.buckets.some((b) => !!b && typeof b.usedPercent === "number" && Number.isFinite(b.usedPercent));
672
678
  }
673
679
  function finiteMs(value) {
@@ -1798,6 +1804,7 @@ var MESH_THINKING_LEVELS = ["low", "medium", "high"];
1798
1804
  var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
1799
1805
  var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
1800
1806
  var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
1807
+ var WORKER_REPORT_SUMMARY_MAX_CHARS = 8e3;
1801
1808
  var WORKER_BRANCH_STATES = [
1802
1809
  "merged_to_main",
1803
1810
  "pushed_feature_branch_needs_merge",
@@ -2065,6 +2072,9 @@ function renderCoordinatorWorkerSection() {
2065
2072
  // src/assistant-protocol.ts
2066
2073
  var ASSISTANT_TOOLS = [
2067
2074
  "projects",
2075
+ "environment",
2076
+ "assistant_action",
2077
+ "project_watch",
2068
2078
  "project_status",
2069
2079
  "project_send",
2070
2080
  "project_read",
@@ -2082,6 +2092,11 @@ function isAssistantTool(value) {
2082
2092
  var ASSISTANT_VERB = {
2083
2093
  // tool verbs
2084
2094
  projects: "assistant_projects",
2095
+ environment: "assistant_environment",
2096
+ action: "assistant_action",
2097
+ watch: "assistant_project_watch",
2098
+ executionState: "assistant_execution_state",
2099
+ executionSettings: "assistant_execution_settings",
2085
2100
  projectStatus: "assistant_project_status",
2086
2101
  projectSend: "assistant_project_send",
2087
2102
  projectRead: "assistant_project_read",
@@ -2101,6 +2116,9 @@ var ASSISTANT_VERB = {
2101
2116
  };
2102
2117
  var ASSISTANT_TOOL_VERBS = {
2103
2118
  projects: ASSISTANT_VERB.projects,
2119
+ environment: ASSISTANT_VERB.environment,
2120
+ assistant_action: ASSISTANT_VERB.action,
2121
+ project_watch: ASSISTANT_VERB.watch,
2104
2122
  project_status: ASSISTANT_VERB.projectStatus,
2105
2123
  project_send: ASSISTANT_VERB.projectSend,
2106
2124
  project_read: ASSISTANT_VERB.projectRead,
@@ -2111,8 +2129,9 @@ var ASSISTANT_TOOL_VERBS = {
2111
2129
  skill_manage: ASSISTANT_VERB.skillManage,
2112
2130
  project_note: ASSISTANT_VERB.projectNote
2113
2131
  };
2114
- var ASSISTANT_WRITE_TOOLS = ["memory", "skill_manage", "project_note", "project_send", "project_add"];
2132
+ var ASSISTANT_WRITE_TOOLS = ["project_watch", "assistant_action", "memory", "skill_manage", "project_note", "project_send", "project_add"];
2115
2133
  var ASSISTANT_OWNER_VERBS = [
2134
+ ASSISTANT_VERB.executionSettings,
2116
2135
  ASSISTANT_VERB.stagedResolve,
2117
2136
  ASSISTANT_VERB.storeAdmin,
2118
2137
  ASSISTANT_VERB.importSkills
@@ -2170,8 +2189,8 @@ function sanitizeRefusalCode(value) {
2170
2189
  var CONSUME_PROFILES = ["default", "native_source"];
2171
2190
  var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
2172
2191
  var SUSPENSION_MODALS = ["approval", "choice"];
2173
- var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
2174
- var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer"];
2192
+ var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered", "dismissed"];
2193
+ var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer", "modal_disappeared"];
2175
2194
  var TURN_END_STRENGTHS = ["genuine", "weak"];
2176
2195
  var TURN_END_BLOCK_REASONS = [
2177
2196
  "missing_final_assistant",
@@ -2179,9 +2198,9 @@ var TURN_END_BLOCK_REASONS = [
2179
2198
  "terminal_block_hard_cap",
2180
2199
  "decoupled_completion"
2181
2200
  ];
2182
- var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
2201
+ var NATIVE_TURN_OUTCOMES = ["completed", "aborted", "failed"];
2183
2202
  var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
2184
- var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
2203
+ var PROVIDER_FAILURES = ["auth_failed", "billing_failed", "usage_limit_exceeded", "server_overloaded", "provider_error"];
2185
2204
  var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
2186
2205
  var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
2187
2206
  var OPERATOR_STATUSES = ["completed", "failed"];
@@ -2208,7 +2227,8 @@ var HOLD_REASONS = [
2208
2227
  // — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
2209
2228
  // a session whose FSM never shows the idle edge again does not wait for
2210
2229
  // liveness / hard_ceiling.
2211
- "await_end"
2230
+ "await_end",
2231
+ "report_correction"
2212
2232
  ];
2213
2233
  var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
2214
2234
  var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
@@ -2219,9 +2239,15 @@ var TURN_REASONS = [
2219
2239
  "transcript_final",
2220
2240
  "worker_reported",
2221
2241
  "finalization_timeout_no_response",
2242
+ "weak_end_liveness_unconfirmed",
2243
+ "weak_end_probe_unobserved",
2244
+ "report_correction_expired",
2222
2245
  "session_error",
2223
2246
  "provider_auth_failed",
2224
2247
  "provider_billing_failed",
2248
+ "provider_usage_limit_exceeded",
2249
+ "provider_server_overloaded",
2250
+ "provider_error",
2225
2251
  "operator_cancel",
2226
2252
  "intentional_cleanup",
2227
2253
  "task_removed",
@@ -2298,8 +2324,8 @@ var TURN_EVIDENCE_FIELD_SPECS = {
2298
2324
  duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
2299
2325
  session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
2300
2326
  turn_started: { retro: bool },
2301
- suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
2302
- suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
2327
+ suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt, providerSetup: boolOpt, clockUnknown: boolOpt },
2328
+ suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS), modalKey: idOpt },
2303
2329
  turn_end: {
2304
2330
  strength: en(TURN_END_STRENGTHS),
2305
2331
  afterFinalizationTimeout: boolOpt,
@@ -2309,6 +2335,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
2309
2335
  releasedByHardCap: boolOpt,
2310
2336
  nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
2311
2337
  live: { t: "live", optional: true },
2338
+ nativeMarker: { t: "native_marker", optional: true },
2312
2339
  reportExpected: boolOpt,
2313
2340
  providerFailure: enOpt(PROVIDER_FAILURES)
2314
2341
  },
@@ -2322,7 +2349,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
2322
2349
  },
2323
2350
  transcript_activity: { newestActivityAt: ms },
2324
2351
  no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
2325
- liveness: { result: en(LIVENESS_RESULTS) },
2352
+ liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
2326
2353
  process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
2327
2354
  session_error: { reason: en(SESSION_ERROR_REASONS) },
2328
2355
  worker_report: {
@@ -2332,6 +2359,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
2332
2359
  branchState: enOpt(WORKER_BRANCH_STATES),
2333
2360
  touchedFileCount: intOpt
2334
2361
  },
2362
+ worker_report_correction_requested: { deliveryId: { t: "id", optional: true } },
2335
2363
  worker_progress: { note: { t: "summary_ref", optional: true } },
2336
2364
  git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
2337
2365
  cancel: { reason: en(CANCEL_REASONS) },
@@ -2379,7 +2407,7 @@ function isLiveTurnPending(value) {
2379
2407
  return isRecord2(value) && hasOnlyKeys(value, ["modal", "adapterPending", "trailingTool", "newestActivityAt"]) && typeof value.modal === "boolean" && typeof value.adapterPending === "boolean" && typeof value.trailingTool === "boolean" && (value.newestActivityAt === void 0 || isFiniteNumber2(value.newestActivityAt));
2380
2408
  }
2381
2409
  function isNativeMarkerRef(value) {
2382
- return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId));
2410
+ return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId", "receivedAt", "startedAt", "errorAt"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId)) && ["receivedAt", "startedAt", "errorAt"].every((key) => value[key] === void 0 || isFiniteNumber2(value[key]));
2383
2411
  }
2384
2412
  function isCoordinatorIdentity(value) {
2385
2413
  return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
@@ -3796,6 +3824,76 @@ function stableMeshNodeRow(row) {
3796
3824
  }
3797
3825
  return out;
3798
3826
  }
3827
+
3828
+ // src/provider-approval.ts
3829
+ function isActionableProviderApproval(approval) {
3830
+ return !!approval && approval.source === "provider_modal" && approval.type === "tool_permission" && approval.lifecycle === "pending" && approval.evidence === "live" && approval.actionable && !!approval.modalKey && Array.isArray(approval.buttons) && approval.buttons.some((button) => typeof button === "string" && !!button.trim());
3831
+ }
3832
+ function readProviderDecision(approval, waiting, hasModal = false) {
3833
+ if (approval !== void 0) return approval && ["provider_modal", "legacy_provider", "status_only", "ledger_approval"].includes(approval.source) ? approval : null;
3834
+ if (!waiting) return null;
3835
+ return {
3836
+ source: hasModal ? "legacy_provider" : "status_only",
3837
+ type: "unknown",
3838
+ compatibility: hasModal ? "session_only" : "unknown",
3839
+ evidence: "unavailable",
3840
+ lifecycle: "pending",
3841
+ modalKey: null,
3842
+ createdAt: null,
3843
+ resolvedAt: null,
3844
+ description: "",
3845
+ buttons: [],
3846
+ actionable: false
3847
+ };
3848
+ }
3849
+ function providerApprovalSnapshot(approval) {
3850
+ if (!approval) return null;
3851
+ const {
3852
+ source,
3853
+ type,
3854
+ lifecycle,
3855
+ modalKey,
3856
+ createdAt,
3857
+ resolvedAt,
3858
+ providerType,
3859
+ sessionId,
3860
+ nodeId,
3861
+ meshId,
3862
+ taskId,
3863
+ attemptId,
3864
+ generation
3865
+ } = approval;
3866
+ return {
3867
+ source,
3868
+ type,
3869
+ lifecycle,
3870
+ modalKey,
3871
+ createdAt,
3872
+ resolvedAt,
3873
+ providerType,
3874
+ sessionId,
3875
+ nodeId,
3876
+ meshId,
3877
+ taskId,
3878
+ attemptId,
3879
+ generation,
3880
+ evidence: "cached",
3881
+ actionable: false,
3882
+ description: "",
3883
+ buttons: []
3884
+ };
3885
+ }
3886
+
3887
+ // src/provider-question.ts
3888
+ function isProviderQuestionBinding(value) {
3889
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
3890
+ const b = value;
3891
+ if (b.transport !== "codex_rpc" && b.transport !== "codex_async") return false;
3892
+ const keys = ["transport", "sessionId", "generation", "threadId", "turnId", "itemId", ...b.transport === "codex_rpc" ? ["requestId"] : []];
3893
+ if (Reflect.ownKeys(b).some((key) => typeof key !== "string" || !keys.includes(key))) return false;
3894
+ if (["sessionId", "generation", "threadId", "turnId", "itemId"].some((key) => typeof b[key] !== "string" || !b[key].trim())) return false;
3895
+ return b.transport === "codex_async" ? b.requestId === void 0 : typeof b.requestId === "string" && !!b.requestId.trim() || typeof b.requestId === "number" && Number.isFinite(b.requestId);
3896
+ }
3799
3897
  // Annotate the CommonJS export names for ESM import in node:
3800
3898
  0 && (module.exports = {
3801
3899
  ASSISTANT_OWNER_VERBS,
@@ -3922,6 +4020,7 @@ function stableMeshNodeRow(row) {
3922
4020
  WORKER_BRANCH_STATES,
3923
4021
  WORKER_PROTOCOL_FOOTER_MARKER,
3924
4022
  WORKER_REPORT_OUTCOMES,
4023
+ WORKER_REPORT_SUMMARY_MAX_CHARS,
3925
4024
  WORKER_TOOLS,
3926
4025
  appendWorkerProtocolFooter,
3927
4026
  argsCarryStatusProbeMarker,
@@ -4006,6 +4105,7 @@ function stableMeshNodeRow(row) {
4006
4105
  hasGitStatusEvidence,
4007
4106
  hasWorkerProtocolFooter,
4008
4107
  interpolateString,
4108
+ isActionableProviderApproval,
4009
4109
  isAssistantTool,
4010
4110
  isBlockedStatus,
4011
4111
  isBusyStatus,
@@ -4041,12 +4141,14 @@ function stableMeshNodeRow(row) {
4041
4141
  isMessageId,
4042
4142
  isMissionUpsertResponse,
4043
4143
  isModelAxisSource,
4144
+ isNativeMarkerRef,
4044
4145
  isNonEmptyString,
4045
4146
  isNotifyKind,
4046
4147
  isOutboundMessage,
4047
4148
  isOutboundMessageOrigin,
4048
4149
  isP2PSignalType,
4049
4150
  isPhantomDaemonEntry,
4151
+ isProviderQuestionBinding,
4050
4152
  isRawDaemonDoId,
4051
4153
  isReadyStatus,
4052
4154
  isRecord,
@@ -4107,11 +4209,13 @@ function stableMeshNodeRow(row) {
4107
4209
  pickBestTransitGitStatus,
4108
4210
  projectFileDiffRow,
4109
4211
  projectTurnEvidenceEntry,
4212
+ providerApprovalSnapshot,
4110
4213
  readBoolean,
4111
4214
  readEnvelopeFields,
4112
4215
  readGitSubmodules,
4113
4216
  readNumber,
4114
4217
  readOptionalRecord,
4218
+ readProviderDecision,
4115
4219
  readRecord,
4116
4220
  readString,
4117
4221
  readStringArray,