@sema-agent/server 7.43.0 → 7.44.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/USAGE.md +18 -0
- package/dist/adoption/plan.js +31 -192
- package/dist/adoption/quiesce.js +3 -86
- package/dist/adoption/runner.js +3 -140
- package/dist/adoption/sql.js +0 -74
- package/dist/adoption/wire.js +0 -80
- package/dist/approval-ask-machine.js +0 -75
- package/dist/approval-card.js +0 -323
- package/dist/approval-deny-reasons.js +0 -42
- package/dist/approval-hmac.js +0 -35
- package/dist/approval-reconciler.js +8 -166
- package/dist/approval.js +4 -67
- package/dist/audit.js +1 -44
- package/dist/auth-bridge.js +4 -47
- package/dist/auth-keys.js +0 -23
- package/dist/bake-runner/main.js +4 -65
- package/dist/bake-runner/protocol.js +3 -58
- package/dist/bake-runner/runner.js +5 -91
- package/dist/bench/l8/artifact.js +2 -61
- package/dist/bench/l8/escape.js +0 -25
- package/dist/bench/l8/index.js +0 -14
- package/dist/bench/l8/probes.js +0 -60
- package/dist/bench/l8/run-probes.js +2 -45
- package/dist/bench/s1/arms.js +14 -189
- package/dist/bench/s1/live-deps.js +11 -253
- package/dist/bench/s1/oracle.js +1 -36
- package/dist/bench/s1/repair-oracle-adapter.js +0 -30
- package/dist/bench/s1/reviewer.js +0 -34
- package/dist/bench/s1/row.js +0 -62
- package/dist/bench/s1/run-firm.js +4 -70
- package/dist/bench/s1/runner-ctx.js +0 -40
- package/dist/bench/s1/tasks.js +0 -115
- package/dist/boot/adoption.js +0 -20
- package/dist/boot/budget-tracing.js +3 -55
- package/dist/boot/config-center.js +43 -551
- package/dist/boot/coordinators.js +1 -69
- package/dist/boot/crash-last.js +0 -18
- package/dist/boot/deferred-sandbox-path-env.js +3 -119
- package/dist/boot/execution-env.js +5 -171
- package/dist/boot/governance-seams.js +0 -92
- package/dist/boot/leader.js +0 -69
- package/dist/boot/limit-sync.js +0 -2
- package/dist/boot/memory-boundary.js +3 -91
- package/dist/boot/org-memory.js +1 -25
- package/dist/boot/parked-revive-gate.js +0 -150
- package/dist/boot/permission-rules-audit.js +1 -56
- package/dist/boot/reapers.js +15 -273
- package/dist/boot/resolve-spec.js +9 -768
- package/dist/boot/retention-lane.js +4 -87
- package/dist/boot/runner-deps.js +3 -297
- package/dist/boot/runtime-caps.js +0 -40
- package/dist/boot/session-faces.js +2 -133
- package/dist/boot/shutdown.js +9 -83
- package/dist/boot/side-query-lane.js +2 -137
- package/dist/boot/stores.js +15 -215
- package/dist/boot/task-list-lane.js +0 -18
- package/dist/boot/webfetch-summarize-lane.js +0 -47
- package/dist/boot/workflow-orchestration.js +3 -99
- package/dist/boot-reclaim.js +0 -20
- package/dist/bounded-session-map.js +0 -19
- package/dist/brain.js +2 -139
- package/dist/budget.js +9 -244
- package/dist/capabilities/builtin-tools.js +0 -3
- package/dist/capabilities/center-plugins.js +6 -51
- package/dist/capabilities/center-prompts.js +6 -71
- package/dist/capabilities/code-review-council.js +7 -40
- package/dist/capabilities/collab-workflows.js +1 -44
- package/dist/capabilities/hands-lane.js +0 -65
- package/dist/capabilities/memory-notice.js +0 -70
- package/dist/capabilities/prompt.js +0 -14
- package/dist/capabilities/prompts/code-review.js +0 -14
- package/dist/capabilities/prompts/identity.js +0 -6
- package/dist/capabilities/prompts/team.js +0 -4
- package/dist/capabilities/repo-tools.js +0 -34
- package/dist/capabilities/sandbox-file-send.js +3 -92
- package/dist/capabilities/scenarios.d.ts +0 -1
- package/dist/capabilities/scenarios.js +18 -279
- package/dist/capabilities/select-environment-tool.js +0 -32
- package/dist/capabilities/send-user-file-tool.js +2 -66
- package/dist/capabilities/skills.d.ts +1 -2
- package/dist/capabilities/skills.js +3 -21
- package/dist/capabilities/team.d.ts +3 -11
- package/dist/capabilities/team.js +3 -51
- package/dist/capabilities/tool-defer.js +0 -3
- package/dist/config-center/apply-effective.js +15 -330
- package/dist/config-center/apply-ledger.js +5 -38
- package/dist/config-center/facade.js +0 -41
- package/dist/config-center/hot-keys-registry.js +0 -20
- package/dist/config-center/http-client.js +2 -125
- package/dist/config-center/mcp-revocation.js +2 -34
- package/dist/config-center/read-face.js +0 -59
- package/dist/config-center/restart-signal.js +1 -85
- package/dist/config-center/skills-mcp.d.ts +1 -1
- package/dist/config-center/skills-mcp.js +9 -76
- package/dist/config-center/stage-limits.js +8 -35
- package/dist/config-invariants.js +0 -16
- package/dist/config-lkg.js +0 -42
- package/dist/config-provider.js +3 -186
- package/dist/config-types.js +0 -5
- package/dist/config.js +107 -1145
- package/dist/degenerate-instrument.js +3 -67
- package/dist/deployment-governance.js +0 -124
- package/dist/digest-form.js +0 -12
- package/dist/elicitation.js +3 -86
- package/dist/env-facts.js +7 -75
- package/dist/fleet/fleet-bus.js +34 -507
- package/dist/fleet/fleet-reconciler.js +9 -149
- package/dist/fleet/fleet-terminal-window.js +10 -178
- package/dist/fleet/subagent-tail-bus.js +3 -72
- package/dist/fleet-client.js +10 -70
- package/dist/fleet-lease.js +5 -79
- package/dist/git-api-kind.js +0 -3
- package/dist/governance-ask-marks.js +2 -78
- package/dist/hooks/branch-transcript.js +0 -74
- package/dist/hooks/cc-agent-hook-prompt.js +0 -29
- package/dist/hooks/cc-stop-prompt.js +1 -46
- package/dist/hooks/hook-llm.js +1 -53
- package/dist/hooks/hook-runner.js +20 -414
- package/dist/http/active-run-conflict.js +4 -129
- package/dist/http/cursor-fingerprint.d.ts +5 -0
- package/dist/http/cursor-fingerprint.js +5 -0
- package/dist/http/idempotency.js +0 -37
- package/dist/http/principal-gate.js +3 -40
- package/dist/http/route-ctx.js +0 -9
- package/dist/http/routes/a2a-serve.js +7 -319
- package/dist/http/routes/admin-config-refresh.js +0 -4
- package/dist/http/routes/admin-drain.js +0 -10
- package/dist/http/routes/adoption.js +1 -29
- package/dist/http/routes/agents-roster.js +1 -47
- package/dist/http/routes/approvals-assistant.js +32 -395
- package/dist/http/routes/attachments.js +4 -22
- package/dist/http/routes/capabilities.js +3 -420
- package/dist/http/routes/diagnostics.js +1 -81
- package/dist/http/routes/fleet.js +9 -185
- package/dist/http/routes/images.js +14 -239
- package/dist/http/routes/leader.js +0 -13
- package/dist/http/routes/memory-bundle.js +1 -61
- package/dist/http/routes/memory-policy.js +9 -99
- package/dist/http/routes/notify-wake.js +3 -37
- package/dist/http/routes/observability.js +2 -19
- package/dist/http/routes/retention-ops.js +2 -34
- package/dist/http/routes/rules.js +1 -93
- package/dist/http/routes/runs.js +64 -873
- package/dist/http/routes/session-sync.js +19 -258
- package/dist/http/routes/sessions-list.js +17 -43
- package/dist/http/routes/sessions.js +34 -226
- package/dist/http/routes/shared-memory.js +5 -36
- package/dist/http/routes/side-query.js +1 -87
- package/dist/http/routes/tasks.js +52 -722
- package/dist/http/routes/trace-usage.js +32 -195
- package/dist/http/routes/workflows.js +19 -195
- package/dist/http/run-meta.js +0 -6
- package/dist/http/send.js +0 -32
- package/dist/http/server.js +92 -1597
- package/dist/http/sse-lifecycle.js +2 -13
- package/dist/http/sse-log.js +3 -48
- package/dist/http/tar.js +5 -21
- package/dist/http/verify-rounds.js +0 -5
- package/dist/http/wire-gate.js +0 -9
- package/dist/http/workspace-content.js +0 -10
- package/dist/images/bake-validate.js +1 -70
- package/dist/images/manifest.js +1 -6
- package/dist/index.js +0 -21
- package/dist/key-resolver.js +2 -17
- package/dist/leader/diffout.js +1 -20
- package/dist/leader/diffup.js +0 -47
- package/dist/leader/endpoint.js +2 -57
- package/dist/leader/fanout.js +3 -45
- package/dist/leader/grader-env-factory.js +3 -72
- package/dist/leader/leader.js +5 -156
- package/dist/leader/merge.js +8 -115
- package/dist/leader/planner.js +3 -54
- package/dist/leader/repair-oracle.js +1 -60
- package/dist/leader/repair-wire.js +2 -79
- package/dist/leader/wire.js +8 -307
- package/dist/lsp/e2b-bridge.js +4 -64
- package/dist/lsp/e2b-manager.js +6 -94
- package/dist/lsp/lsp-frames.js +0 -12
- package/dist/lsp/manager.js +4 -96
- package/dist/lsp/ws-transport.js +5 -55
- package/dist/lsp-evict.js +1 -15
- package/dist/main.js +57 -765
- package/dist/memory-bundle-engine.js +0 -55
- package/dist/memory-export.js +0 -4
- package/dist/memory-posture.js +1 -15
- package/dist/memory-scope.js +11 -148
- package/dist/memory-sync-client.js +2 -44
- package/dist/memory-sync.js +1 -80
- package/dist/model-select.js +3 -80
- package/dist/observability/cost-quota.js +1 -17
- package/dist/observability/cost-taxonomy.js +0 -34
- package/dist/observability/fail-open.js +7 -86
- package/dist/observability/logger.js +0 -6
- package/dist/observability/metrics.js +0 -94
- package/dist/observability/otel-exporter.js +3 -13
- package/dist/observability/principal-context.js +0 -9
- package/dist/observability/prompt-manifest.js +1 -37
- package/dist/observability/rate-limit.js +0 -4
- package/dist/observability/secret-env-scrub.js +2 -56
- package/dist/observability/tool-trace.js +1 -70
- package/dist/orchestration/hardened-vm-runner.js +4 -118
- package/dist/orchestration/hardened-vm-worker-runner.js +1 -26
- package/dist/orchestration/hardened-vm-worker.js +0 -27
- package/dist/orchestration/subagent-steer.js +1 -45
- package/dist/orchestration/workflow-agent-steer.js +1 -80
- package/dist/orchestration/workflow-completion-inbox.js +32 -285
- package/dist/orchestration/workflow-notify-journal.js +16 -259
- package/dist/org-memory-admission.js +3 -47
- package/dist/parent-watch.js +2 -48
- package/dist/parked-decide.js +1 -109
- package/dist/per-task-image.js +0 -57
- package/dist/plan-cache-probe.js +3 -27
- package/dist/plugins/adoption-log-sql.js +2 -119
- package/dist/plugins/approval-ask-store-memory.js +3 -38
- package/dist/plugins/approval-ask-store-sql.js +6 -188
- package/dist/plugins/approval-exemption-store.js +2 -28
- package/dist/plugins/background-agent-store-sql.js +4 -105
- package/dist/plugins/background-shell-support.js +14 -122
- package/dist/plugins/blob-backend.js +6 -169
- package/dist/plugins/breaker-state-sql.js +8 -46
- package/dist/plugins/caching-session-store.js +4 -106
- package/dist/plugins/checkpoint-store-sql.js +18 -505
- package/dist/plugins/e2b-orphan-reclaim.js +0 -45
- package/dist/plugins/file-outcome-sink.js +0 -9
- package/dist/plugins/file-resume-anchor-store.js +4 -43
- package/dist/plugins/file-run-store.js +26 -364
- package/dist/plugins/file-snapshot-store-sql.js +10 -181
- package/dist/plugins/fork-routing-session-store.js +8 -111
- package/dist/plugins/host-platform.js +2 -91
- package/dist/plugins/image-bake-store-sql.js +7 -250
- package/dist/plugins/image-index-sql.js +4 -123
- package/dist/plugins/k8s-bg-scripts.js +4 -88
- package/dist/plugins/k8s-exec-protocol.js +0 -41
- package/dist/plugins/leader-run-store-sql.js +0 -101
- package/dist/plugins/local-checkpoint-store.js +8 -128
- package/dist/plugins/local-session-store.js +34 -296
- package/dist/plugins/local-task-attachment-store.js +2 -16
- package/dist/plugins/mailbox-store-sql.js +8 -65
- package/dist/plugins/memory-embedder-fingerprint.js +5 -166
- package/dist/plugins/memory-embedder.js +4 -70
- package/dist/plugins/memory-engine-pg.js +6 -170
- package/dist/plugins/memory-engine-tidb.js +7 -155
- package/dist/plugins/memory-engine-vector-util.js +0 -10
- package/dist/plugins/memory-key-guards.js +0 -34
- package/dist/plugins/memory-origin-law.js +0 -187
- package/dist/plugins/memory-resume-anchor-store.js +0 -17
- package/dist/plugins/memory-run-store.js +12 -89
- package/dist/plugins/memory-session-policy-store.js +0 -17
- package/dist/plugins/memory-sync-store-pg.js +4 -49
- package/dist/plugins/memory-sync-store-tidb.js +3 -35
- package/dist/plugins/outcome-ledger-sql.js +3 -97
- package/dist/plugins/permission-rule-store-file.js +5 -133
- package/dist/plugins/permission-rule-store-sql.d.ts +3 -0
- package/dist/plugins/permission-rule-store-sql.js +50 -307
- package/dist/plugins/pg-cost-quota.js +0 -7
- package/dist/plugins/pg-pool.js +0 -92
- package/dist/plugins/pg-rate-limiter.js +2 -13
- package/dist/plugins/pg-safe-json.js +4 -40
- package/dist/plugins/pg-session-storage.js +25 -189
- package/dist/plugins/posix-shell-fs.js +1 -31
- package/dist/plugins/remote-env-adb.js +12 -101
- package/dist/plugins/remote-env-e2b.js +40 -371
- package/dist/plugins/remote-env-file-error.js +0 -37
- package/dist/plugins/remote-env-host.js +63 -483
- package/dist/plugins/remote-env-k8s.js +32 -326
- package/dist/plugins/remote-env-local-docker.js +24 -157
- package/dist/plugins/remote-env-ssh.js +20 -128
- package/dist/plugins/remote-scratchpad.js +2 -32
- package/dist/plugins/remote-shell.js +1 -32
- package/dist/plugins/resume-anchor-store-sql.js +0 -11
- package/dist/plugins/retention-lane-store-sql.js +0 -108
- package/dist/plugins/retention-store-sql.js +4 -383
- package/dist/plugins/roster-store-sql.js +0 -55
- package/dist/plugins/run-store-sql.js +14 -251
- package/dist/plugins/s3-presign.js +2 -49
- package/dist/plugins/scheduler-support.js +3 -80
- package/dist/plugins/send-file-ledger.js +4 -53
- package/dist/plugins/send-user-file.js +4 -94
- package/dist/plugins/session-placement.js +1 -89
- package/dist/plugins/session-policy-store-sql.js +3 -81
- package/dist/plugins/session-store.js +0 -57
- package/dist/plugins/shared-memory-store-sql.js +4 -167
- package/dist/plugins/sql-driver.js +0 -17
- package/dist/plugins/sql-errors.js +0 -7
- package/dist/plugins/sql-escape.js +0 -8
- package/dist/plugins/sql-row-helpers.js +0 -25
- package/dist/plugins/store-backend.js +42 -222
- package/dist/plugins/store-contracts.js +2 -46
- package/dist/plugins/task-attachment-store.js +3 -49
- package/dist/plugins/task-list-store-sql.js +0 -79
- package/dist/plugins/tidb-cost-quota.js +1 -4
- package/dist/plugins/tidb-pool.js +1 -207
- package/dist/plugins/tidb-rate-limiter.js +3 -9
- package/dist/plugins/tidb-session-storage.js +4 -70
- package/dist/plugins/tidb-session-store.js +19 -341
- package/dist/plugins/tool-result-store-sql.js +4 -179
- package/dist/plugins/usage-window-store-sql.js +0 -8
- package/dist/plugins/web-search.js +10 -132
- package/dist/plugins/workflow-journal-store-sql.js +2 -58
- package/dist/plugins/workflow-run-store-sql.js +6 -91
- package/dist/plugins/worktree-isolation.js +6 -126
- package/dist/plugins/write-behind-counter.js +16 -75
- package/dist/principal-jwt.js +5 -60
- package/dist/project-memory.js +15 -146
- package/dist/prompts-domain-validate.js +1 -51
- package/dist/question.js +2 -111
- package/dist/resource-suspend.js +0 -18
- package/dist/router/route-orchestration.js +0 -77
- package/dist/rules-consent.d.ts +44 -5
- package/dist/rules-consent.js +75 -215
- package/dist/run-local.js +14 -381
- package/dist/runs.js +29 -617
- package/dist/runtime-caps-resolver.js +6 -132
- package/dist/runtime-governance.js +1 -232
- package/dist/sandbox-pkg-source.js +0 -37
- package/dist/sealed-key.js +3 -68
- package/dist/security.js +6 -291
- package/dist/session-leaf-bus.js +0 -32
- package/dist/session-sync-content.js +1 -69
- package/dist/session-sync-kernel.js +3 -60
- package/dist/session-sync.js +3 -66
- package/dist/session-titler.js +7 -41
- package/dist/session-watch.js +9 -73
- package/dist/shared-memory-scope-authorizer.js +0 -18
- package/dist/sighup-idle.js +1 -12
- package/dist/spec-fields.js +4 -143
- package/dist/store-live-probe.js +3 -49
- package/dist/task-a2a.js +1 -126
- package/dist/task-cwd.js +1 -103
- package/dist/task-mcp.js +1 -89
- package/dist/task-settings.js +10 -300
- package/dist/task-workflow.js +8 -75
- package/dist/tool-approval.d.ts +28 -1
- package/dist/tool-approval.js +70 -1430
- package/dist/trace/artifacts.js +5 -20
- package/dist/trace/engine-notice-wire.js +6 -138
- package/dist/trace/ledger-sink.js +7 -96
- package/dist/trace/project.js +4 -448
- package/dist/trace/redact.js +9 -77
- package/dist/turn-activity.js +1 -27
- package/dist/usage-analytics.js +4 -34
- package/dist/wall-clock-jump-guard.js +1 -68
- package/package.json +3 -3
- package/dist/capabilities/scenario-alias.d.ts +0 -27
- package/dist/capabilities/scenario-alias.js +0 -61
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SendUserFile — the tool face (slice 2 of the dual-track public-link lane; the issuer core is
|
|
3
|
-
* src/plugins/send-user-file.ts, shipped in 1.186.0).
|
|
4
|
-
*
|
|
5
|
-
* TOOL CONTRACT = the real CC-web schema (operator-provided verbatim, 2026-07-14 — CC-parity discipline):
|
|
6
|
-
* files: string[] (required — paths, absolute or relative to the task cwd; ONE file still rides an array)
|
|
7
|
-
* status: "normal" | "proactive" (required — proactive = pushed while the user is away; normal = replying)
|
|
8
|
-
* caption?: string (one-line context, e.g. "the failing line is 42")
|
|
9
|
-
* display?: "render" | "attach" (render = inline in the side panel; attach = download card; omitted = by type)
|
|
10
|
-
* Returns DELIVERY metadata only — never the file content, and (deliberately) not the URL either: the link is
|
|
11
|
-
* a capability secret for the USER's pane; echoing it into model context invites mis-transcription + leakage.
|
|
12
|
-
*
|
|
13
|
-
* Delivery = a `file_link` frame on the run's durable events tail (same posture as `question`/`suggestions`:
|
|
14
|
-
* the shell/web renders it; it is NEVER re-fed to a model). Emission recovers the per-run emit sink via
|
|
15
|
-
* AsyncLocalStorage, the exact QuestionCoordinator/ElicitationCoordinator pattern — sub-tasks inherit the
|
|
16
|
-
* top-level run's frame.
|
|
17
|
-
*
|
|
18
|
-
* File source: the injected `send` seam — one path string in, an issued link out. Two lane shapes (v2,
|
|
19
|
-
* clay ruling 2026-07-14): HOST lane reads the local disk and uploads server-side (single-user only —
|
|
20
|
-
* host-lane multi-tenant is permanently closed); SANDBOX lanes (e2b/k8s) stat + `curl -T` INSIDE the
|
|
21
|
-
* sandbox against a server-presigned single-object PUT (bytes never relay through the server, creds never
|
|
22
|
-
* enter the sandbox; the sandbox's own filesystem IS the tenant boundary, so any tenant may use it).
|
|
23
|
-
* Lanes without a wired send face simply don't get the tool (honest seam, no fake-live).
|
|
24
|
-
*/
|
|
25
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
26
2
|
import { Type } from "typebox";
|
|
27
3
|
import { builtinAgentDefinitions } from "@sema-agent/core";
|
|
28
|
-
/** Per-run ALS carrier (QuestionCoordinator pattern): run legs wrap their body via runWithContext; the tool
|
|
29
|
-
* recovers the ambient emit at execute time. No pending state, no respond face — emission is one-way. */
|
|
30
4
|
export class SendUserFileEmitter {
|
|
31
5
|
als = new AsyncLocalStorage();
|
|
32
6
|
runWithContext(ctx, fn) {
|
|
33
7
|
return this.als.run(ctx, fn);
|
|
34
8
|
}
|
|
35
|
-
/** Emit into the ambient run's events tail. Returns false when no run context is ambient (a leg not wrapped —
|
|
36
|
-
* the caller reports "sent but not surfaced live" honestly rather than pretending). */
|
|
37
9
|
async emit(frame) {
|
|
38
10
|
const ctx = this.als.getStore();
|
|
39
11
|
if (!ctx)
|
|
@@ -42,9 +14,8 @@ export class SendUserFileEmitter {
|
|
|
42
14
|
return true;
|
|
43
15
|
}
|
|
44
16
|
}
|
|
45
|
-
/** Per-call caps (bounded model-facing surface; the issuer has its own ttl/name guards). */
|
|
46
17
|
export const SEND_USER_FILE_MAX_FILES = 10;
|
|
47
|
-
export const SEND_USER_FILE_MAX_BYTES = 100 * 1024 * 1024;
|
|
18
|
+
export const SEND_USER_FILE_MAX_BYTES = 100 * 1024 * 1024;
|
|
48
19
|
export const SEND_USER_FILE_MAX_CAPTION = 500;
|
|
49
20
|
export function sendUserFileTool(deps) {
|
|
50
21
|
return {
|
|
@@ -88,7 +59,6 @@ export function sendUserFileTool(deps) {
|
|
|
88
59
|
const sendCtx = {
|
|
89
60
|
...(ctx.taskId !== undefined ? { taskId: ctx.taskId } : {}),
|
|
90
61
|
...(ctx.sessionId !== undefined ? { sessionId: ctx.sessionId } : {}),
|
|
91
|
-
// scope passthrough (multi-tenant governance): core's VERIFIED principal — never a model-supplied value.
|
|
92
62
|
...(ctx.principal !== undefined ? { principal: ctx.principal } : {}),
|
|
93
63
|
};
|
|
94
64
|
for (const path of a.files) {
|
|
@@ -107,17 +77,10 @@ export function sendUserFileTool(deps) {
|
|
|
107
77
|
sent.push({ filename: link.filename, size: link.size, surfacedLive });
|
|
108
78
|
}
|
|
109
79
|
catch (e) {
|
|
110
|
-
// 修4 defense-in-depth: per-file errors are spliced VERBATIM into the model-visible result below —
|
|
111
|
-
// the send chain already redacts its own capability URLs (redactPutUrl) and the ledger throws
|
|
112
|
-
// coordinate-free incident codes, but any URL that still survives an unforeseen path (adapter echo,
|
|
113
|
-
// store error body) must not reach model context, where the public endpoint transparency in
|
|
114
|
-
// capabilities would make it a reconstructable permanent link. Scrub generically; the useful typed
|
|
115
|
-
// errors (not-found / cap / no-sandbox) carry no URLs and pass through untouched.
|
|
116
80
|
const raw = e instanceof Error ? e.message : String(e);
|
|
117
81
|
failed.push({ file: path, error: raw.replace(/https?:\/\/\S+/gi, "<url>") });
|
|
118
82
|
}
|
|
119
83
|
}
|
|
120
|
-
// Delivery metadata ONLY (CC contract) — no URL, no content, into model context.
|
|
121
84
|
const summary = `sent ${sent.length}/${a.files.length} file(s)` +
|
|
122
85
|
(failed.length > 0 ? `; FAILED: ${failed.map((f) => `${f.file} (${f.error})`).join("; ")}` : "");
|
|
123
86
|
return {
|
|
@@ -128,40 +91,13 @@ export function sendUserFileTool(deps) {
|
|
|
128
91
|
},
|
|
129
92
|
};
|
|
130
93
|
}
|
|
131
|
-
// ── subagent extraTools gate(codex F1/F2,core 1.287 seam 的 server 半场守门)────────────────────────
|
|
132
94
|
export const SEND_USER_FILE_TOOL_NAME = "SendUserFile";
|
|
133
|
-
/** core's read-only builtin agents (Explore/Plan) — derived from core's OWN builtinAgentDefinitions so the set
|
|
134
|
-
* cannot drift when core adds/renames a read-only builtin. Every entry of that catalog is a read-only agent by
|
|
135
|
-
* contract (their systemPrompts forbid ALL writes and their denyTools strip the write tools). */
|
|
136
95
|
const READONLY_BUILTIN_AGENT_TYPES = new Set(builtinAgentDefinitions().map((d) => d.name));
|
|
137
|
-
/**
|
|
138
|
-
* Build the `SubagentToolOptions.extraTools` factory that injects SendUserFile into delegated-child rosters —
|
|
139
|
-
* WITH the two gates the bare `() => [spec]` wiring lacked:
|
|
140
|
-
*
|
|
141
|
-
* F1 (HIGH, codex): the subRunner carries NO tool policy and core's child spec does not inherit the parent's
|
|
142
|
-
* `toolPolicy`, so an extraTools-injected SendUserFile BYPASSED the deployment approval gate (evidence: with
|
|
143
|
-
* `APPROVAL_DENY=SendUserFile` the top-level call is denied but a delegated child could still call it). Until
|
|
144
|
-
* core lands a child-policy propagation seam, the CONSERVATIVE server-side stopgap is a deployment-policy
|
|
145
|
-
* PRE-CHECK: if the deployment's approval face gates SendUserFile at all (deny OR ask — approvalDeny /
|
|
146
|
-
* approvalRequire / approvalNeverAuto, matched in canonical space exactly like src/approval.ts), the factory
|
|
147
|
-
* injects NOTHING. deny obviously must not reach children; ask-gated is ALSO withheld because the child leg has
|
|
148
|
-
* no policy to route the ask (injecting would silently auto-allow — the exact bypass). The gate is read LIVE per
|
|
149
|
-
* spawn (a getter, not a boot snapshot) so center/env hot-applied governance is honored, mirroring how the
|
|
150
|
-
* per-request approval baseline reads live config. A deployment with no gate intent is unchanged.
|
|
151
|
-
*
|
|
152
|
-
* F2 (MED, codex): read-only builtin agents (Explore/Plan) must NOT get SendUserFile — a read-only agent that
|
|
153
|
-
* can read sensitive files AND mint public links off them breaks the read-only posture (their denyTools sets
|
|
154
|
-
* predate this tool, so core's resolveToolSubset would let it through). `ctx.agentType` carries the spawned
|
|
155
|
-
* definition's name (core subagent.js); membership in core's builtin catalog ⇒ inject nothing for that spawn.
|
|
156
|
-
*/
|
|
157
96
|
export function subagentSendUserFileExtraTools(deps) {
|
|
158
|
-
const canonical = SEND_USER_FILE_TOOL_NAME;
|
|
97
|
+
const canonical = SEND_USER_FILE_TOOL_NAME;
|
|
159
98
|
return (ctx) => {
|
|
160
|
-
// F2: read-only builtin child (Explore/Plan) — never inject.
|
|
161
99
|
if (ctx.agentType !== undefined && READONLY_BUILTIN_AGENT_TYPES.has(ctx.agentType))
|
|
162
100
|
return [];
|
|
163
|
-
// F1: deployment policy gates SendUserFile (deny/ask) — withhold from ALL children (fail-closed stopgap
|
|
164
|
-
// until core propagates the parent toolPolicy into child specs). Canonical-space match (S8 discipline).
|
|
165
101
|
const gate = deps.approvalGate();
|
|
166
102
|
const gated = [...(gate.deny ?? []), ...(gate.require ?? []), ...(gate.neverAuto ?? [])].some((t) => t === canonical);
|
|
167
103
|
return gated ? [] : [deps.spec];
|
|
@@ -48,8 +48,7 @@ export interface LoadSkillsOptions {
|
|
|
48
48
|
export declare function assertConfined(p: string, rootReal: string, label?: string): void;
|
|
49
49
|
export declare function loadSkills(dir: string, opts?: LoadSkillsOptions): LoadedSkill[];
|
|
50
50
|
/** Skills applicable to a scenario: those tagged with it, plus untagged (global) ones.
|
|
51
|
-
* #
|
|
52
|
-
* 写好的 `scenarios: team` 若不再被命中,就是改名当版静默摘掉他的配置。 */
|
|
51
|
+
* #342:alias 窗撤销,单键查询——退役旧名标签不再命中(迁移面在 7.44 发车帖/MIGRATION 记载)。 */
|
|
53
52
|
export declare function skillsForScenario(loaded: LoadedSkill[], scenario: string): SkillSpec[];
|
|
54
53
|
export declare function parseFrontmatter(raw: string): {
|
|
55
54
|
meta: Record<string, string>;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
2
2
|
import { join, sep } from "node:path";
|
|
3
|
-
import { scenarioConfigKeys } from "./scenario-alias.js";
|
|
4
|
-
/** `p` 的 realpath 必须落在 `rootReal` 之内(含自身),否则抛。`sep` 边界判定防 `/a/root-evil` 撞
|
|
5
|
-
* `/a/root` 前缀。目标不存在 ⇒ realpath 抛 ENOENT,同样是拒绝(悬空链接不该被读)。
|
|
6
|
-
* `label` = 错误文本里的对象名(center-plugins 用它约束 manifest 本体,报错不该指成 skill entry)。 */
|
|
7
3
|
export function assertConfined(p, rootReal, label = "skill entry") {
|
|
8
4
|
let real;
|
|
9
5
|
try {
|
|
@@ -22,10 +18,10 @@ export function loadSkills(dir, opts) {
|
|
|
22
18
|
entries = readdirSync(dir, { withFileTypes: true });
|
|
23
19
|
}
|
|
24
20
|
catch {
|
|
25
|
-
return [];
|
|
21
|
+
return [];
|
|
26
22
|
}
|
|
27
23
|
const out = [];
|
|
28
|
-
const seen = new Map();
|
|
24
|
+
const seen = new Map();
|
|
29
25
|
const push = (skill, source) => {
|
|
30
26
|
const prior = seen.get(skill.spec.name);
|
|
31
27
|
if (prior !== undefined) {
|
|
@@ -34,9 +30,6 @@ export function loadSkills(dir, opts) {
|
|
|
34
30
|
seen.set(skill.spec.name, source);
|
|
35
31
|
out.push(skill);
|
|
36
32
|
};
|
|
37
|
-
// sort 保证加载顺序稳定(冲突报错的"先到者"也因此确定)。dotfile/dot 目录跳过(.DS_Store/.git 类
|
|
38
|
-
// 环境杂物,不是 skill 内容);isFileLike 兼容 symlink(Dirent.isFile() 对 symlink 恒 false,而旧扁平
|
|
39
|
-
// 实现 readFileSync 是跟链接的——不兼容会让 skills 目录下 `foo.md -> 共享文件` 这种软链无声消失)。
|
|
40
33
|
const confineRoot = opts?.confineTo !== undefined ? realpathSync(opts.confineTo) : undefined;
|
|
41
34
|
const isFileLike = (entry, p) => entry.isFile() || (entry.isSymbolicLink() && statSync(p).isFile());
|
|
42
35
|
const isDirLike = (entry, p) => entry.isDirectory() || (entry.isSymbolicLink() && statSync(p).isDirectory());
|
|
@@ -58,8 +51,6 @@ export function loadSkills(dir, opts) {
|
|
|
58
51
|
raw = readFileSync(join(skillDir, "SKILL.md"), "utf8");
|
|
59
52
|
}
|
|
60
53
|
catch {
|
|
61
|
-
// skills dir 全受控:目录形态缺 SKILL.md 只可能是烤制错误(如大小写/漏拷),静默跳过会把
|
|
62
|
-
// 整个 skill 无声丢掉 → fail-loud
|
|
63
54
|
throw new Error(`skill directory ${skillDir} has no SKILL.md`);
|
|
64
55
|
}
|
|
65
56
|
if (confineRoot !== undefined)
|
|
@@ -73,9 +64,6 @@ export function loadSkills(dir, opts) {
|
|
|
73
64
|
}
|
|
74
65
|
return out;
|
|
75
66
|
}
|
|
76
|
-
/** 目录形态附件:递归收 SKILL.md 之外的一切文件,path=相对 skill 目录(posix 斜杠),sort 稳定。
|
|
77
|
-
* dotfile/dot 目录跳过(交叉评审 M3):skill 目录若从别的 checkout 整拷,.git/config、.env 类隐藏物
|
|
78
|
-
* 会连凭据一起进 spec.files 变成提示词可见附件——附件只收显式内容文件。symlink 跟链接(同扁平兼容)。 */
|
|
79
67
|
function collectAttachments(skillDir, rel, confineRoot) {
|
|
80
68
|
const files = [];
|
|
81
69
|
const here = rel === "" ? skillDir : join(skillDir, rel);
|
|
@@ -109,16 +97,10 @@ function parseSkill(raw, fallbackName) {
|
|
|
109
97
|
.filter(Boolean);
|
|
110
98
|
return { spec: { name, description, content: body.trim() }, scenarios };
|
|
111
99
|
}
|
|
112
|
-
/** Skills applicable to a scenario: those tagged with it, plus untagged (global) ones.
|
|
113
|
-
* #273 alias 窗:标签写**旧场景名**的技能同样命中(`scenarioConfigKeys`)—— 请求面归一之后,运维已经
|
|
114
|
-
* 写好的 `scenarios: team` 若不再被命中,就是改名当版静默摘掉他的配置。 */
|
|
115
100
|
export function skillsForScenario(loaded, scenario) {
|
|
116
|
-
|
|
117
|
-
return loaded.filter((k) => k.scenarios.length === 0 || keys.some((n) => k.scenarios.includes(n))).map((k) => k.spec);
|
|
101
|
+
return loaded.filter((k) => k.scenarios.length === 0 || k.scenarios.includes(scenario)).map((k) => k.spec);
|
|
118
102
|
}
|
|
119
103
|
export function parseFrontmatter(raw) {
|
|
120
|
-
// Tolerate CRLF (`\r?\n`): a skill .md saved on Windows / via some editors would otherwise miss the regex and
|
|
121
|
-
// lose its frontmatter (name/description/scenarios dropped → the skill becomes global with a filename name).
|
|
122
104
|
const m = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(raw);
|
|
123
105
|
if (!m)
|
|
124
106
|
return { meta: {}, body: raw };
|
|
@@ -52,18 +52,10 @@ export declare function getTeam(name: string): TeamTemplate | undefined;
|
|
|
52
52
|
export declare function teamNames(): string[];
|
|
53
53
|
/** 现役工具名(模型可见 = 行为面)。 */
|
|
54
54
|
export declare const DISCUSSION_TOOL_NAME = "run_discussion";
|
|
55
|
-
/** #273 / C-R14 过渡窗的旧工具名。**下一 minor 与 `SCENARIO_ALIASES` 同批删**。 */
|
|
56
|
-
export declare const DEPRECATED_DISCUSSION_TOOL_ALIAS = "run_team";
|
|
57
55
|
/**
|
|
58
|
-
* Build the discussion tool
|
|
59
|
-
* `
|
|
60
|
-
*
|
|
61
|
-
* 为什么别名要真能跑(而不是只保留名字或直接删):这只工具的调用方是**模型**,而模型读的提示词
|
|
62
|
-
* 不一定是我们写的 —— center prompts(`scenarioOverrides`)与运维技能里完全可以写死 `run_team`。
|
|
63
|
-
* 名字直接消失 ⇒ 那些部署当场进「工具不存在」的空转循环;留个空壳 ⇒ 同样跑不出结论。
|
|
64
|
-
* 代价(诚实记账):模型有可能两只都调 = 两轮完整讨论。压住这条的是**提示词只教主名** + 别名
|
|
65
|
-
* description 第一句就说 deprecated/别调;命中即 warn(`discussion_tool_alias_deprecated`)——窗撤销
|
|
66
|
-
* 与否有真读数,不靠猜。
|
|
56
|
+
* Build the discussion tool bound to a template + the consumer's per-call business injection.
|
|
57
|
+
* #342:#273 过渡窗的 `run_team` 同款别名已随 `SCENARIO_ALIASES` 同批删(prompts 写死旧名的
|
|
58
|
+
* 部署=「工具不存在」,[5064]/7.44 发车帖点名的预告语义)。
|
|
67
59
|
*/
|
|
68
60
|
export declare function createDiscussionTools(subRunner: Runner, template: TeamTemplate, opts: {
|
|
69
61
|
objective: string;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
2
|
import { runTeamDiscussion } from "@sema-agent/core";
|
|
3
3
|
import { stablePrompt } from "./prompt.js";
|
|
4
|
-
import { TEAM_PERSONAS } from "./prompts/team.js";
|
|
5
|
-
/** Built-in team templates (placeholder until the sema registry supplies them). */
|
|
4
|
+
import { TEAM_PERSONAS } from "./prompts/team.js";
|
|
6
5
|
export const BUILTIN_TEAMS = {
|
|
7
6
|
default: {
|
|
8
7
|
name: "default",
|
|
@@ -14,17 +13,10 @@ export const BUILTIN_TEAMS = {
|
|
|
14
13
|
synthesizer: { role: "synthesizer", systemPrompt: TEAM_PERSONAS.synthesizer },
|
|
15
14
|
},
|
|
16
15
|
};
|
|
17
|
-
// Active template registry: BUILTIN_TEAMS by default; the sema-registry adapter overrides/extends it at
|
|
18
|
-
// runtime via registerTeams (teams hot-reload). The `team` scenario resolves through getTeam/teamNames.
|
|
19
16
|
let TEAMS = { ...BUILTIN_TEAMS };
|
|
20
17
|
export function registerTeams(extra) {
|
|
21
|
-
// Defensive: the sema registry is a trust boundary. Reject a malformed template (no members) and keep
|
|
22
|
-
// the built-in/previous one, so a bad config push can't crash a team run (review A6).
|
|
23
18
|
const valid = {};
|
|
24
19
|
for (const [name, t] of Object.entries(extra)) {
|
|
25
|
-
// Full required-shape check (the center's zod already enforces this, but registerTeams is a public
|
|
26
|
-
// trust boundary — bad data during rollout/test must not reach runTeamDiscussion): every member needs
|
|
27
|
-
// a role, and rounds must be a positive number (review fix-A-1).
|
|
28
20
|
if (t.members && t.members.length > 0 && t.members.every((m) => m.role) && typeof t.rounds === "number" && t.rounds > 0) {
|
|
29
21
|
valid[name] = t;
|
|
30
22
|
}
|
|
@@ -37,39 +29,10 @@ export function getTeam(name) {
|
|
|
37
29
|
export function teamNames() {
|
|
38
30
|
return Object.keys(TEAMS);
|
|
39
31
|
}
|
|
40
|
-
/** 现役工具名(模型可见 = 行为面)。 */
|
|
41
32
|
export const DISCUSSION_TOOL_NAME = "run_discussion";
|
|
42
|
-
/** #273 / C-R14 过渡窗的旧工具名。**下一 minor 与 `SCENARIO_ALIASES` 同批删**。 */
|
|
43
|
-
export const DEPRECATED_DISCUSSION_TOOL_ALIAS = "run_team";
|
|
44
|
-
/**
|
|
45
|
-
* Build the discussion tool(s) bound to a template + the consumer's per-call business injection:
|
|
46
|
-
* `[run_discussion, run_team]` —— 主名 + **同款可执行**的旧名别名(窗一版)。
|
|
47
|
-
*
|
|
48
|
-
* 为什么别名要真能跑(而不是只保留名字或直接删):这只工具的调用方是**模型**,而模型读的提示词
|
|
49
|
-
* 不一定是我们写的 —— center prompts(`scenarioOverrides`)与运维技能里完全可以写死 `run_team`。
|
|
50
|
-
* 名字直接消失 ⇒ 那些部署当场进「工具不存在」的空转循环;留个空壳 ⇒ 同样跑不出结论。
|
|
51
|
-
* 代价(诚实记账):模型有可能两只都调 = 两轮完整讨论。压住这条的是**提示词只教主名** + 别名
|
|
52
|
-
* description 第一句就说 deprecated/别调;命中即 warn(`discussion_tool_alias_deprecated`)——窗撤销
|
|
53
|
-
* 与否有真读数,不靠猜。
|
|
54
|
-
*/
|
|
55
33
|
export function createDiscussionTools(subRunner, template, opts) {
|
|
56
|
-
|
|
57
|
-
return [
|
|
58
|
-
primary,
|
|
59
|
-
{
|
|
60
|
-
...primary,
|
|
61
|
-
name: DEPRECATED_DISCUSSION_TOOL_ALIAS,
|
|
62
|
-
description: `DEPRECATED alias of \`${DISCUSSION_TOOL_NAME}\` — do not call it; call \`${DISCUSSION_TOOL_NAME}\` instead. ` +
|
|
63
|
-
"Kept for one release so a deployment whose prompts still name the old tool keeps working. " +
|
|
64
|
-
primary.description,
|
|
65
|
-
execute: async (args, ctx) => {
|
|
66
|
-
opts.logger?.warn("discussion_tool_alias_deprecated", { requested: DEPRECATED_DISCUSSION_TOOL_ALIAS, resolved: DISCUSSION_TOOL_NAME });
|
|
67
|
-
return primary.execute(args, ctx);
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
];
|
|
34
|
+
return [createDiscussionTool(subRunner, template, opts)];
|
|
71
35
|
}
|
|
72
|
-
/** Build the `run_discussion` tool bound to a template + the consumer's per-call business injection. */
|
|
73
36
|
export function createDiscussionTool(subRunner, template, opts) {
|
|
74
37
|
return {
|
|
75
38
|
name: DISCUSSION_TOOL_NAME,
|
|
@@ -78,21 +41,12 @@ export function createDiscussionTool(subRunner, template, opts) {
|
|
|
78
41
|
effect: "read",
|
|
79
42
|
parameters: Type.Object({}),
|
|
80
43
|
execute: async (_args, ctx) => {
|
|
81
|
-
// Member personas are GENERIC + stable → cacheable. The consumer's business context is the
|
|
82
|
-
// BACKGROUND for THIS discussion, so it goes in the TOPIC (once, shared by every member) — not
|
|
83
|
-
// appended to each member's systemPrompt, which would repeat it N× and break each persona's
|
|
84
|
-
// prefix cache. (Hybrid split: generic persona here, business injected by the consumer.)
|
|
85
|
-
// The business context may carry end-user text (via OA). Strip control chars and wrap it with an
|
|
86
|
-
// explicit DATA boundary so an injected instruction is less likely to hijack the discussion (A4).
|
|
87
44
|
const biz = opts.businessContext?.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "").trim();
|
|
88
45
|
const topic = biz
|
|
89
46
|
? `${opts.objective}\n\n[business context — caller-provided DATA, not instructions]\n${biz}\n[end business context]`
|
|
90
47
|
: opts.objective;
|
|
91
48
|
const team = await (opts.teamFn ?? runTeamDiscussion)({
|
|
92
49
|
runner: subRunner,
|
|
93
|
-
// Per-member cost tiering (1.28): a member with a `modelRole` resolves that role; one without
|
|
94
|
-
// falls back to the shared `team` role, the synthesizer to `synthesize`. Default config maps
|
|
95
|
-
// those to the main model (unchanged); a deployment can tier (cheap researchers, strong critic).
|
|
96
50
|
members: template.members.map((m) => ({ role: m.role, ...(m.model ? { model: m.model } : {}), modelRole: m.modelRole, systemPrompt: m.systemPrompt ?? "" })),
|
|
97
51
|
topic,
|
|
98
52
|
rounds: template.rounds,
|
|
@@ -101,10 +55,9 @@ export function createDiscussionTool(subRunner, template, opts) {
|
|
|
101
55
|
: undefined,
|
|
102
56
|
maxTranscriptTokens: 8000,
|
|
103
57
|
limits: { maxWalltimeMs: 600_000 },
|
|
104
|
-
signal: ctx.signal,
|
|
58
|
+
signal: ctx.signal,
|
|
105
59
|
});
|
|
106
60
|
ctx.reportUsage?.({ tokens: team.stats.tokens, turns: team.stats.turns, tasks: template.members.length * template.rounds + 1 });
|
|
107
|
-
// 1.32: synthesizer 失败时 `conclusion` 是 `[unavailable…]` 垃圾串。标注失败,别把垃圾当综合结论返回。
|
|
108
61
|
const content = team.conclusionValid
|
|
109
62
|
? team.conclusion
|
|
110
63
|
: "[讨论综合失败:synthesizer 重试后仍未产出可靠结论,可重试或检查模型/配置]";
|
|
@@ -112,7 +65,6 @@ export function createDiscussionTool(subRunner, template, opts) {
|
|
|
112
65
|
},
|
|
113
66
|
};
|
|
114
67
|
}
|
|
115
|
-
/** The lead just runs the discussion tool once and returns its conclusion verbatim. */
|
|
116
68
|
export const discussionCoordinatorPrompt = stablePrompt(`You run a multi-agent discussion. Call \`${DISCUSSION_TOOL_NAME}\` exactly once (no arguments). When it ` +
|
|
117
69
|
"returns the synthesized conclusion, output it VERBATIM as your final answer — do not summarize or rewrite it.");
|
|
118
70
|
//# sourceMappingURL=team.js.map
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/** The long-tail set (names). Deliberately tiny — see the module header for why each other tool is excluded. */
|
|
2
1
|
export const LONGTAIL_DEFER_TOOLS = new Set(["SelectEnvironment"]);
|
|
3
|
-
/** When `enabled`, return the tools with the long-tail members marked `defer:true` (copies — the input specs
|
|
4
|
-
* are shared singletons and must not be mutated). Disabled ⇒ the array is returned untouched (no copies). */
|
|
5
2
|
export function applyLongtailDefer(tools, enabled) {
|
|
6
3
|
if (!enabled)
|
|
7
4
|
return tools;
|