@opengeni/worker-bundle 2.0.1 → 2.0.2-canary.38686408778001
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/activities/agent-run-admission.d.ts +1 -12
- package/dist/activities/agent-turn/admission.d.ts +88 -10
- package/dist/activities/agent-turn/agent-build.d.ts +14 -3
- package/dist/activities/agent-turn/claim.d.ts +4 -1
- package/dist/activities/agent-turn/claude-core.d.ts +195 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +3 -0
- package/dist/activities/agent-turn/codex-core-capacity.d.ts +37 -0
- package/dist/activities/agent-turn/codex-core-claim.d.ts +40 -0
- package/dist/activities/agent-turn/codex-core-errors.d.ts +102 -0
- package/dist/activities/agent-turn/codex-core-failover.d.ts +15 -0
- package/dist/activities/agent-turn/codex-core-requests.d.ts +28 -0
- package/dist/activities/agent-turn/codex-core-settlement.d.ts +77 -0
- package/dist/activities/agent-turn/codex-credit-policy.d.ts +30 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex-usage-policy.d.ts +2 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -19
- package/dist/activities/agent-turn/compaction-interruption.d.ts +32 -0
- package/dist/activities/agent-turn/compaction-prep.d.ts +30 -1
- package/dist/activities/agent-turn/credential-leases.d.ts +64 -37
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +172 -28
- package/dist/activities/agent-turn/failure-settlement.d.ts +10 -43
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +7 -2
- package/dist/activities/agent-turn/finalization.d.ts +2 -0
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +13 -1
- package/dist/activities/agent-turn/history-sink.d.ts +3 -1
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +76 -0
- package/dist/activities/agent-turn/meaningful-output.d.ts +9 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +56 -14
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/prompt-tool-availability.d.ts +17 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/provider-recovery-copy.d.ts +24 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/provider-recovery-policy.d.ts +6 -0
- package/dist/activities/agent-turn/quiescence.d.ts +6 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +6 -5
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +9 -5
- package/dist/activities/agent-turn/run.d.ts +27 -2
- package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -0
- package/dist/activities/agent-turn/sandbox-provision.d.ts +25 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
- package/dist/activities/agent-turn/secret-resolver.d.ts +64 -0
- package/dist/activities/agent-turn/session-title.d.ts +60 -3
- package/dist/activities/agent-turn/session-usage-custody.d.ts +66 -0
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-search.d.ts +2 -0
- package/dist/activities/agent-turn/skill-tools.d.ts +41 -4
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +6 -3
- package/dist/activities/agent-turn/subscription-capacity-arming.d.ts +41 -0
- package/dist/activities/agent-turn/subscription-core-capacity.d.ts +86 -0
- package/dist/activities/agent-turn/subscription-core-failover.d.ts +69 -0
- package/dist/activities/agent-turn/subscription-core-placed.d.ts +14 -0
- package/dist/activities/agent-turn/subscription-core-requests.d.ts +109 -0
- package/dist/activities/agent-turn/subscription-core-settlement.d.ts +112 -0
- package/dist/activities/agent-turn/subscription-lease.d.ts +44 -0
- package/dist/activities/agent-turn/subscription-serving-capacity.d.ts +6 -0
- package/dist/activities/agent-turn/subscription-serving-catalog.d.ts +13 -0
- package/dist/activities/agent-turn/subscription-serving-claim.d.ts +30 -0
- package/dist/activities/agent-turn/subscription-serving-providers.d.ts +2 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +30 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +55 -3
- package/dist/activities/agent-turn/turn-context.d.ts +104 -5
- package/dist/activities/agent-turn/web-search.d.ts +57 -0
- package/dist/activities/agent-turn/xai-core.d.ts +96 -0
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +34 -0
- package/dist/activities/capabilities.d.ts +8 -20
- package/dist/activities/codemode-dispatcher.d.ts +20 -3
- package/dist/activities/codex-capacity.d.ts +1 -56
- package/dist/activities/codex-image-generation.d.ts +49 -3
- package/dist/activities/common.d.ts +3 -1
- package/dist/activities/context-compaction.d.ts +41 -2
- package/dist/activities/environment.d.ts +1 -19
- package/dist/activities/gmail-files.d.ts +50 -0
- package/dist/activities/goals.d.ts +1 -9
- package/dist/activities/incident-telemetry-authority.d.ts +5 -2
- package/dist/activities/incident-telemetry-preflight.d.ts +10 -3
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +2 -21
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +15 -0
- package/dist/activities/parent-wake.d.ts +17 -12
- package/dist/activities/programmatic-approvals.d.ts +10 -0
- package/dist/activities/requester-unavailable-receipt.d.ts +8 -0
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +16 -4
- package/dist/activities/run-input.d.ts +17 -0
- package/dist/activities/sandbox-lease.d.ts +132 -12
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-archive.d.ts +58 -0
- package/dist/activities/session-state.d.ts +15 -3
- package/dist/activities/session-storage.d.ts +44 -0
- package/dist/activities/subscription-core-claude-waits.d.ts +2 -0
- package/dist/activities/subscription-core-codex-quota.d.ts +25 -0
- package/dist/activities/subscription-core-codex-waits.d.ts +153 -0
- package/dist/activities/subscription-core-image-operation.d.ts +29 -0
- package/dist/activities/subscription-core-usage-recheck.d.ts +49 -0
- package/dist/activities/subscription-core-wait-bindings.d.ts +3 -0
- package/dist/activities/subscription-core-xai-quota.d.ts +30 -0
- package/dist/activities/subscription-core-xai-waits.d.ts +2 -0
- package/dist/activities/types.d.ts +68 -5
- package/dist/activities/video-generation-admission.d.ts +2 -8
- package/dist/activities/video-generation-credential.d.ts +15 -12
- package/dist/activities/video-generation-subscription-core.d.ts +70 -0
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +47 -0
- package/dist/activities/xai-auth.d.ts +6 -18
- package/dist/activities/xai-image-generation.d.ts +22 -6
- package/dist/{activities-control-QA6OLRQY.js → activities-control-NTXZHYET.js} +1552 -2876
- package/dist/activities-control-NTXZHYET.js.map +1 -0
- package/dist/activities-control.d.ts +64 -4
- package/dist/{activities-turn-YVVKCGAK.js → activities-turn-RKRI5GY4.js} +9238 -4392
- package/dist/activities-turn-RKRI5GY4.js.map +1 -0
- package/dist/activities.d.ts +64 -4
- package/dist/artifact-materializer-entry.js +104 -35
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +132 -61
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-GDCLDKSH.js → chunk-24GP3BX5.js} +79 -72
- package/dist/chunk-24GP3BX5.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-I7HKKMUJ.js → chunk-5NNS4327.js} +734 -58
- package/dist/chunk-5NNS4327.js.map +1 -0
- package/dist/{chunk-M3NVMF2V.js → chunk-7BIHFUGB.js} +2293 -3956
- package/dist/chunk-7BIHFUGB.js.map +1 -0
- package/dist/chunk-MVESOYFC.js +3746 -0
- package/dist/chunk-MVESOYFC.js.map +1 -0
- package/dist/chunk-NQDVJ6RI.js +2823 -0
- package/dist/chunk-NQDVJ6RI.js.map +1 -0
- package/dist/chunk-O7UPBWXK.js +79 -0
- package/dist/chunk-O7UPBWXK.js.map +1 -0
- package/dist/chunk-W2QSM5HR.js +414 -0
- package/dist/chunk-W2QSM5HR.js.map +1 -0
- package/dist/chunk-ZN3XJR33.js +227 -0
- package/dist/chunk-ZN3XJR33.js.map +1 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +12 -1
- package/dist/editable-artifact-outbox-service.d.ts +3 -1
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +2 -2
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +49 -48
- package/dist/index.js +835 -256
- package/dist/index.js.map +1 -1
- package/dist/internal-maintenance.d.ts +63 -0
- package/dist/maintenance-cadence.d.ts +43 -0
- package/dist/observability-metrics.d.ts +293 -24
- package/dist/onepassword-vault-provider.d.ts +7 -0
- package/dist/parent-wake-PCLH7A3Y.js +24 -0
- package/dist/parent-wake-PCLH7A3Y.js.map +1 -0
- package/dist/personal-github-git-credentials.d.ts +1 -1
- package/dist/readiness-checks.d.ts +39 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-lease-BJYU72N3.js +84 -0
- package/dist/sandbox-lease-BJYU72N3.js.map +1 -0
- package/dist/sandbox-reaper-contract.d.ts +25 -0
- package/dist/sandbox-resume.d.ts +72 -4
- package/dist/sandbox-routing.d.ts +4 -2
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js +12 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js.map +1 -0
- package/dist/telemetry-scheduler.d.ts +14 -0
- package/dist/temporal-runtime-logger.d.ts +22 -0
- package/dist/turn-task-queue-reader.d.ts +18 -0
- package/dist/turn-worker-activity-telemetry.d.ts +47 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +468 -71
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +10 -0
- package/dist/workflows/sandbox-reaper.d.ts +10 -1
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session-storage.d.ts +2 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows/site-auth-maintenance.d.ts +2 -1
- package/dist/workflows/workflow-wake.d.ts +14 -3
- package/dist/workflows.d.ts +3 -1
- package/package.json +26 -20
- package/src/activities/agent-run-admission.ts +1 -82
- package/src/activities/agent-turn/admission.ts +175 -24
- package/src/activities/agent-turn/agent-build.ts +226 -145
- package/src/activities/agent-turn/claim.ts +363 -64
- package/src/activities/agent-turn/claude-core.ts +587 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +30 -757
- package/src/activities/agent-turn/codex-core-capacity.ts +190 -0
- package/src/activities/agent-turn/codex-core-claim.ts +83 -0
- package/src/activities/agent-turn/codex-core-errors.ts +308 -0
- package/src/activities/agent-turn/codex-core-failover.ts +73 -0
- package/src/activities/agent-turn/codex-core-requests.ts +86 -0
- package/src/activities/agent-turn/codex-core-settlement.ts +263 -0
- package/src/activities/agent-turn/codex-credit-policy.ts +247 -0
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex-usage-policy.ts +2 -0
- package/src/activities/agent-turn/codex.ts +8 -76
- package/src/activities/agent-turn/compaction-interruption.ts +56 -0
- package/src/activities/agent-turn/compaction-prep.ts +249 -36
- package/src/activities/agent-turn/credential-leases.ts +269 -214
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +1134 -82
- package/src/activities/agent-turn/failure-settlement.ts +879 -886
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +17 -5
- package/src/activities/agent-turn/finalization.ts +107 -88
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +90 -22
- package/src/activities/agent-turn/history-sink.ts +26 -4
- package/src/activities/agent-turn/history.ts +25 -5
- package/src/activities/agent-turn/input-wait-reply.ts +139 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/meaningful-output.ts +44 -0
- package/src/activities/agent-turn/media-artifacts.ts +3 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +299 -233
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/prompt-tool-availability.ts +27 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/provider-recovery-copy.ts +76 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/provider-recovery-policy.ts +25 -0
- package/src/activities/agent-turn/quiescence.ts +7 -7
- package/src/activities/agent-turn/recovery-warning.ts +6 -8
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +124 -76
- package/src/activities/agent-turn/run.ts +501 -112
- package/src/activities/agent-turn/sandbox-establish.ts +152 -75
- package/src/activities/agent-turn/sandbox-provision.ts +54 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -1
- package/src/activities/agent-turn/sandbox-runtime.ts +319 -11
- package/src/activities/agent-turn/secret-resolver.ts +155 -0
- package/src/activities/agent-turn/session-title.ts +177 -12
- package/src/activities/agent-turn/session-usage-custody.ts +170 -0
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-save.ts +35 -7
- package/src/activities/agent-turn/skill-search.ts +9 -0
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +208 -21
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +599 -110
- package/src/activities/agent-turn/subscription-capacity-arming.ts +81 -0
- package/src/activities/agent-turn/subscription-core-capacity.ts +439 -0
- package/src/activities/agent-turn/subscription-core-failover.ts +229 -0
- package/src/activities/agent-turn/subscription-core-placed.ts +37 -0
- package/src/activities/agent-turn/subscription-core-requests.ts +271 -0
- package/src/activities/agent-turn/subscription-core-settlement.ts +234 -0
- package/src/activities/agent-turn/subscription-lease.ts +140 -0
- package/src/activities/agent-turn/subscription-serving-capacity.ts +195 -0
- package/src/activities/agent-turn/subscription-serving-catalog.ts +71 -0
- package/src/activities/agent-turn/subscription-serving-claim.ts +178 -0
- package/src/activities/agent-turn/subscription-serving-providers.ts +15 -0
- package/src/activities/agent-turn/tool-environment.ts +384 -292
- package/src/activities/agent-turn/tool-policy.ts +104 -4
- package/src/activities/agent-turn/tool-result-spill.ts +1 -0
- package/src/activities/agent-turn/turn-context.ts +124 -8
- package/src/activities/agent-turn/web-search.ts +431 -0
- package/src/activities/agent-turn/xai-core.ts +301 -0
- package/src/activities/automations.ts +81 -6
- package/src/activities/browser-deadline-checkpoint.ts +297 -0
- package/src/activities/capabilities.ts +53 -213
- package/src/activities/codemode-dispatcher.ts +236 -14
- package/src/activities/codex-capacity.ts +27 -380
- package/src/activities/codex-image-generation.ts +252 -42
- package/src/activities/common.ts +12 -0
- package/src/activities/connector-attachments.ts +3 -1
- package/src/activities/context-compaction.ts +162 -21
- package/src/activities/environment.ts +18 -106
- package/src/activities/gmail-files.ts +108 -0
- package/src/activities/goals.ts +120 -204
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/incident-telemetry-authority.ts +80 -50
- package/src/activities/incident-telemetry-preflight.ts +27 -15
- package/src/activities/knowledge-indexing.ts +287 -17
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +2 -124
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +122 -88
- package/src/activities/parent-wake.ts +89 -21
- package/src/activities/programmatic-approvals.ts +26 -0
- package/src/activities/requester-unavailable-receipt.ts +14 -0
- package/src/activities/retained-screenshots.ts +135 -24
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +61 -19
- package/src/activities/run-input.ts +116 -9
- package/src/activities/sandbox-lease.ts +1615 -73
- package/src/activities/scheduled-tasks.ts +758 -141
- package/src/activities/session-archive.ts +382 -0
- package/src/activities/session-state.ts +219 -10
- package/src/activities/session-storage.ts +124 -0
- package/src/activities/site-auth-maintenance.ts +5 -2
- package/src/activities/subscription-core-claude-waits.ts +49 -0
- package/src/activities/subscription-core-codex-quota.ts +46 -0
- package/src/activities/subscription-core-codex-waits.ts +488 -0
- package/src/activities/subscription-core-image-operation.ts +126 -0
- package/src/activities/subscription-core-usage-recheck.ts +146 -0
- package/src/activities/subscription-core-wait-bindings.ts +12 -0
- package/src/activities/subscription-core-xai-quota.ts +85 -0
- package/src/activities/subscription-core-xai-waits.ts +48 -0
- package/src/activities/types.ts +85 -9
- package/src/activities/video-generation-admission.ts +1 -36
- package/src/activities/video-generation-credential.ts +38 -56
- package/src/activities/video-generation-reconciliation.ts +150 -131
- package/src/activities/video-generation-subscription-core.ts +180 -0
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +302 -0
- package/src/activities/xai-auth.ts +34 -112
- package/src/activities/xai-image-generation.ts +84 -36
- package/src/activities-control.ts +8 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +17 -0
- package/src/activity-services.ts +29 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +79 -38
- package/src/editable-artifact-materializer-subprocess.ts +47 -2
- package/src/editable-artifact-outbox-dispatcher.ts +107 -46
- package/src/editable-artifact-outbox-service.ts +55 -25
- package/src/github-rest-mcp.ts +1 -1
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +4 -1
- package/src/http.ts +4 -2
- package/src/index.ts +222 -282
- package/src/internal-maintenance.ts +347 -0
- package/src/maintenance-cadence.ts +156 -0
- package/src/observability-metrics.ts +1173 -73
- package/src/onepassword-vault-provider.ts +11 -0
- package/src/personal-github-git-credentials.ts +3 -1
- package/src/pr-review-credentials.ts +1 -1
- package/src/readiness-checks.ts +113 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-reaper-contract.ts +33 -0
- package/src/sandbox-resume.ts +444 -73
- package/src/sandbox-routing.ts +230 -75
- package/src/session-event-fanout.ts +23 -0
- package/src/telemetry-scheduler.ts +53 -0
- package/src/temporal-runtime-logger.ts +44 -0
- package/src/turn-task-queue-reader.ts +110 -0
- package/src/turn-worker-activity-telemetry.ts +209 -0
- package/src/worker-service-lifecycle.ts +54 -1
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +55 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/sandbox-reaper.ts +88 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session-storage.ts +19 -0
- package/src/workflows/session.ts +238 -33
- package/src/workflows/site-auth-maintenance.ts +2 -1
- package/src/workflows/workflow-wake.ts +26 -4
- package/src/workflows.ts +7 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +0 -2
- package/dist/activities/codex-fleet-shadow.d.ts +0 -74
- package/dist/activities/codex-rotation.d.ts +0 -200
- package/dist/activities/xai-quota.d.ts +0 -3
- package/dist/activities-control-QA6OLRQY.js.map +0 -1
- package/dist/activities-turn-YVVKCGAK.js.map +0 -1
- package/dist/chunk-GDCLDKSH.js.map +0 -1
- package/dist/chunk-I7HKKMUJ.js.map +0 -1
- package/dist/chunk-M3NVMF2V.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/xai-capacity.ts +0 -257
- package/src/activities/codex-fleet-shadow.ts +0 -306
- package/src/activities/codex-rotation.ts +0 -685
- package/src/activities/xai-quota.ts +0 -35
|
@@ -1,26 +1,183 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { boundModelToolOutputItem } from "@opengeni/codex";
|
|
2
|
+
import type { AttemptToolDefinition, AttemptToolExecutionContext } from "@opengeni/codemode";
|
|
3
|
+
import {
|
|
4
|
+
SKILL_USE_META_KEY,
|
|
5
|
+
SkillUse,
|
|
6
|
+
type AttemptToolResult,
|
|
7
|
+
type SkillReadKind,
|
|
8
|
+
type SkillUseSource,
|
|
9
|
+
} from "@opengeni/contracts";
|
|
10
|
+
import { modelToolResultFits } from "@opengeni/runtime";
|
|
2
11
|
import {
|
|
3
12
|
listSkillPaths,
|
|
4
13
|
PORTABLE_SKILL_MAX_FILES,
|
|
5
14
|
readSkillFiles,
|
|
15
|
+
skillScriptIndex,
|
|
6
16
|
SKILL_READ_MAX_PATHS,
|
|
7
17
|
type SkillTextFile,
|
|
8
18
|
} from "@opengeni/runtime/skill-library";
|
|
9
19
|
|
|
10
20
|
export const SKILL_READ_TOOL_NAME = "skill_read";
|
|
11
21
|
|
|
22
|
+
type JsonValue = NonNullable<AttemptToolResult["_meta"]>[string];
|
|
23
|
+
|
|
24
|
+
/** Content-free provenance of a resolved Skill. The caller never receives it. */
|
|
25
|
+
export type SkillReadOrigin = Readonly<{
|
|
26
|
+
id: string;
|
|
27
|
+
source: SkillUseSource;
|
|
28
|
+
/** Platform display label of a built-in; never user-authored text. */
|
|
29
|
+
label?: string;
|
|
30
|
+
/** Whole-artifact digest, for an artifact without a ledger revision. */
|
|
31
|
+
contentSha256?: string;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
12
34
|
export type SkillReadContent = Readonly<{
|
|
13
35
|
files: readonly SkillTextFile[];
|
|
14
36
|
skillId: string;
|
|
15
37
|
revisionId: string;
|
|
16
38
|
scopeVersion: number;
|
|
17
39
|
installationVersion?: number;
|
|
40
|
+
origin?: SkillReadOrigin;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
/** A selected built-in or session artifact: no ledger identity, and none is synthesized. */
|
|
44
|
+
export type SelectedSkillReadContent = Readonly<{
|
|
45
|
+
files: readonly SkillTextFile[];
|
|
46
|
+
origin: SkillReadOrigin;
|
|
47
|
+
}>;
|
|
48
|
+
|
|
49
|
+
type SkillReadIdentity = Partial<
|
|
50
|
+
Pick<SkillReadContent, "skillId" | "revisionId" | "scopeVersion" | "installationVersion">
|
|
51
|
+
>;
|
|
52
|
+
|
|
53
|
+
export type SkillReadObservation = Readonly<{
|
|
54
|
+
caller: AttemptToolExecutionContext["caller"]["kind"];
|
|
55
|
+
kind: SkillReadKind;
|
|
56
|
+
/** Null when the read was refused before a Skill resolved. */
|
|
57
|
+
source: SkillUseSource | null;
|
|
58
|
+
/** The resolved Skill id, or the requested identifier when none resolved. */
|
|
59
|
+
skill: string;
|
|
60
|
+
}>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Content-free read telemetry. It never changes what the caller receives: a
|
|
64
|
+
* model result gains only MCP `_meta`, which the model never sees and which
|
|
65
|
+
* only the tool-output event projection keeps.
|
|
66
|
+
*/
|
|
67
|
+
export type SkillReadTelemetry = Readonly<{
|
|
68
|
+
/** Ids in the Skill index the model sees this turn; null until known. */
|
|
69
|
+
indexedSkillIds: () => ReadonlySet<string> | null;
|
|
70
|
+
/** Whether skill_search returned this id earlier in this turn attempt. */
|
|
71
|
+
searched: (id: string) => boolean;
|
|
72
|
+
observe: (observation: SkillReadObservation) => void;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
export type SkillReadActiveHistory = Readonly<{
|
|
76
|
+
/** Earlier skill_read results still in this session's active model history. */
|
|
77
|
+
readResults: () => Promise<ReadonlyArray<Record<string, unknown>>>;
|
|
78
|
+
/**
|
|
79
|
+
* This turn's model tool-output bound. Rows are bounded when stored, but a
|
|
80
|
+
* later model with a lower bound receives a shorter copy than the row holds.
|
|
81
|
+
*/
|
|
82
|
+
toolOutputTruncationTokens: () => number;
|
|
83
|
+
/** The lookup only saves tokens, so a failure returns the full text. */
|
|
84
|
+
onLookupFailed?: (error: unknown) => void;
|
|
18
85
|
}>;
|
|
19
86
|
|
|
87
|
+
const IDENTITY_KEYS = ["skillId", "revisionId", "scopeVersion", "installationVersion"] as const;
|
|
88
|
+
|
|
89
|
+
export const SKILL_UNAVAILABLE_MESSAGE = "Skill is not available in this session.";
|
|
90
|
+
/** Bounds on the Skill list an unresolved identifier returns. */
|
|
91
|
+
export const SKILL_UNAVAILABLE_LIST_MAX_ENTRIES = 25;
|
|
92
|
+
export const SKILL_UNAVAILABLE_LIST_MAX_BYTES = 4 * 1024;
|
|
93
|
+
// A shorter shared edge is chance: random hex ids share 1-3 leading characters often.
|
|
94
|
+
const MIN_RESEMBLANCE = 4;
|
|
95
|
+
|
|
96
|
+
export type AvailableSkill = Readonly<{ id: string; name: string }>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The error for an identifier that resolves to no Skill. It lists available
|
|
100
|
+
* Skills by id and name only, the descriptors the Skill index and skill_search
|
|
101
|
+
* already show the model, so the caller can retry instead of rediscovering
|
|
102
|
+
* the work from scratch. Entries resembling the requested identifier (shared
|
|
103
|
+
* prefix, suffix, or containment) come first, so a mistyped or spliced id
|
|
104
|
+
* keeps its likely targets inside the bound. The requested identifier is
|
|
105
|
+
* never echoed.
|
|
106
|
+
*/
|
|
107
|
+
export function unavailableSkillError(
|
|
108
|
+
requested: string,
|
|
109
|
+
available: readonly AvailableSkill[],
|
|
110
|
+
): Error {
|
|
111
|
+
const byId = new Map<string, AvailableSkill>();
|
|
112
|
+
for (const entry of available) if (!byId.has(entry.id)) byId.set(entry.id, entry);
|
|
113
|
+
const wanted = requested.toLowerCase();
|
|
114
|
+
const ranked = [...byId.values()]
|
|
115
|
+
.map((entry) => ({ entry, score: resemblance(wanted, entry) }))
|
|
116
|
+
.sort(
|
|
117
|
+
(a, b) =>
|
|
118
|
+
b.score - a.score || compare(a.entry.name, b.entry.name) || compare(a.entry.id, b.entry.id),
|
|
119
|
+
);
|
|
120
|
+
const header = [
|
|
121
|
+
SKILL_UNAVAILABLE_MESSAGE,
|
|
122
|
+
...(wanted.startsWith("repository:")
|
|
123
|
+
? ["Repository Skills are read with repository_skill_read."]
|
|
124
|
+
: []),
|
|
125
|
+
ranked.length === 0
|
|
126
|
+
? "No configured Skills are available in this session."
|
|
127
|
+
: "Retry with an exact id from these available Skills:",
|
|
128
|
+
].join("\n");
|
|
129
|
+
const lines = [header];
|
|
130
|
+
// Reserve room for the omission notice so the whole message stays bounded.
|
|
131
|
+
const budget = SKILL_UNAVAILABLE_LIST_MAX_BYTES - 128;
|
|
132
|
+
let bytes = Buffer.byteLength(header, "utf8");
|
|
133
|
+
let listed = 0;
|
|
134
|
+
for (const { entry } of ranked) {
|
|
135
|
+
const line = `- ${JSON.stringify({ id: entry.id, name: entry.name })}`;
|
|
136
|
+
const lineBytes = Buffer.byteLength(line, "utf8") + 1;
|
|
137
|
+
if (listed >= SKILL_UNAVAILABLE_LIST_MAX_ENTRIES || bytes + lineBytes > budget) continue;
|
|
138
|
+
lines.push(line);
|
|
139
|
+
bytes += lineBytes;
|
|
140
|
+
listed += 1;
|
|
141
|
+
}
|
|
142
|
+
const omitted = ranked.length - listed;
|
|
143
|
+
if (omitted > 0)
|
|
144
|
+
lines.push(`${omitted} more available Skills are not listed. Use skill_search to find them.`);
|
|
145
|
+
return new Error(lines.join("\n"));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function resemblance(wanted: string, entry: AvailableSkill): number {
|
|
149
|
+
let best = 0;
|
|
150
|
+
for (const key of [entry.id.toLowerCase(), entry.name.toLowerCase()]) {
|
|
151
|
+
const contained =
|
|
152
|
+
wanted.includes(key) || key.includes(wanted) ? Math.min(wanted.length, key.length) : 0;
|
|
153
|
+
let prefix = 0;
|
|
154
|
+
while (prefix < wanted.length && prefix < key.length && wanted[prefix] === key[prefix])
|
|
155
|
+
prefix += 1;
|
|
156
|
+
let suffix = 0;
|
|
157
|
+
while (
|
|
158
|
+
suffix < wanted.length &&
|
|
159
|
+
suffix < key.length &&
|
|
160
|
+
wanted[wanted.length - 1 - suffix] === key[key.length - 1 - suffix]
|
|
161
|
+
)
|
|
162
|
+
suffix += 1;
|
|
163
|
+
best = Math.max(best, contained, prefix, suffix);
|
|
164
|
+
}
|
|
165
|
+
return best >= MIN_RESEMBLANCE ? best : 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function compare(left: string, right: string): number {
|
|
169
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
20
172
|
/** A first-party gateway definition, not a sandbox capability or second backend. */
|
|
21
173
|
export function createSkillReadAttemptToolDefinition(input: {
|
|
22
174
|
authorize: () => Promise<void>;
|
|
23
|
-
load: (
|
|
175
|
+
load: (
|
|
176
|
+
skill: string,
|
|
177
|
+
) => Promise<readonly SkillTextFile[] | SkillReadContent | SelectedSkillReadContent>;
|
|
178
|
+
/** Without it every read returns full text. */
|
|
179
|
+
activeHistory?: SkillReadActiveHistory;
|
|
180
|
+
telemetry?: SkillReadTelemetry;
|
|
24
181
|
}): AttemptToolDefinition {
|
|
25
182
|
return {
|
|
26
183
|
identity: { serverId: "opengeni", toolName: SKILL_READ_TOOL_NAME },
|
|
@@ -54,7 +211,7 @@ export function createSkillReadAttemptToolDefinition(input: {
|
|
|
54
211
|
},
|
|
55
212
|
source: "opengeni",
|
|
56
213
|
approval: "none",
|
|
57
|
-
execute: async (args) => {
|
|
214
|
+
execute: async (args, context) => {
|
|
58
215
|
if (
|
|
59
216
|
typeof args.skill !== "string" ||
|
|
60
217
|
!args.skill ||
|
|
@@ -68,31 +225,220 @@ export function createSkillReadAttemptToolDefinition(input: {
|
|
|
68
225
|
throw new Error("skill_read listFiles:true cannot be combined with paths.");
|
|
69
226
|
}
|
|
70
227
|
await input.authorize();
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
228
|
+
const skill = args.skill;
|
|
229
|
+
let origin: SkillReadOrigin | undefined;
|
|
230
|
+
let identity: SkillReadIdentity = {};
|
|
231
|
+
let read: { kind: Exclude<SkillReadKind, "refused">; result: AttemptToolResult };
|
|
232
|
+
try {
|
|
233
|
+
const loaded = await input.load(skill);
|
|
234
|
+
const content = "files" in loaded ? loaded : { files: loaded };
|
|
235
|
+
origin = "origin" in content ? content.origin : undefined;
|
|
236
|
+
if ("skillId" in content) {
|
|
237
|
+
identity = {
|
|
238
|
+
skillId: content.skillId,
|
|
239
|
+
revisionId: content.revisionId,
|
|
240
|
+
scopeVersion: content.scopeVersion,
|
|
241
|
+
...(content.installationVersion !== undefined
|
|
242
|
+
? { installationVersion: content.installationVersion }
|
|
243
|
+
: {}),
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
read = await readResult(
|
|
247
|
+
content.files,
|
|
248
|
+
identity,
|
|
249
|
+
args as { skill: string; listFiles?: boolean; paths?: string[] },
|
|
250
|
+
context,
|
|
251
|
+
input.activeHistory,
|
|
252
|
+
);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
observe(input.telemetry, { caller: context.caller.kind, kind: "refused", origin, skill });
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
observe(input.telemetry, { caller: context.caller.kind, kind: read.kind, origin, skill });
|
|
258
|
+
return context.caller.kind === "model" && origin && input.telemetry
|
|
259
|
+
? withSkillUse(read, origin, identity, input.telemetry)
|
|
260
|
+
: read.result;
|
|
96
261
|
},
|
|
97
262
|
};
|
|
98
263
|
}
|
|
264
|
+
|
|
265
|
+
async function readResult(
|
|
266
|
+
files: readonly SkillTextFile[],
|
|
267
|
+
identity: SkillReadIdentity,
|
|
268
|
+
args: { skill: string; listFiles?: boolean; paths?: string[] },
|
|
269
|
+
context: AttemptToolExecutionContext,
|
|
270
|
+
activeHistory: SkillReadActiveHistory | undefined,
|
|
271
|
+
): Promise<{ kind: Exclude<SkillReadKind, "refused">; result: AttemptToolResult }> {
|
|
272
|
+
if (args.listFiles === true) {
|
|
273
|
+
return {
|
|
274
|
+
kind: "list",
|
|
275
|
+
result: textResult({ ...identity, ...listSkillPaths(files, PORTABLE_SKILL_MAX_FILES) }),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const selected = readSkillFiles(files, args.paths);
|
|
279
|
+
// Only the model's default SKILL.md read is deduplicated: explicit paths
|
|
280
|
+
// are the fresh-copy request, and a Codemode program never sees history.
|
|
281
|
+
if (
|
|
282
|
+
args.paths === undefined &&
|
|
283
|
+
context.caller.kind === "model" &&
|
|
284
|
+
activeHistory &&
|
|
285
|
+
(await inActiveHistory(activeHistory, identity, selected.files[0]!))
|
|
286
|
+
) {
|
|
287
|
+
return {
|
|
288
|
+
kind: "already_in_context",
|
|
289
|
+
result: textResult({
|
|
290
|
+
...identity,
|
|
291
|
+
alreadyInContext: true,
|
|
292
|
+
message: `Already in context: SKILL.md of ${JSON.stringify(args.skill)}${identity.revisionId ? ` revision ${identity.revisionId}` : ""} was returned earlier in this conversation and is unchanged. Use that copy. Re-read only if you need a fresh copy: call skill_read with paths ["SKILL.md"].`,
|
|
293
|
+
}),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (args.paths !== undefined) {
|
|
297
|
+
return { kind: "files", result: textResult({ ...identity, ...selected }) };
|
|
298
|
+
}
|
|
299
|
+
// The default read also indexes runnable files (path and first usage line)
|
|
300
|
+
// so the commands are visible without a sandbox checkout.
|
|
301
|
+
const scripts = skillScriptIndex(files);
|
|
302
|
+
return {
|
|
303
|
+
kind: "full",
|
|
304
|
+
result: textResult({ ...identity, ...selected, ...(scripts ?? {}) }),
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Telemetry must never change or fail a read. */
|
|
309
|
+
function observe(
|
|
310
|
+
telemetry: SkillReadTelemetry | undefined,
|
|
311
|
+
read: {
|
|
312
|
+
caller: SkillReadObservation["caller"];
|
|
313
|
+
kind: SkillReadKind;
|
|
314
|
+
origin: SkillReadOrigin | undefined;
|
|
315
|
+
skill: string;
|
|
316
|
+
},
|
|
317
|
+
): void {
|
|
318
|
+
if (!telemetry) return;
|
|
319
|
+
try {
|
|
320
|
+
telemetry.observe({
|
|
321
|
+
caller: read.caller,
|
|
322
|
+
kind: read.kind,
|
|
323
|
+
source: read.origin?.source ?? null,
|
|
324
|
+
skill: read.origin?.id ?? read.skill,
|
|
325
|
+
});
|
|
326
|
+
} catch {
|
|
327
|
+
// Metrics are best effort.
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Adds the content-free Skill-use fact as MCP `_meta`. The model output is
|
|
333
|
+
* the text part alone, so it stays byte-identical. The fact is dropped
|
|
334
|
+
* rather than let it push a result past the model-visible size cap, which
|
|
335
|
+
* would change what the model receives.
|
|
336
|
+
*/
|
|
337
|
+
function withSkillUse(
|
|
338
|
+
read: { kind: Exclude<SkillReadKind, "refused">; result: AttemptToolResult },
|
|
339
|
+
origin: SkillReadOrigin,
|
|
340
|
+
identity: SkillReadIdentity,
|
|
341
|
+
telemetry: SkillReadTelemetry,
|
|
342
|
+
): AttemptToolResult {
|
|
343
|
+
try {
|
|
344
|
+
const text = read.result.content[0]?.type === "text" ? read.result.content[0].text : "";
|
|
345
|
+
// Parsing rejects anything outside the closed, content-free shape.
|
|
346
|
+
const use = SkillUse.parse({
|
|
347
|
+
id: origin.id,
|
|
348
|
+
source: origin.source,
|
|
349
|
+
...(origin.label ? { label: origin.label } : {}),
|
|
350
|
+
...(identity.revisionId
|
|
351
|
+
? { revisionId: identity.revisionId }
|
|
352
|
+
: origin.contentSha256
|
|
353
|
+
? { contentSha256: origin.contentSha256 }
|
|
354
|
+
: {}),
|
|
355
|
+
kind: read.kind,
|
|
356
|
+
bytes: Buffer.byteLength(text, "utf8"),
|
|
357
|
+
inIndex: telemetry.indexedSkillIds()?.has(origin.id) ?? false,
|
|
358
|
+
searchedThisTurn: telemetry.searched(origin.id),
|
|
359
|
+
});
|
|
360
|
+
const annotated: AttemptToolResult = {
|
|
361
|
+
...read.result,
|
|
362
|
+
_meta: { ...read.result._meta, [SKILL_USE_META_KEY]: use as JsonValue },
|
|
363
|
+
};
|
|
364
|
+
return modelToolResultFits(annotated) ? annotated : read.result;
|
|
365
|
+
} catch {
|
|
366
|
+
return read.result;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function textResult(
|
|
371
|
+
output: NonNullable<AttemptToolResult["structuredContent"]>,
|
|
372
|
+
): AttemptToolResult {
|
|
373
|
+
return {
|
|
374
|
+
isError: false,
|
|
375
|
+
content: [{ type: "text", text: JSON.stringify(output) }],
|
|
376
|
+
structuredContent: output,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async function inActiveHistory(
|
|
381
|
+
history: SkillReadActiveHistory,
|
|
382
|
+
identity: SkillReadIdentity,
|
|
383
|
+
file: SkillTextFile,
|
|
384
|
+
): Promise<boolean> {
|
|
385
|
+
let results: ReadonlyArray<Record<string, unknown>>;
|
|
386
|
+
try {
|
|
387
|
+
results = await history.readResults();
|
|
388
|
+
} catch (error) {
|
|
389
|
+
history.onLookupFailed?.(error);
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
const tokens = history.toolOutputTruncationTokens();
|
|
393
|
+
// Judge the copy this turn's model receives, not the stored row.
|
|
394
|
+
return results.some((item) =>
|
|
395
|
+
returnedFile(boundModelToolOutputItem(item, tokens), identity, file),
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* True when an earlier result gave the model this exact file text under the
|
|
401
|
+
* same Skill identity. A truncated, spilled, or failed result does not parse
|
|
402
|
+
* as a Skill read, so it never counts.
|
|
403
|
+
*/
|
|
404
|
+
function returnedFile(
|
|
405
|
+
item: Record<string, unknown>,
|
|
406
|
+
identity: SkillReadIdentity,
|
|
407
|
+
file: SkillTextFile,
|
|
408
|
+
): boolean {
|
|
409
|
+
const text = resultText(item.output);
|
|
410
|
+
if (text === null) return false;
|
|
411
|
+
let previous: unknown;
|
|
412
|
+
try {
|
|
413
|
+
previous = JSON.parse(text);
|
|
414
|
+
} catch {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
if (!previous || typeof previous !== "object" || Array.isArray(previous)) return false;
|
|
418
|
+
const record = previous as Record<string, unknown>;
|
|
419
|
+
return (
|
|
420
|
+
IDENTITY_KEYS.every((key) => record[key] === identity[key]) &&
|
|
421
|
+
Array.isArray(record.files) &&
|
|
422
|
+
record.files.some(
|
|
423
|
+
(candidate: unknown) =>
|
|
424
|
+
!!candidate &&
|
|
425
|
+
typeof candidate === "object" &&
|
|
426
|
+
(candidate as SkillTextFile).path === file.path &&
|
|
427
|
+
(candidate as SkillTextFile).content === file.content,
|
|
428
|
+
)
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/** The single text part of a function result, in any SDK output shape. */
|
|
433
|
+
function resultText(output: unknown): string | null {
|
|
434
|
+
if (typeof output === "string") return output;
|
|
435
|
+
const parts = Array.isArray(output) ? output : [output];
|
|
436
|
+
if (parts.length !== 1) return null;
|
|
437
|
+
const part = parts[0] as { type?: unknown; text?: unknown } | null;
|
|
438
|
+
return part &&
|
|
439
|
+
typeof part === "object" &&
|
|
440
|
+
(part.type === "text" || part.type === "input_text") &&
|
|
441
|
+
typeof part.text === "string"
|
|
442
|
+
? part.text
|
|
443
|
+
: null;
|
|
444
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import {
|
|
3
4
|
applySkillFileChanges,
|
|
4
5
|
buildPortableSkillArtifact,
|
|
@@ -23,6 +24,27 @@ export type SkillSaveReceipt = {
|
|
|
23
24
|
replayed: boolean;
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
const skillSaveArguments = z
|
|
28
|
+
.object({
|
|
29
|
+
operationId: z.uuid(),
|
|
30
|
+
skillId: z.uuid(),
|
|
31
|
+
expectedRevisionId: z.uuid().nullable(),
|
|
32
|
+
expectedScopeVersion: z.number().int().nonnegative(),
|
|
33
|
+
files: z
|
|
34
|
+
.array(
|
|
35
|
+
z
|
|
36
|
+
.object({
|
|
37
|
+
path: z.string().min(1).max(1024),
|
|
38
|
+
content: z.string(),
|
|
39
|
+
})
|
|
40
|
+
.strict(),
|
|
41
|
+
)
|
|
42
|
+
.max(PORTABLE_SKILL_MAX_FILES),
|
|
43
|
+
deletions: z.array(z.string().min(1).max(1024)).max(PORTABLE_SKILL_MAX_FILES).optional(),
|
|
44
|
+
reason: z.string().min(1).max(2000),
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
47
|
+
|
|
26
48
|
/** Persistence owns mode enforcement, replay, and the final compare-and-swap. */
|
|
27
49
|
export function createSkillSaveAttemptToolDefinition(input: {
|
|
28
50
|
authorize: () => Promise<void>;
|
|
@@ -91,8 +113,14 @@ export function createSkillSaveAttemptToolDefinition(input: {
|
|
|
91
113
|
approval: "none",
|
|
92
114
|
execute: async (args) => {
|
|
93
115
|
await input.authorize();
|
|
94
|
-
|
|
95
|
-
|
|
116
|
+
// Some model calls stringify JSON null. Normalize only this nullable
|
|
117
|
+
// creation sentinel, then validate before any revision lookup or write.
|
|
118
|
+
// Missing, empty and malformed IDs must not silently become creation.
|
|
119
|
+
const request = skillSaveArguments.parse({
|
|
120
|
+
...args,
|
|
121
|
+
expectedRevisionId: args.expectedRevisionId === "null" ? null : args.expectedRevisionId,
|
|
122
|
+
});
|
|
123
|
+
const { skillId, expectedRevisionId } = request;
|
|
96
124
|
// Expand the edit against its immutable base, not today's head. The
|
|
97
125
|
// lifecycle can then replay an already committed operation before CAS.
|
|
98
126
|
const current =
|
|
@@ -102,17 +130,17 @@ export function createSkillSaveAttemptToolDefinition(input: {
|
|
|
102
130
|
}
|
|
103
131
|
const files = applySkillFileChanges(
|
|
104
132
|
current?.files ?? [],
|
|
105
|
-
|
|
106
|
-
|
|
133
|
+
request.files,
|
|
134
|
+
request.deletions ?? [],
|
|
107
135
|
);
|
|
108
136
|
const artifact = buildPortableSkillArtifact(files);
|
|
109
137
|
const output = await input.save({
|
|
110
|
-
operationId:
|
|
138
|
+
operationId: request.operationId,
|
|
111
139
|
skillId,
|
|
112
140
|
expectedRevisionId,
|
|
113
|
-
expectedScopeVersion:
|
|
141
|
+
expectedScopeVersion: request.expectedScopeVersion,
|
|
114
142
|
files: artifact.files,
|
|
115
|
-
reason:
|
|
143
|
+
reason: request.reason,
|
|
116
144
|
});
|
|
117
145
|
return {
|
|
118
146
|
isError: false,
|
|
@@ -15,6 +15,8 @@ export function createSkillSearchAttemptToolDefinition(input: {
|
|
|
15
15
|
authorize: () => Promise<void>;
|
|
16
16
|
listWorkspace: () => Promise<readonly WorkspaceSkillSearchEntry[]>;
|
|
17
17
|
publicSearch: PublicSkillSearchClient;
|
|
18
|
+
/** Ids of the readable Skills a search returned, for read telemetry only. */
|
|
19
|
+
onWorkspaceHits?: (ids: readonly string[]) => void;
|
|
18
20
|
}): AttemptToolDefinition {
|
|
19
21
|
return {
|
|
20
22
|
identity: { serverId: "opengeni", toolName: "skill_search" },
|
|
@@ -59,6 +61,13 @@ export function createSkillSearchAttemptToolDefinition(input: {
|
|
|
59
61
|
source: entry.source ?? "workspace",
|
|
60
62
|
installed: !entry.source || entry.source === "workspace",
|
|
61
63
|
}));
|
|
64
|
+
if (workspaceHits.length) {
|
|
65
|
+
try {
|
|
66
|
+
input.onWorkspaceHits?.(workspaceHits.map((entry) => entry.id));
|
|
67
|
+
} catch {
|
|
68
|
+
// Telemetry never changes a search.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
62
71
|
let publicResult: Awaited<ReturnType<PublicSkillSearchClient["search"]>> | null = null;
|
|
63
72
|
let publicError: {
|
|
64
73
|
source: "skills_sh";
|
|
@@ -20,6 +20,7 @@ export function configuredBundledSkillNames(context: BundledSkillConfiguration):
|
|
|
20
20
|
{ name: "document-parsing", include: () => true },
|
|
21
21
|
{ name: "opengeni-skills", include: () => true },
|
|
22
22
|
{ name: "opengeni-projects", include: () => true },
|
|
23
|
+
{ name: "opengeni-schedules", include: () => tools.has("scheduled_tasks_create") },
|
|
23
24
|
{ name: "opengeni-documents", include: artifacts },
|
|
24
25
|
{ name: "opengeni-spreadsheets", include: artifacts },
|
|
25
26
|
{ name: "opengeni-presentations", include: artifacts },
|
|
@@ -27,6 +28,7 @@ export function configuredBundledSkillNames(context: BundledSkillConfiguration):
|
|
|
27
28
|
name: "opengeni-sites",
|
|
28
29
|
include: () => tools.has("artifacts_create") && tools.has("artifacts_publish"),
|
|
29
30
|
},
|
|
31
|
+
{ name: "opengeni-secrets", include: () => tools.has("secret_search") },
|
|
30
32
|
{ name: "opengeni-video-generation", include: () => context.videoGenerationEnabled },
|
|
31
33
|
];
|
|
32
34
|
return definitions
|
|
@@ -43,12 +45,14 @@ export function loadConfiguredBundledSkills(context: BundledSkillConfiguration)
|
|
|
43
45
|
const names = new Set(configuredBundledSkillNames(context));
|
|
44
46
|
const artifacts = loadNativeToolSkillArtifacts({
|
|
45
47
|
projects: names.has("opengeni-projects"),
|
|
48
|
+
schedules: names.has("opengeni-schedules"),
|
|
46
49
|
editableArtifacts: [
|
|
47
50
|
"opengeni-documents",
|
|
48
51
|
"opengeni-spreadsheets",
|
|
49
52
|
"opengeni-presentations",
|
|
50
53
|
].some((name) => names.has(name)),
|
|
51
54
|
sites: names.has("opengeni-sites"),
|
|
55
|
+
secrets: names.has("opengeni-secrets"),
|
|
52
56
|
videoGeneration: names.has("opengeni-video-generation"),
|
|
53
57
|
});
|
|
54
58
|
return [...artifacts, ...(names.has("opengeni-skills") ? [loadSkillManagementSkill()] : [])]
|