@sema-agent/core 7.0.2 → 7.2.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/CHANGELOG.md +58 -0
- package/dist/agents/cross-session-envelope.d.ts +138 -0
- package/dist/agents/cross-session-envelope.js +191 -0
- package/dist/agents/cross-session-judge.d.ts +119 -0
- package/dist/agents/cross-session-judge.js +184 -0
- package/dist/agents/cross-session-ref.d.ts +52 -0
- package/dist/agents/cross-session-ref.js +64 -0
- package/dist/agents/repair-loop.d.ts +8 -7
- package/dist/agents/roster-store.d.ts +7 -2
- package/dist/agents/send-message-tool.d.ts +13 -0
- package/dist/agents/send-message-tool.js +36 -12
- package/dist/brain/errors.d.ts +18 -0
- package/dist/brain/errors.js +3 -0
- package/dist/brain/stream-engine.js +6 -4
- package/dist/core/checkpoint-store.d.ts +189 -3
- package/dist/core/checkpoint-store.js +56 -16
- package/dist/core/context-edit.d.ts +3 -0
- package/dist/core/governance-codes.d.ts +1 -1
- package/dist/core/governance-codes.js +4 -0
- package/dist/core/hooks.d.ts +34 -7
- package/dist/core/hooks.js +14 -8
- package/dist/core/image-downsample.d.ts +4 -3
- package/dist/core/permission-rule-consent.d.ts +72 -23
- package/dist/core/permission-rule-consent.js +115 -26
- package/dist/core/permission-rule-model.d.ts +245 -51
- package/dist/core/permission-rule-model.js +312 -54
- package/dist/core/permission-rule-org.js +13 -6
- package/dist/core/remote-env.d.ts +8 -1
- package/dist/core/roles.d.ts +30 -8
- package/dist/core/roles.js +12 -8
- package/dist/core/runner/assemble-result.js +2 -1
- package/dist/core/runner/prepare-task.d.ts +41 -2
- package/dist/core/runner/prepare-task.js +353 -152
- package/dist/core/runner/prepare-workspace-restore.d.ts +6 -1
- package/dist/core/runner/prepare-workspace-restore.js +2 -1
- package/dist/core/runner/runtask.d.ts +12 -3
- package/dist/core/runner/runtask.js +45 -7
- package/dist/core/safety-axis-vocab.d.ts +1 -1
- package/dist/core/strategy-store.d.ts +4 -1
- package/dist/core/task-notification.d.ts +64 -5
- package/dist/core/task-notification.js +25 -4
- package/dist/core/task-registry-shared.d.ts +7 -3
- package/dist/core/tool-errors.d.ts +1 -1
- package/dist/core/tool-policy.d.ts +51 -7
- package/dist/core/tool-policy.js +63 -9
- package/dist/core/types.d.ts +110 -9
- package/dist/core/untrusted-text.js +17 -1
- package/dist/engine/compaction/compaction.js +6 -2
- package/dist/engine/harness/agent-harness.d.ts +28 -6
- package/dist/engine/harness/agent-harness.js +34 -2
- package/dist/engine/harness/messages.js +4 -0
- package/dist/engine/harness/types.d.ts +37 -0
- package/dist/engine/harness/types.js +5 -0
- package/dist/engine/session/session.js +3 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +5 -2
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/harness.js +1 -0
- package/dist/orchestration/builtin-workflows.d.ts +17 -9
- package/dist/orchestration/run-workflow-tool.js +7 -2
- package/dist/orchestration/workflow-governance.js +1 -1
- package/dist/orchestration/workflow-types.d.ts +1 -0
- package/dist/orchestration/workflow.js +1 -1
- package/dist/stores/file/mailbox-store.d.ts +2 -1
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +125 -1
|
@@ -180,5 +180,6 @@ export function assembleResult(spec, sessionId, final, stats, flags) {
|
|
|
180
180
|
void _internalCompaction;
|
|
181
181
|
if (flags.unpricedSpend)
|
|
182
182
|
delete publicStats.costMicroUsd;
|
|
183
|
-
|
|
183
|
+
const stampHaltedByUser = flags.userHalted === true && status !== "suspended" && status !== "needs_review";
|
|
184
|
+
return { taskId, ...(flags.runId !== undefined ? { runId: flags.runId } : {}), sessionId, status, ...(flags.model !== undefined ? { model: flags.model } : {}), result: result.trim(), salvagedOutput, blockedReason, errorMessage, errorCode, ...(apiFailure !== undefined ? { apiFailure } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}), checkpointToken, ...(checkpointId !== undefined ? { checkpointId } : {}), checkpointGate, ...(workspaceRestoreMode !== undefined ? { workspaceRestoreMode } : {}), ...(flags.rewindNotes !== undefined && flags.rewindNotes.length > 0 ? { rewindNotes: flags.rewindNotes } : {}), ...(flags.haltedOnUserRejection === true ? { haltedOnUserRejection: true } : {}), ...(stampHaltedByUser ? { haltedByUser: true } : {}), ...(flags.remoteEnvFailures !== undefined && flags.remoteEnvFailures.length > 0 ? { remoteEnvFailures: [...flags.remoteEnvFailures] } : {}), ...(flags.strandedHumanAnswers !== undefined && flags.strandedHumanAnswers.length > 0 ? { strandedHumanAnswers: flags.strandedHumanAnswers } : {}), ...(flags.effectiveReadFace !== undefined ? { effectiveReadFace: flags.effectiveReadFace } : {}), ...(flags.effectiveReadDenyPatterns !== undefined && flags.effectiveReadDenyPatterns.length > 0 ? { effectiveReadDenyPatterns: flags.effectiveReadDenyPatterns } : {}), ...(flags.effectiveMemoryScopes !== undefined ? { effectiveMemoryScopes: flags.effectiveMemoryScopes } : {}), ...(flags.effectiveReasoning !== undefined ? { effectiveReasoning: flags.effectiveReasoning } : {}), stats: publicStats };
|
|
184
185
|
}
|
|
@@ -24,13 +24,14 @@ import { type ToolManifestRow } from "../../prompt-assembly/tool-catalog.js";
|
|
|
24
24
|
import type { ToolDisclosureManifest } from "../trace.js";
|
|
25
25
|
import { type ClearedProjectionLedger, type ContextEditMachine, type OccurrenceIndex } from "../context-edit.js";
|
|
26
26
|
import type { TaskNotificationPayload } from "../task-notification.js";
|
|
27
|
+
import type { RemoteExecutionEnv, SnapshotId } from "../remote-env.js";
|
|
27
28
|
import { type CwdRef, type ReadFace } from "../../tools/fs/index.js";
|
|
28
29
|
import { type WorkflowSizeGuideline } from "../../orchestration/workflow-size-guideline.js";
|
|
29
30
|
import type { Runner } from "./runtask.js";
|
|
30
31
|
import { type CheckpointGate, type CheckpointState, type CheckpointToken, type ResourceLedger, type PlatformLimitReason, type ResourceLimitReason } from "../checkpoint-store.js";
|
|
31
32
|
import { type WiringManifest } from "../wiring-manifest.js";
|
|
32
33
|
import type { ActiveWorktreeSession, AgentMessage, AgentTool, ExecutionEnv } from "../../internal/harness.js";
|
|
33
|
-
import type { NestedUsageAccum, RunnerDeps, TaskEvent, TaskResult, TaskSpec, ToolActivity, ToolEffect } from "../types.js";
|
|
34
|
+
import type { NestedUsageAccum, RemoteEnvFailureNote, RunnerDeps, TaskEvent, TaskResult, TaskSpec, ToolActivity, ToolEffect } from "../types.js";
|
|
34
35
|
import type { RepairBundle } from "../../agents/repair-loop.js";
|
|
35
36
|
/** Test seam (mirrors `__resetToolModelGateAnnouncements`): never called by production code.
|
|
36
37
|
* Re-arms BOTH arms (a WeakMap has no clear — it is re-minted). */
|
|
@@ -1121,7 +1122,8 @@ export interface PrepareResume {
|
|
|
1121
1122
|
* to restore — prepare rebuilds the per-task env via `deps.executionEnvFactory` then `resumeVM(snapshotId)`
|
|
1122
1123
|
* + `postResumeInit()` (instead of running on a fresh, empty env). Threaded HERE (not via `ResumeTaskConfig`)
|
|
1123
1124
|
* so the factory stays a deployment-level `RunnerDeps` capability and never pollutes `TaskSpec` — preserving
|
|
1124
|
-
* the "untrusted caller can't inject an env" red line (remote-env.
|
|
1125
|
+
* the "untrusted caller can't inject an env" red line ({@link import("../remote-env.js").ExecutionEnvFactory}'s
|
|
1126
|
+
* own contract states it: "Lives on `RunnerDeps` (deployment-level) — NOT on `TaskSpec`"; code-ready council round-2). */
|
|
1125
1127
|
workspaceHandle?: import("../remote-env.js").WorkspaceHandle;
|
|
1126
1128
|
/**
|
|
1127
1129
|
* design/174 — the call id of the CONTENT ask whose answer an operator's approval was spent on, when
|
|
@@ -1895,6 +1897,43 @@ export declare function batchContextAt(messages: AgentMessage[], currentId: stri
|
|
|
1895
1897
|
batchToolCallIds: string[];
|
|
1896
1898
|
completedCallIds: string[];
|
|
1897
1899
|
};
|
|
1900
|
+
/**
|
|
1901
|
+
* design/384 slice 2 — the ONE compensation for a paused-but-unparked VM, shared by the fence's
|
|
1902
|
+
* post-pause checkpoints (③ in the park closure, ④ in the saga) and the saga's put-failure absent
|
|
1903
|
+
* arm (previously inline there: same two hops, one implementation now, so the three sites cannot
|
|
1904
|
+
* drift). Restores the workspace (bounded transient retry) then re-establishes consistency
|
|
1905
|
+
* (`postResumeInit`), both hops under one INDEPENDENT `AbortSignal.timeout(io.boundMs)` —
|
|
1906
|
+
* deliberately NOT the run/cut signal: the remote contract answers an already-aborted signal
|
|
1907
|
+
* `{ok:false,"aborted"}`, so gating the restore on the very signal whose firing caused the
|
|
1908
|
+
* compensation made it die instantly and strand the paused VM on exactly the run-abort arm that
|
|
1909
|
+
* needs it most. The adapter signal is best-effort (a deaf adapter ignores it), so the caller's
|
|
1910
|
+
* await is ALSO raced against the same bound — bounded decision, three outcomes:
|
|
1911
|
+
* · settled ok ⇒ the VM is running again ({ok:true});
|
|
1912
|
+
* · settled not-ok / threw ⇒ recorded + disclosed, {ok:false} — the caller takes its fatal
|
|
1913
|
+
* fail-closed arm (abort the run; never continue on a paused VM);
|
|
1914
|
+
* · bound fires with the adapter still in flight ⇒ {ok:false} NOW, and the in-flight call
|
|
1915
|
+
* continues DETACHED + swallow-guarded with the late-settlement split:
|
|
1916
|
+
* – late SUCCESS: a running VM now exists with no run and no committed row to own it — the
|
|
1917
|
+
* detached continuation compensates the compensation with `destroy()` (the adapter's own
|
|
1918
|
+
* best-effort contract, swallow-guarded, disclosed);
|
|
1919
|
+
* – late FAILURE: disclosed; the VM is most likely still paused — provider-side TTL/GC
|
|
1920
|
+
* territory, and the disclosure is the end of this engine's obligation (a deaf adapter's
|
|
1921
|
+
* stranded VM is that adapter's own defect surface).
|
|
1922
|
+
* Decide-then-disclose throughout: `io.disclose`/`io.noteFailure` must be swallow-guarded by the
|
|
1923
|
+
* caller's binding, and nothing they do can change the returned verdict. Never throws. Exported for
|
|
1924
|
+
* direct unit pinning (the bounded/deaf/late arms need a small bound; production binds the
|
|
1925
|
+
* `PARK_COMPENSATION_TIMEOUT_MS` constant at the one call-site closure).
|
|
1926
|
+
*/
|
|
1927
|
+
export declare function compensateUnparkedPause(remoteEnv: RemoteExecutionEnv, snapshotId: SnapshotId, io: {
|
|
1928
|
+
boundMs: number;
|
|
1929
|
+
noteFailure: (note: RemoteEnvFailureNote) => void;
|
|
1930
|
+
disclose: (err: unknown) => void;
|
|
1931
|
+
}): Promise<{
|
|
1932
|
+
ok: true;
|
|
1933
|
+
} | {
|
|
1934
|
+
ok: false;
|
|
1935
|
+
reason: string;
|
|
1936
|
+
}>;
|
|
1898
1937
|
/**
|
|
1899
1938
|
* rescan C5 — the ONE spelling of the placement fields' empty-string discipline: `""` is absence
|
|
1900
1939
|
* wearing clothes (the resume entry's principal-rung posture), and every placement read that must
|