@adhdev/mesh-shared 1.0.82-rc.2 → 1.0.82-rc.21
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/assistant-protocol.d.ts +12 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +236 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +220 -20
- package/dist/index.mjs.map +1 -1
- package/dist/launch-defaults.d.ts +194 -0
- package/dist/mesh-tool-names.d.ts +2 -2
- package/dist/mesh-vocabulary.d.ts +8 -1
- package/dist/node-facts.d.ts +40 -0
- package/dist/path-ownership.d.ts +1 -1
- package/dist/provider-approval.d.ts +36 -0
- package/dist/provider-question.d.ts +19 -0
- package/dist/quota-freshness.d.ts +65 -0
- package/dist/turn-evidence.d.ts +20 -8
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/assistant-protocol.ts +26 -1
- package/src/index.ts +4 -0
- package/src/keyed-doc-delta.ts +9 -1
- package/src/launch-defaults.ts +168 -0
- package/src/mesh-tool-names.ts +1 -0
- package/src/mesh-vocabulary.ts +8 -0
- package/src/node-facts.ts +35 -0
- package/src/path-ownership.ts +4 -6
- package/src/provider-approval.ts +59 -0
- package/src/provider-question.ts +31 -0
- package/src/quota-freshness.ts +136 -0
- package/src/turn-evidence.ts +20 -17
- package/src/types.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -300,6 +300,50 @@ function defaultProviderPriorityFromNodeFacts(facts) {
|
|
|
300
300
|
return orderProvidersByBuiltinPreference(detected.length ? detected : enabled);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
// src/quota-freshness.ts
|
|
304
|
+
var QUOTA_RETRY_INFLIGHT_GRACE_MS = 6e4;
|
|
305
|
+
var QUOTA_BACKFILL_HORIZON_MS = 60 * 60 * 1e3;
|
|
306
|
+
function hasUsableWindow(window) {
|
|
307
|
+
return !!window && typeof window.usedPercent === "number" && Number.isFinite(window.usedPercent);
|
|
308
|
+
}
|
|
309
|
+
function hasReading(quota) {
|
|
310
|
+
if (hasUsableWindow(quota.session) || hasUsableWindow(quota.weekly) || hasUsableWindow(quota.monthly)) return true;
|
|
311
|
+
return Array.isArray(quota.buckets) && quota.buckets.some((b) => !!b && typeof b.usedPercent === "number" && Number.isFinite(b.usedPercent));
|
|
312
|
+
}
|
|
313
|
+
function finiteMs(value) {
|
|
314
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
315
|
+
}
|
|
316
|
+
function backfillCheckAt(quota, now) {
|
|
317
|
+
const dataDue = finiteMs(quota.updatedAt);
|
|
318
|
+
const attempted = finiteMs(quota.metadata?.fetchedAt);
|
|
319
|
+
const dueAt = Math.max(
|
|
320
|
+
dataDue === void 0 ? Number.NEGATIVE_INFINITY : dataDue + QUOTA_BACKFILL_HORIZON_MS,
|
|
321
|
+
attempted === void 0 ? Number.NEGATIVE_INFINITY : attempted + QUOTA_BACKFILL_HORIZON_MS
|
|
322
|
+
);
|
|
323
|
+
return Number.isFinite(dueAt) && dueAt > now ? dueAt : void 0;
|
|
324
|
+
}
|
|
325
|
+
function assessQuotaFreshness(quota, now = Date.now()) {
|
|
326
|
+
const meta = quota.metadata;
|
|
327
|
+
const kind = meta?.failureKind;
|
|
328
|
+
const userMustAct = kind === "no-data" && quota.provider !== "codex-cli" || kind === "expired-token" && ["grok-cli", "kimi", "antigravity-cli"].includes(quota.provider);
|
|
329
|
+
if (userMustAct) return hasReading(quota) ? { cue: "stale", userMustAct: true } : { userMustAct: true };
|
|
330
|
+
if (meta?.lastGoodWindows !== true) {
|
|
331
|
+
const measuredAt = finiteMs(quota.updatedAt);
|
|
332
|
+
if (hasReading(quota) && (measuredAt === void 0 || now - measuredAt >= QUOTA_BACKFILL_HORIZON_MS)) {
|
|
333
|
+
return { cue: "stale", userMustAct };
|
|
334
|
+
}
|
|
335
|
+
return { userMustAct };
|
|
336
|
+
}
|
|
337
|
+
const retryAtMs = finiteMs(meta?.retryAtMs);
|
|
338
|
+
const retryStopped = meta?.retryExhausted === true || retryAtMs !== void 0 && retryAtMs + QUOTA_RETRY_INFLIGHT_GRACE_MS < now;
|
|
339
|
+
if (kind !== "no-data" && !retryStopped) return { cue: "refreshing", userMustAct: false };
|
|
340
|
+
const nextCheckAt = backfillCheckAt(quota, now);
|
|
341
|
+
return nextCheckAt === void 0 ? { cue: "stale", userMustAct: false } : { cue: "stale", userMustAct: false, nextCheckAt };
|
|
342
|
+
}
|
|
343
|
+
function minutesUntilQuotaCheck(nextCheckAt, now = Date.now()) {
|
|
344
|
+
return Math.max(1, Math.round((nextCheckAt - now) / 6e4));
|
|
345
|
+
}
|
|
346
|
+
|
|
303
347
|
// src/workspace-normalize.ts
|
|
304
348
|
function normalizeMeshWorkspaceForCompare(dir) {
|
|
305
349
|
if (typeof dir !== "string") return "";
|
|
@@ -691,6 +735,7 @@ var CANONICAL_MESH_TOOL_NAMES = [
|
|
|
691
735
|
"mesh_list_pending_approvals",
|
|
692
736
|
"mesh_create",
|
|
693
737
|
"mesh_add_node",
|
|
738
|
+
"mesh_attach_remote",
|
|
694
739
|
"mesh_clone_node",
|
|
695
740
|
"mesh_remove_node",
|
|
696
741
|
"mesh_cleanup_worktree_nodes",
|
|
@@ -1400,6 +1445,7 @@ var MESH_THINKING_LEVELS = ["low", "medium", "high"];
|
|
|
1400
1445
|
var MESH_DELIVERY_MODES = ["when_idle", "interrupt"];
|
|
1401
1446
|
var MESH_SESSION_CLEANUP_MODES = ["preserve", "stop", "delete_stopped", "stop_and_delete"];
|
|
1402
1447
|
var WORKER_REPORT_OUTCOMES = ["completed", "blocked", "failed"];
|
|
1448
|
+
var WORKER_REPORT_SUMMARY_MAX_CHARS = 8e3;
|
|
1403
1449
|
var WORKER_BRANCH_STATES = [
|
|
1404
1450
|
"merged_to_main",
|
|
1405
1451
|
"pushed_feature_branch_needs_merge",
|
|
@@ -1667,15 +1713,21 @@ function renderCoordinatorWorkerSection() {
|
|
|
1667
1713
|
// src/assistant-protocol.ts
|
|
1668
1714
|
var ASSISTANT_TOOLS = [
|
|
1669
1715
|
"projects",
|
|
1716
|
+
"environment",
|
|
1717
|
+
"assistant_action",
|
|
1718
|
+
"project_watch",
|
|
1670
1719
|
"project_status",
|
|
1671
1720
|
"project_send",
|
|
1672
1721
|
"project_read",
|
|
1673
1722
|
"project_add",
|
|
1723
|
+
"project_attach_remote",
|
|
1674
1724
|
"discover_repos",
|
|
1675
1725
|
"memory",
|
|
1676
1726
|
"skill_view",
|
|
1677
1727
|
"skill_manage",
|
|
1678
|
-
"project_note"
|
|
1728
|
+
"project_note",
|
|
1729
|
+
"launch_defaults",
|
|
1730
|
+
"launch_defaults_set"
|
|
1679
1731
|
];
|
|
1680
1732
|
var ASSISTANT_TOOL_SET = new Set(ASSISTANT_TOOLS);
|
|
1681
1733
|
function isAssistantTool(value) {
|
|
@@ -1684,40 +1736,59 @@ function isAssistantTool(value) {
|
|
|
1684
1736
|
var ASSISTANT_VERB = {
|
|
1685
1737
|
// tool verbs
|
|
1686
1738
|
projects: "assistant_projects",
|
|
1739
|
+
environment: "assistant_environment",
|
|
1740
|
+
action: "assistant_action",
|
|
1741
|
+
watch: "assistant_project_watch",
|
|
1742
|
+
executionState: "assistant_execution_state",
|
|
1743
|
+
executionSettings: "assistant_execution_settings",
|
|
1687
1744
|
projectStatus: "assistant_project_status",
|
|
1688
1745
|
projectSend: "assistant_project_send",
|
|
1689
1746
|
projectRead: "assistant_project_read",
|
|
1690
1747
|
projectAdd: "assistant_project_add",
|
|
1748
|
+
projectAttachRemote: "assistant_project_attach_remote",
|
|
1691
1749
|
discoverRepos: "assistant_discover_repos",
|
|
1692
1750
|
memory: "assistant_memory",
|
|
1693
1751
|
skillView: "assistant_skill_view",
|
|
1694
1752
|
skillManage: "assistant_skill_manage",
|
|
1695
1753
|
projectNote: "assistant_project_note",
|
|
1754
|
+
launchDefaults: "assistant_launch_defaults",
|
|
1755
|
+
launchDefaultsSet: "assistant_launch_defaults_set",
|
|
1696
1756
|
// assistant-side daemon verbs without a tool of the same name
|
|
1697
1757
|
launch: "launch_assistant",
|
|
1698
1758
|
pendingRelays: "assistant_pending_relays",
|
|
1699
1759
|
// owner verbs (dashboard only)
|
|
1700
1760
|
stagedResolve: "assistant_staged_resolve",
|
|
1701
1761
|
storeAdmin: "assistant_store_admin",
|
|
1702
|
-
importSkills: "assistant_import_skills"
|
|
1762
|
+
importSkills: "assistant_import_skills",
|
|
1763
|
+
/** Projects the assistant is following (open relay threads) — list / stop following. */
|
|
1764
|
+
threads: "assistant_threads",
|
|
1765
|
+
threadClose: "assistant_thread_close"
|
|
1703
1766
|
};
|
|
1704
1767
|
var ASSISTANT_TOOL_VERBS = {
|
|
1705
1768
|
projects: ASSISTANT_VERB.projects,
|
|
1769
|
+
environment: ASSISTANT_VERB.environment,
|
|
1770
|
+
assistant_action: ASSISTANT_VERB.action,
|
|
1771
|
+
project_watch: ASSISTANT_VERB.watch,
|
|
1706
1772
|
project_status: ASSISTANT_VERB.projectStatus,
|
|
1707
1773
|
project_send: ASSISTANT_VERB.projectSend,
|
|
1708
1774
|
project_read: ASSISTANT_VERB.projectRead,
|
|
1709
1775
|
project_add: ASSISTANT_VERB.projectAdd,
|
|
1776
|
+
project_attach_remote: ASSISTANT_VERB.projectAttachRemote,
|
|
1710
1777
|
discover_repos: ASSISTANT_VERB.discoverRepos,
|
|
1711
1778
|
memory: ASSISTANT_VERB.memory,
|
|
1712
1779
|
skill_view: ASSISTANT_VERB.skillView,
|
|
1713
1780
|
skill_manage: ASSISTANT_VERB.skillManage,
|
|
1714
|
-
project_note: ASSISTANT_VERB.projectNote
|
|
1781
|
+
project_note: ASSISTANT_VERB.projectNote,
|
|
1782
|
+
launch_defaults: ASSISTANT_VERB.launchDefaults,
|
|
1783
|
+
launch_defaults_set: ASSISTANT_VERB.launchDefaultsSet
|
|
1715
1784
|
};
|
|
1716
|
-
var ASSISTANT_WRITE_TOOLS = ["memory", "skill_manage", "project_note", "project_send", "project_add"];
|
|
1785
|
+
var ASSISTANT_WRITE_TOOLS = ["project_watch", "assistant_action", "memory", "skill_manage", "project_note", "project_send", "project_add", "project_attach_remote", "launch_defaults_set"];
|
|
1717
1786
|
var ASSISTANT_OWNER_VERBS = [
|
|
1787
|
+
ASSISTANT_VERB.executionSettings,
|
|
1718
1788
|
ASSISTANT_VERB.stagedResolve,
|
|
1719
1789
|
ASSISTANT_VERB.storeAdmin,
|
|
1720
|
-
ASSISTANT_VERB.importSkills
|
|
1790
|
+
ASSISTANT_VERB.importSkills,
|
|
1791
|
+
ASSISTANT_VERB.threadClose
|
|
1721
1792
|
];
|
|
1722
1793
|
var ASSISTANT_REVIEW_TURN_VERBS = [
|
|
1723
1794
|
ASSISTANT_VERB.memory,
|
|
@@ -1772,8 +1843,8 @@ function sanitizeRefusalCode(value) {
|
|
|
1772
1843
|
var CONSUME_PROFILES = ["default", "native_source"];
|
|
1773
1844
|
var SESSION_REBOUND_REASONS = ["restart", "live_holder"];
|
|
1774
1845
|
var SUSPENSION_MODALS = ["approval", "choice"];
|
|
1775
|
-
var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered"];
|
|
1776
|
-
var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer"];
|
|
1846
|
+
var SUSPENSION_RESOLUTIONS = ["approved", "rejected", "answered", "dismissed"];
|
|
1847
|
+
var SUSPENSION_RESOLUTION_VIAS = ["modal_button", "auto_approve", "prompt_answer", "modal_disappeared"];
|
|
1777
1848
|
var TURN_END_STRENGTHS = ["genuine", "weak"];
|
|
1778
1849
|
var TURN_END_BLOCK_REASONS = [
|
|
1779
1850
|
"missing_final_assistant",
|
|
@@ -1781,9 +1852,9 @@ var TURN_END_BLOCK_REASONS = [
|
|
|
1781
1852
|
"terminal_block_hard_cap",
|
|
1782
1853
|
"decoupled_completion"
|
|
1783
1854
|
];
|
|
1784
|
-
var NATIVE_TURN_OUTCOMES = ["completed", "aborted"];
|
|
1855
|
+
var NATIVE_TURN_OUTCOMES = ["completed", "aborted", "failed"];
|
|
1785
1856
|
var LIVENESS_RESULTS = ["alive", "unknown", "read_failed", "dead"];
|
|
1786
|
-
var PROVIDER_FAILURES = ["auth_failed", "billing_failed"];
|
|
1857
|
+
var PROVIDER_FAILURES = ["auth_failed", "billing_failed", "usage_limit_exceeded", "server_overloaded", "provider_error"];
|
|
1787
1858
|
var SESSION_ERROR_REASONS = ["provider_error", "adapter_error", "spawn_failed", "auth_failed", "billing_failed", "unknown", "daemon_restart"];
|
|
1788
1859
|
var CANCEL_REASONS = ["operator_cancel", "intentional_cleanup", "task_removed", "mission_abandoned", "superseded"];
|
|
1789
1860
|
var OPERATOR_STATUSES = ["completed", "failed"];
|
|
@@ -1810,7 +1881,8 @@ var HOLD_REASONS = [
|
|
|
1810
1881
|
// — a turn_end commits the report (R9t), expiry commits it anyway (R13t) so
|
|
1811
1882
|
// a session whose FSM never shows the idle edge again does not wait for
|
|
1812
1883
|
// liveness / hard_ceiling.
|
|
1813
|
-
"await_end"
|
|
1884
|
+
"await_end",
|
|
1885
|
+
"report_correction"
|
|
1814
1886
|
];
|
|
1815
1887
|
var TURN_OUTCOMES = ["completed", "failed", "cancelled"];
|
|
1816
1888
|
var COMMIT_STRENGTHS = ["genuine", "weak", "tool_report", "operator"];
|
|
@@ -1821,9 +1893,15 @@ var TURN_REASONS = [
|
|
|
1821
1893
|
"transcript_final",
|
|
1822
1894
|
"worker_reported",
|
|
1823
1895
|
"finalization_timeout_no_response",
|
|
1896
|
+
"weak_end_liveness_unconfirmed",
|
|
1897
|
+
"weak_end_probe_unobserved",
|
|
1898
|
+
"report_correction_expired",
|
|
1824
1899
|
"session_error",
|
|
1825
1900
|
"provider_auth_failed",
|
|
1826
1901
|
"provider_billing_failed",
|
|
1902
|
+
"provider_usage_limit_exceeded",
|
|
1903
|
+
"provider_server_overloaded",
|
|
1904
|
+
"provider_error",
|
|
1827
1905
|
"operator_cancel",
|
|
1828
1906
|
"intentional_cleanup",
|
|
1829
1907
|
"task_removed",
|
|
@@ -1900,8 +1978,8 @@ var TURN_EVIDENCE_FIELD_SPECS = {
|
|
|
1900
1978
|
duplicate_dispatch_refusal: { holderSessionId: id, holderAttemptId: idOpt },
|
|
1901
1979
|
session_rebound: { toSessionId: id, reason: en(SESSION_REBOUND_REASONS) },
|
|
1902
1980
|
turn_started: { retro: bool },
|
|
1903
|
-
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt },
|
|
1904
|
-
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS) },
|
|
1981
|
+
suspension: { modal: en(SUSPENSION_MODALS), modalKey: idOpt, providerSetup: boolOpt, clockUnknown: boolOpt },
|
|
1982
|
+
suspension_resolved: { resolution: en(SUSPENSION_RESOLUTIONS), via: en(SUSPENSION_RESOLUTION_VIAS), modalKey: idOpt },
|
|
1905
1983
|
turn_end: {
|
|
1906
1984
|
strength: en(TURN_END_STRENGTHS),
|
|
1907
1985
|
afterFinalizationTimeout: boolOpt,
|
|
@@ -1911,6 +1989,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
|
|
|
1911
1989
|
releasedByHardCap: boolOpt,
|
|
1912
1990
|
nativeOutcome: enOpt(NATIVE_TURN_OUTCOMES),
|
|
1913
1991
|
live: { t: "live", optional: true },
|
|
1992
|
+
nativeMarker: { t: "native_marker", optional: true },
|
|
1914
1993
|
reportExpected: boolOpt,
|
|
1915
1994
|
providerFailure: enOpt(PROVIDER_FAILURES)
|
|
1916
1995
|
},
|
|
@@ -1924,7 +2003,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
|
|
|
1924
2003
|
},
|
|
1925
2004
|
transcript_activity: { newestActivityAt: ms },
|
|
1926
2005
|
no_progress: { stalledMs: ms, observedStatus: en(NO_PROGRESS_OBSERVED_STATUSES), finalAssistantPresent: bool },
|
|
1927
|
-
liveness: { result: en(LIVENESS_RESULTS) },
|
|
2006
|
+
liveness: { result: en(LIVENESS_RESULTS), probeStartedAtMs: msOpt },
|
|
1928
2007
|
process_exit: { exitCode: { t: "int", nullable: true }, providerFailure: enOpt(PROVIDER_FAILURES) },
|
|
1929
2008
|
session_error: { reason: en(SESSION_ERROR_REASONS) },
|
|
1930
2009
|
worker_report: {
|
|
@@ -1934,6 +2013,7 @@ var TURN_EVIDENCE_FIELD_SPECS = {
|
|
|
1934
2013
|
branchState: enOpt(WORKER_BRANCH_STATES),
|
|
1935
2014
|
touchedFileCount: intOpt
|
|
1936
2015
|
},
|
|
2016
|
+
worker_report_correction_requested: { deliveryId: { t: "id", optional: true } },
|
|
1937
2017
|
worker_progress: { note: { t: "summary_ref", optional: true } },
|
|
1938
2018
|
git_side_effect: { dirty: bool, commitsSinceDispatch: { t: "int" }, attributable: bool },
|
|
1939
2019
|
cancel: { reason: en(CANCEL_REASONS) },
|
|
@@ -1981,7 +2061,7 @@ function isLiveTurnPending(value) {
|
|
|
1981
2061
|
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));
|
|
1982
2062
|
}
|
|
1983
2063
|
function isNativeMarkerRef(value) {
|
|
1984
|
-
return isRecord2(value) && hasOnlyKeys(value, ["outcome", "turnId"]) && NATIVE_TURN_OUTCOMES.includes(value.outcome) && (value.turnId === void 0 || isEvidenceIdentifier(value.turnId));
|
|
2064
|
+
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]));
|
|
1985
2065
|
}
|
|
1986
2066
|
function isCoordinatorIdentity(value) {
|
|
1987
2067
|
return isRecord2(value) && hasOnlyKeys(value, ["daemonId", "coordinatorRunId", "sessionId"]) && isEvidenceIdentifier(value.daemonId) && isEvidenceIdentifier(value.coordinatorRunId) && (value.sessionId === void 0 || isEvidenceIdentifier(value.sessionId));
|
|
@@ -3050,14 +3130,11 @@ function normalizeOwnedPaths(input) {
|
|
|
3050
3130
|
}
|
|
3051
3131
|
function entryContains(base, path) {
|
|
3052
3132
|
if (path === base.path) return true;
|
|
3053
|
-
if (base.subtree && (path ===
|
|
3133
|
+
if (base.subtree && (base.path === "" || path.startsWith(`${base.path}/`))) return true;
|
|
3054
3134
|
return false;
|
|
3055
3135
|
}
|
|
3056
3136
|
function entriesOverlap(a, b) {
|
|
3057
|
-
|
|
3058
|
-
if (a.subtree && (b.path === a.path || b.path.startsWith(`${a.path}/`))) return true;
|
|
3059
|
-
if (b.subtree && (a.path === b.path || a.path.startsWith(`${b.path}/`))) return true;
|
|
3060
|
-
return false;
|
|
3137
|
+
return entryContains(a, b.path) || entryContains(b, a.path);
|
|
3061
3138
|
}
|
|
3062
3139
|
function pathsOverlap(a, b) {
|
|
3063
3140
|
if (a.paths.length === 0 || b.paths.length === 0) return false;
|
|
@@ -3329,7 +3406,15 @@ function foldKeyedDoc(held, delta, spec) {
|
|
|
3329
3406
|
const heldList = heldCollections.get(path);
|
|
3330
3407
|
if (change?.absent) {
|
|
3331
3408
|
const [head2, tail2] = splitPath(path);
|
|
3332
|
-
if (!tail2)
|
|
3409
|
+
if (!tail2) {
|
|
3410
|
+
delete next[head2];
|
|
3411
|
+
continue;
|
|
3412
|
+
}
|
|
3413
|
+
const parent2 = next[head2];
|
|
3414
|
+
if (!isRecord3(parent2) || !(tail2 in parent2)) continue;
|
|
3415
|
+
const copy = { ...parent2 };
|
|
3416
|
+
delete copy[tail2];
|
|
3417
|
+
next[head2] = copy;
|
|
3333
3418
|
continue;
|
|
3334
3419
|
}
|
|
3335
3420
|
if (!change && heldList === void 0) continue;
|
|
@@ -3393,6 +3478,105 @@ function stableMeshNodeRow(row) {
|
|
|
3393
3478
|
}
|
|
3394
3479
|
return out;
|
|
3395
3480
|
}
|
|
3481
|
+
|
|
3482
|
+
// src/provider-approval.ts
|
|
3483
|
+
function isActionableProviderApproval(approval) {
|
|
3484
|
+
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());
|
|
3485
|
+
}
|
|
3486
|
+
function readProviderDecision(approval, waiting, hasModal = false) {
|
|
3487
|
+
if (approval !== void 0) return approval && ["provider_modal", "legacy_provider", "status_only", "ledger_approval"].includes(approval.source) ? approval : null;
|
|
3488
|
+
if (!waiting) return null;
|
|
3489
|
+
return {
|
|
3490
|
+
source: hasModal ? "legacy_provider" : "status_only",
|
|
3491
|
+
type: "unknown",
|
|
3492
|
+
compatibility: hasModal ? "session_only" : "unknown",
|
|
3493
|
+
evidence: "unavailable",
|
|
3494
|
+
lifecycle: "pending",
|
|
3495
|
+
modalKey: null,
|
|
3496
|
+
createdAt: null,
|
|
3497
|
+
resolvedAt: null,
|
|
3498
|
+
description: "",
|
|
3499
|
+
buttons: [],
|
|
3500
|
+
actionable: false
|
|
3501
|
+
};
|
|
3502
|
+
}
|
|
3503
|
+
function providerApprovalSnapshot(approval) {
|
|
3504
|
+
if (!approval) return null;
|
|
3505
|
+
const {
|
|
3506
|
+
source,
|
|
3507
|
+
type,
|
|
3508
|
+
lifecycle,
|
|
3509
|
+
modalKey,
|
|
3510
|
+
createdAt,
|
|
3511
|
+
resolvedAt,
|
|
3512
|
+
providerType,
|
|
3513
|
+
sessionId,
|
|
3514
|
+
nodeId,
|
|
3515
|
+
meshId,
|
|
3516
|
+
taskId,
|
|
3517
|
+
attemptId,
|
|
3518
|
+
generation
|
|
3519
|
+
} = approval;
|
|
3520
|
+
return {
|
|
3521
|
+
source,
|
|
3522
|
+
type,
|
|
3523
|
+
lifecycle,
|
|
3524
|
+
modalKey,
|
|
3525
|
+
createdAt,
|
|
3526
|
+
resolvedAt,
|
|
3527
|
+
providerType,
|
|
3528
|
+
sessionId,
|
|
3529
|
+
nodeId,
|
|
3530
|
+
meshId,
|
|
3531
|
+
taskId,
|
|
3532
|
+
attemptId,
|
|
3533
|
+
generation,
|
|
3534
|
+
evidence: "cached",
|
|
3535
|
+
actionable: false,
|
|
3536
|
+
description: "",
|
|
3537
|
+
buttons: []
|
|
3538
|
+
};
|
|
3539
|
+
}
|
|
3540
|
+
|
|
3541
|
+
// src/provider-question.ts
|
|
3542
|
+
function isProviderQuestionBinding(value) {
|
|
3543
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
3544
|
+
const b = value;
|
|
3545
|
+
if (b.transport !== "codex_rpc" && b.transport !== "codex_async") return false;
|
|
3546
|
+
const keys = ["transport", "sessionId", "generation", "threadId", "turnId", "itemId", ...b.transport === "codex_rpc" ? ["requestId"] : []];
|
|
3547
|
+
if (Reflect.ownKeys(b).some((key) => typeof key !== "string" || !keys.includes(key))) return false;
|
|
3548
|
+
if (["sessionId", "generation", "threadId", "turnId", "itemId"].some((key) => typeof b[key] !== "string" || !b[key].trim())) return false;
|
|
3549
|
+
return b.transport === "codex_async" ? b.requestId === void 0 : typeof b.requestId === "string" && !!b.requestId.trim() || typeof b.requestId === "number" && Number.isFinite(b.requestId);
|
|
3550
|
+
}
|
|
3551
|
+
|
|
3552
|
+
// src/launch-defaults.ts
|
|
3553
|
+
var LAUNCH_DEFAULT_ROLES = ["assistant", "coordinator"];
|
|
3554
|
+
var LAUNCH_DEFAULT_SOURCES = ["user", "stored_default", "project_default", "provider_default"];
|
|
3555
|
+
var LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE = "Applies to the next launch; running sessions are unchanged.";
|
|
3556
|
+
function isLaunchDefaultRole(value) {
|
|
3557
|
+
return typeof value === "string" && LAUNCH_DEFAULT_ROLES.includes(value);
|
|
3558
|
+
}
|
|
3559
|
+
function isLaunchDefaultSource(value) {
|
|
3560
|
+
return typeof value === "string" && LAUNCH_DEFAULT_SOURCES.includes(value);
|
|
3561
|
+
}
|
|
3562
|
+
var LAUNCH_DEFAULT_ERROR_CODES = [
|
|
3563
|
+
"invalid_args",
|
|
3564
|
+
"launch_default_required",
|
|
3565
|
+
"launch_default_unavailable",
|
|
3566
|
+
"launch_selection_invalid",
|
|
3567
|
+
"launch_default_invalid",
|
|
3568
|
+
"revision_conflict",
|
|
3569
|
+
"store_unavailable",
|
|
3570
|
+
"store_busy",
|
|
3571
|
+
"persistence_failed",
|
|
3572
|
+
"project_not_found",
|
|
3573
|
+
"project_ambiguous",
|
|
3574
|
+
"project_not_hosted",
|
|
3575
|
+
"project_storage_unavailable",
|
|
3576
|
+
"staging_unavailable",
|
|
3577
|
+
"staging_failed",
|
|
3578
|
+
"review_turn_tool_denied"
|
|
3579
|
+
];
|
|
3396
3580
|
export {
|
|
3397
3581
|
ASSISTANT_OWNER_VERBS,
|
|
3398
3582
|
ASSISTANT_REVIEW_TURN_VERBS,
|
|
@@ -3431,6 +3615,10 @@ export {
|
|
|
3431
3615
|
EVIDENCE_ENVELOPE_FIELD_SPECS,
|
|
3432
3616
|
EVIDENCE_SOURCE_IDS,
|
|
3433
3617
|
HOLD_REASONS,
|
|
3618
|
+
LAUNCH_DEFAULTS_NEXT_LAUNCH_NOTE,
|
|
3619
|
+
LAUNCH_DEFAULT_ERROR_CODES,
|
|
3620
|
+
LAUNCH_DEFAULT_ROLES,
|
|
3621
|
+
LAUNCH_DEFAULT_SOURCES,
|
|
3434
3622
|
LIVENESS_RESULTS,
|
|
3435
3623
|
MAX_MESH_RECORD_STRING,
|
|
3436
3624
|
MAX_OWNED_PATHS,
|
|
@@ -3471,6 +3659,8 @@ export {
|
|
|
3471
3659
|
OUTBOUND_MESSAGE_ORIGINS,
|
|
3472
3660
|
P2P_SIGNAL_TYPES,
|
|
3473
3661
|
PROVIDER_FAILURES,
|
|
3662
|
+
QUOTA_BACKFILL_HORIZON_MS,
|
|
3663
|
+
QUOTA_RETRY_INFLIGHT_GRACE_MS,
|
|
3474
3664
|
QUOTA_SUPPORTED_PROVIDERS,
|
|
3475
3665
|
RECENT_SESSION_BUCKETS,
|
|
3476
3666
|
RECLAIMING_SEND_REFUSALS,
|
|
@@ -3516,9 +3706,11 @@ export {
|
|
|
3516
3706
|
WORKER_BRANCH_STATES,
|
|
3517
3707
|
WORKER_PROTOCOL_FOOTER_MARKER,
|
|
3518
3708
|
WORKER_REPORT_OUTCOMES,
|
|
3709
|
+
WORKER_REPORT_SUMMARY_MAX_CHARS,
|
|
3519
3710
|
WORKER_TOOLS,
|
|
3520
3711
|
appendWorkerProtocolFooter,
|
|
3521
3712
|
argsCarryStatusProbeMarker,
|
|
3713
|
+
assessQuotaFreshness,
|
|
3522
3714
|
buildSlotProposal,
|
|
3523
3715
|
canonicalDaemonId,
|
|
3524
3716
|
classifySessionStatus,
|
|
@@ -3599,6 +3791,7 @@ export {
|
|
|
3599
3791
|
hasGitStatusEvidence,
|
|
3600
3792
|
hasWorkerProtocolFooter,
|
|
3601
3793
|
interpolateString,
|
|
3794
|
+
isActionableProviderApproval,
|
|
3602
3795
|
isAssistantTool,
|
|
3603
3796
|
isBlockedStatus,
|
|
3604
3797
|
isBusyStatus,
|
|
@@ -3620,6 +3813,8 @@ export {
|
|
|
3620
3813
|
isFiniteNumber,
|
|
3621
3814
|
isIdleSessionState,
|
|
3622
3815
|
isInputEnvelopeWire,
|
|
3816
|
+
isLaunchDefaultRole,
|
|
3817
|
+
isLaunchDefaultSource,
|
|
3623
3818
|
isMeshDeliveryMode,
|
|
3624
3819
|
isMeshIndexQueryResponse,
|
|
3625
3820
|
isMeshMissionStatusValue,
|
|
@@ -3634,12 +3829,14 @@ export {
|
|
|
3634
3829
|
isMessageId,
|
|
3635
3830
|
isMissionUpsertResponse,
|
|
3636
3831
|
isModelAxisSource,
|
|
3832
|
+
isNativeMarkerRef,
|
|
3637
3833
|
isNonEmptyString,
|
|
3638
3834
|
isNotifyKind,
|
|
3639
3835
|
isOutboundMessage,
|
|
3640
3836
|
isOutboundMessageOrigin,
|
|
3641
3837
|
isP2PSignalType,
|
|
3642
3838
|
isPhantomDaemonEntry,
|
|
3839
|
+
isProviderQuestionBinding,
|
|
3643
3840
|
isRawDaemonDoId,
|
|
3644
3841
|
isReadyStatus,
|
|
3645
3842
|
isRecord,
|
|
@@ -3677,6 +3874,7 @@ export {
|
|
|
3677
3874
|
meshUtf8ByteLength,
|
|
3678
3875
|
meshWorkspacesEquivalent,
|
|
3679
3876
|
mintMessageId,
|
|
3877
|
+
minutesUntilQuotaCheck,
|
|
3680
3878
|
normalizeAuthOkLimits,
|
|
3681
3879
|
normalizeBrainSlot,
|
|
3682
3880
|
normalizeDifficultyBrainMap,
|
|
@@ -3699,11 +3897,13 @@ export {
|
|
|
3699
3897
|
pickBestTransitGitStatus,
|
|
3700
3898
|
projectFileDiffRow,
|
|
3701
3899
|
projectTurnEvidenceEntry,
|
|
3900
|
+
providerApprovalSnapshot,
|
|
3702
3901
|
readBoolean,
|
|
3703
3902
|
readEnvelopeFields,
|
|
3704
3903
|
readGitSubmodules,
|
|
3705
3904
|
readNumber,
|
|
3706
3905
|
readOptionalRecord,
|
|
3906
|
+
readProviderDecision,
|
|
3707
3907
|
readRecord,
|
|
3708
3908
|
readString,
|
|
3709
3909
|
readStringArray,
|