fnloom 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +162 -2
- package/package.json +77 -4
- package/packages/build/package.json +31 -0
- package/packages/build/src/build-system.ts +186 -0
- package/packages/build/src/builder.ts +225 -0
- package/packages/build/src/context.ts +2 -0
- package/packages/build/src/files.ts +73 -0
- package/packages/build/src/folder.ts +52 -0
- package/packages/build/src/index.ts +20 -0
- package/packages/build/src/scan.ts +82 -0
- package/packages/build/src/tests.ts +138 -0
- package/packages/build/tsconfig.json +6 -0
- package/packages/cli/bin/harness.mjs +17 -0
- package/packages/cli/package.json +27 -0
- package/packages/cli/src/catalog.ts +35 -0
- package/packages/cli/src/cli.ts +83 -0
- package/packages/cli/src/command.ts +112 -0
- package/packages/cli/src/commands/available.ts +66 -0
- package/packages/cli/src/commands/build.ts +57 -0
- package/packages/cli/src/commands/data.ts +36 -0
- package/packages/cli/src/commands/install.ts +109 -0
- package/packages/cli/src/commands/manage.ts +104 -0
- package/packages/cli/src/commands/mcp.ts +198 -0
- package/packages/cli/src/commands/new.ts +139 -0
- package/packages/cli/src/commands/pack.ts +37 -0
- package/packages/cli/src/commands/start.ts +22 -0
- package/packages/cli/src/commands/test.ts +57 -0
- package/packages/cli/src/files.ts +5 -0
- package/packages/cli/src/hub-client.ts +84 -0
- package/packages/cli/src/hub.ts +169 -0
- package/packages/cli/src/index.ts +12 -0
- package/packages/cli/src/io.ts +32 -0
- package/packages/cli/src/live.ts +66 -0
- package/packages/cli/src/local.ts +94 -0
- package/packages/cli/src/main.ts +6 -0
- package/packages/cli/src/testing.ts +216 -0
- package/packages/cli/tsconfig.json +6 -0
- package/packages/core/package.json +21 -0
- package/packages/core/src/access.ts +97 -0
- package/packages/core/src/admin.ts +90 -0
- package/packages/core/src/api-index.ts +26 -0
- package/packages/core/src/approvals.ts +229 -0
- package/packages/core/src/auto-pair.ts +47 -0
- package/packages/core/src/changes.ts +61 -0
- package/packages/core/src/checks.ts +93 -0
- package/packages/core/src/claims.ts +98 -0
- package/packages/core/src/compare.ts +47 -0
- package/packages/core/src/config-secrets.ts +28 -0
- package/packages/core/src/connections.ts +193 -0
- package/packages/core/src/context-files.ts +179 -0
- package/packages/core/src/context-graph.ts +270 -0
- package/packages/core/src/csv.ts +33 -0
- package/packages/core/src/data.ts +176 -0
- package/packages/core/src/decisions.ts +98 -0
- package/packages/core/src/flow.ts +225 -0
- package/packages/core/src/fn-block.ts +51 -0
- package/packages/core/src/fn-facts.ts +533 -0
- package/packages/core/src/fn-renames.ts +102 -0
- package/packages/core/src/gin-a.ts +185 -0
- package/packages/core/src/gin-record.ts +142 -0
- package/packages/core/src/gin.ts +104 -0
- package/packages/core/src/grants.ts +84 -0
- package/packages/core/src/graph-kinds.ts +44 -0
- package/packages/core/src/graph.ts +95 -0
- package/packages/core/src/https.ts +35 -0
- package/packages/core/src/identity.ts +38 -0
- package/packages/core/src/image-embeddings.ts +96 -0
- package/packages/core/src/index.ts +129 -0
- package/packages/core/src/inject.ts +104 -0
- package/packages/core/src/issues.ts +137 -0
- package/packages/core/src/labels.ts +96 -0
- package/packages/core/src/lifecycle.ts +237 -0
- package/packages/core/src/link.ts +491 -0
- package/packages/core/src/llm.ts +167 -0
- package/packages/core/src/manifest.ts +657 -0
- package/packages/core/src/mcp-servers.ts +134 -0
- package/packages/core/src/media-types.ts +145 -0
- package/packages/core/src/mention-search.ts +27 -0
- package/packages/core/src/metrics.ts +91 -0
- package/packages/core/src/model-calls.ts +223 -0
- package/packages/core/src/model-names.ts +704 -0
- package/packages/core/src/modes.ts +325 -0
- package/packages/core/src/objects.ts +15 -0
- package/packages/core/src/owner-runs.ts +89 -0
- package/packages/core/src/package.ts +195 -0
- package/packages/core/src/partial.ts +69 -0
- package/packages/core/src/people-only.ts +52 -0
- package/packages/core/src/pickers.ts +31 -0
- package/packages/core/src/ports.ts +14 -0
- package/packages/core/src/primitives.ts +287 -0
- package/packages/core/src/programs.ts +155 -0
- package/packages/core/src/query.ts +264 -0
- package/packages/core/src/records/actors.ts +188 -0
- package/packages/core/src/records/announced.ts +39 -0
- package/packages/core/src/records/chat.ts +279 -0
- package/packages/core/src/records/citations.ts +126 -0
- package/packages/core/src/records/compare.ts +97 -0
- package/packages/core/src/records/content.ts +196 -0
- package/packages/core/src/records/injections.ts +146 -0
- package/packages/core/src/records/mcps.ts +115 -0
- package/packages/core/src/records/runs.ts +280 -0
- package/packages/core/src/records/spend.ts +158 -0
- package/packages/core/src/records/systems.ts +298 -0
- package/packages/core/src/records/tables.ts +164 -0
- package/packages/core/src/registries.ts +229 -0
- package/packages/core/src/remote-auth.ts +111 -0
- package/packages/core/src/resource-forms.ts +218 -0
- package/packages/core/src/resources.ts +166 -0
- package/packages/core/src/review-summary.ts +69 -0
- package/packages/core/src/run.ts +312 -0
- package/packages/core/src/sensitivity.ts +101 -0
- package/packages/core/src/sso.ts +268 -0
- package/packages/core/src/status.ts +158 -0
- package/packages/core/src/suggestions.ts +228 -0
- package/packages/core/src/system-events.ts +47 -0
- package/packages/core/src/system-pages.ts +72 -0
- package/packages/core/src/system-parts.ts +51 -0
- package/packages/core/src/system-providers.ts +163 -0
- package/packages/core/src/urls.ts +50 -0
- package/packages/core/src/validation.ts +39 -0
- package/packages/core/src/versions.ts +52 -0
- package/packages/core/src/visuals.ts +478 -0
- package/packages/core/src/web.ts +965 -0
- package/packages/core/src/widgets-v1.ts +73 -0
- package/packages/core/src/widgets.ts +427 -0
- package/packages/core/tsconfig.json +5 -0
- package/packages/hub/context/asking.md +16 -0
- package/packages/hub/context/attached_files.md +27 -0
- package/packages/hub/context/background_runs.md +14 -0
- package/packages/hub/context/earlier_chats.md +16 -0
- package/packages/hub/context/examples.md +13 -0
- package/packages/hub/context/finding_fns.md +18 -0
- package/packages/hub/context/images.md +24 -0
- package/packages/hub/context/later.md +27 -0
- package/packages/hub/context/limits.md +13 -0
- package/packages/hub/context/memory.md +38 -0
- package/packages/hub/context/resources.md +21 -0
- package/packages/hub/context/saved_fns.md +28 -0
- package/packages/hub/context/undo.md +20 -0
- package/packages/hub/package.json +55 -0
- package/packages/hub/src/access/create.ts +29 -0
- package/packages/hub/src/access/hits.ts +57 -0
- package/packages/hub/src/access/index.ts +119 -0
- package/packages/hub/src/access/scope.ts +133 -0
- package/packages/hub/src/access/service.ts +171 -0
- package/packages/hub/src/api/admin-ops.ts +410 -0
- package/packages/hub/src/api/auth.ts +286 -0
- package/packages/hub/src/api/client-address.ts +55 -0
- package/packages/hub/src/api/connect.ts +45 -0
- package/packages/hub/src/api/dual.ts +103 -0
- package/packages/hub/src/api/events.ts +185 -0
- package/packages/hub/src/api/files.ts +209 -0
- package/packages/hub/src/api/hash.ts +23 -0
- package/packages/hub/src/api/http.ts +171 -0
- package/packages/hub/src/api/https.ts +125 -0
- package/packages/hub/src/api/identities.ts +246 -0
- package/packages/hub/src/api/index.ts +94 -0
- package/packages/hub/src/api/injections.ts +256 -0
- package/packages/hub/src/api/mime.ts +31 -0
- package/packages/hub/src/api/person-ops.ts +153 -0
- package/packages/hub/src/api/push.ts +97 -0
- package/packages/hub/src/api/reads.ts +145 -0
- package/packages/hub/src/api/secrets.ts +71 -0
- package/packages/hub/src/api/serve.ts +280 -0
- package/packages/hub/src/api/signed.ts +66 -0
- package/packages/hub/src/api/sso-route.ts +73 -0
- package/packages/hub/src/api/sso.ts +382 -0
- package/packages/hub/src/api/system-parts.ts +97 -0
- package/packages/hub/src/api/testing/issuer.ts +128 -0
- package/packages/hub/src/api/testing/rig.ts +272 -0
- package/packages/hub/src/api/tls.ts +383 -0
- package/packages/hub/src/api/web/access.ts +84 -0
- package/packages/hub/src/api/web/admin.ts +90 -0
- package/packages/hub/src/api/web/auth.ts +103 -0
- package/packages/hub/src/api/web/build3.ts +44 -0
- package/packages/hub/src/api/web/build4.ts +24 -0
- package/packages/hub/src/api/web/build5.ts +120 -0
- package/packages/hub/src/api/web/chat.ts +144 -0
- package/packages/hub/src/api/web/content.ts +42 -0
- package/packages/hub/src/api/web/context.ts +41 -0
- package/packages/hub/src/api/web/contextor.ts +37 -0
- package/packages/hub/src/api/web/data.ts +33 -0
- package/packages/hub/src/api/web/explorer.ts +22 -0
- package/packages/hub/src/api/web/find.ts +50 -0
- package/packages/hub/src/api/web/graph.ts +17 -0
- package/packages/hub/src/api/web/https.ts +18 -0
- package/packages/hub/src/api/web/identity.ts +18 -0
- package/packages/hub/src/api/web/images.ts +18 -0
- package/packages/hub/src/api/web/inbox.ts +35 -0
- package/packages/hub/src/api/web/index.ts +137 -0
- package/packages/hub/src/api/web/injections.ts +22 -0
- package/packages/hub/src/api/web/mcps.ts +32 -0
- package/packages/hub/src/api/web/metrics.ts +24 -0
- package/packages/hub/src/api/web/models.ts +21 -0
- package/packages/hub/src/api/web/outside-images.ts +32 -0
- package/packages/hub/src/api/web/packaging.ts +31 -0
- package/packages/hub/src/api/web/pages.ts +55 -0
- package/packages/hub/src/api/web/people.ts +92 -0
- package/packages/hub/src/api/web/pickers.ts +115 -0
- package/packages/hub/src/api/web/resources.ts +42 -0
- package/packages/hub/src/api/web/review.ts +119 -0
- package/packages/hub/src/api/web/runs.ts +94 -0
- package/packages/hub/src/api/web/settings.ts +35 -0
- package/packages/hub/src/api/web/systems.ts +83 -0
- package/packages/hub/src/api/web/tables.ts +31 -0
- package/packages/hub/src/api/web/versions.ts +17 -0
- package/packages/hub/src/api/web/visibility.ts +47 -0
- package/packages/hub/src/boot/admin-fns.ts +78 -0
- package/packages/hub/src/boot/admin-secrets.ts +140 -0
- package/packages/hub/src/boot/env.ts +170 -0
- package/packages/hub/src/boot/hub-context.ts +39 -0
- package/packages/hub/src/boot/hub-fns.ts +549 -0
- package/packages/hub/src/boot/hub-groups.ts +34 -0
- package/packages/hub/src/boot/identity.ts +66 -0
- package/packages/hub/src/boot/index.ts +191 -0
- package/packages/hub/src/boot/info.ts +22 -0
- package/packages/hub/src/boot/keys.ts +60 -0
- package/packages/hub/src/boot/log.ts +31 -0
- package/packages/hub/src/boot/modules.ts +277 -0
- package/packages/hub/src/boot/person-fns.ts +78 -0
- package/packages/hub/src/boot/read-fns.ts +73 -0
- package/packages/hub/src/boot/services.ts +156 -0
- package/packages/hub/src/boot/start.ts +246 -0
- package/packages/hub/src/bus/memory.ts +60 -0
- package/packages/hub/src/bus.ts +80 -0
- package/packages/hub/src/catalog/api-index.ts +72 -0
- package/packages/hub/src/catalog/availability.ts +210 -0
- package/packages/hub/src/catalog/catalog.ts +1062 -0
- package/packages/hub/src/catalog/definitions.ts +19 -0
- package/packages/hub/src/catalog/fixtures.ts +82 -0
- package/packages/hub/src/catalog/fn-names.ts +128 -0
- package/packages/hub/src/catalog/index.ts +126 -0
- package/packages/hub/src/catalog/injections.ts +90 -0
- package/packages/hub/src/catalog/scope.ts +86 -0
- package/packages/hub/src/catalog/serial.ts +10 -0
- package/packages/hub/src/catalog/signature.ts +69 -0
- package/packages/hub/src/catalog/versions.ts +110 -0
- package/packages/hub/src/chat/announce.ts +145 -0
- package/packages/hub/src/chat/cache.ts +50 -0
- package/packages/hub/src/chat/chat.ts +72 -0
- package/packages/hub/src/chat/cite-rule.ts +64 -0
- package/packages/hub/src/chat/cites.ts +236 -0
- package/packages/hub/src/chat/compare.ts +290 -0
- package/packages/hub/src/chat/deliveries.ts +187 -0
- package/packages/hub/src/chat/deps.ts +69 -0
- package/packages/hub/src/chat/enrich.ts +601 -0
- package/packages/hub/src/chat/env.ts +33 -0
- package/packages/hub/src/chat/errors.ts +38 -0
- package/packages/hub/src/chat/files.ts +72 -0
- package/packages/hub/src/chat/index.ts +259 -0
- package/packages/hub/src/chat/mention-requests.ts +49 -0
- package/packages/hub/src/chat/mention-search.ts +64 -0
- package/packages/hub/src/chat/mentions.ts +274 -0
- package/packages/hub/src/chat/notifications.ts +278 -0
- package/packages/hub/src/chat/people.ts +59 -0
- package/packages/hub/src/chat/presence.ts +48 -0
- package/packages/hub/src/chat/reply.ts +23 -0
- package/packages/hub/src/chat/sessions.ts +306 -0
- package/packages/hub/src/chat/shown.ts +158 -0
- package/packages/hub/src/chat/state.ts +270 -0
- package/packages/hub/src/chat/streams.ts +92 -0
- package/packages/hub/src/chat/suggestions.ts +383 -0
- package/packages/hub/src/chat/support.ts +144 -0
- package/packages/hub/src/chat/testing.ts +488 -0
- package/packages/hub/src/chat/turns.ts +586 -0
- package/packages/hub/src/chat/undo.ts +177 -0
- package/packages/hub/src/connections/create.ts +25 -0
- package/packages/hub/src/connections/env.ts +14 -0
- package/packages/hub/src/connections/index.ts +86 -0
- package/packages/hub/src/connections/service.ts +536 -0
- package/packages/hub/src/contextor/brought.ts +64 -0
- package/packages/hub/src/contextor/budget.ts +74 -0
- package/packages/hub/src/contextor/calibration.ts +35 -0
- package/packages/hub/src/contextor/choose.ts +116 -0
- package/packages/hub/src/contextor/contextors.ts +550 -0
- package/packages/hub/src/contextor/crawl.ts +252 -0
- package/packages/hub/src/contextor/create.ts +113 -0
- package/packages/hub/src/contextor/dynamic.ts +102 -0
- package/packages/hub/src/contextor/env.ts +83 -0
- package/packages/hub/src/contextor/examples.ts +204 -0
- package/packages/hub/src/contextor/fns.ts +147 -0
- package/packages/hub/src/contextor/graph.ts +137 -0
- package/packages/hub/src/contextor/history.ts +211 -0
- package/packages/hub/src/contextor/index.ts +524 -0
- package/packages/hub/src/contextor/injected.ts +401 -0
- package/packages/hub/src/contextor/limits.ts +168 -0
- package/packages/hub/src/contextor/links.ts +67 -0
- package/packages/hub/src/contextor/modes.ts +520 -0
- package/packages/hub/src/contextor/planner.ts +626 -0
- package/packages/hub/src/contextor/render.ts +531 -0
- package/packages/hub/src/contextor/score.ts +93 -0
- package/packages/hub/src/contextor/testing.ts +161 -0
- package/packages/hub/src/contextor/tokens.ts +102 -0
- package/packages/hub/src/contextor/views.ts +171 -0
- package/packages/hub/src/contextor/xml.ts +140 -0
- package/packages/hub/src/data/create.ts +45 -0
- package/packages/hub/src/data/env.ts +16 -0
- package/packages/hub/src/data/fields.ts +71 -0
- package/packages/hub/src/data/fns.ts +50 -0
- package/packages/hub/src/data/index.ts +50 -0
- package/packages/hub/src/data/service.ts +348 -0
- package/packages/hub/src/execution/agent.ts +1381 -0
- package/packages/hub/src/execution/ai.ts +408 -0
- package/packages/hub/src/execution/channel.ts +38 -0
- package/packages/hub/src/execution/claims.ts +103 -0
- package/packages/hub/src/execution/create.ts +261 -0
- package/packages/hub/src/execution/deadlines.ts +74 -0
- package/packages/hub/src/execution/deciders.ts +60 -0
- package/packages/hub/src/execution/env.ts +28 -0
- package/packages/hub/src/execution/errors.ts +103 -0
- package/packages/hub/src/execution/executors.ts +246 -0
- package/packages/hub/src/execution/gateway.ts +209 -0
- package/packages/hub/src/execution/handlers.ts +154 -0
- package/packages/hub/src/execution/hub-fns.ts +50 -0
- package/packages/hub/src/execution/index.ts +244 -0
- package/packages/hub/src/execution/interactions.ts +65 -0
- package/packages/hub/src/execution/ledger.ts +168 -0
- package/packages/hub/src/execution/limits.ts +175 -0
- package/packages/hub/src/execution/link-handlers.ts +142 -0
- package/packages/hub/src/execution/media.ts +240 -0
- package/packages/hub/src/execution/models.ts +42 -0
- package/packages/hub/src/execution/policies.ts +371 -0
- package/packages/hub/src/execution/ports.ts +159 -0
- package/packages/hub/src/execution/providers.ts +106 -0
- package/packages/hub/src/execution/queues.ts +161 -0
- package/packages/hub/src/execution/runs.ts +1237 -0
- package/packages/hub/src/execution/scope.ts +152 -0
- package/packages/hub/src/execution/spend.ts +75 -0
- package/packages/hub/src/execution/stream-guard.ts +138 -0
- package/packages/hub/src/execution/testing.ts +490 -0
- package/packages/hub/src/execution/time.ts +36 -0
- package/packages/hub/src/execution/tools.ts +84 -0
- package/packages/hub/src/execution/wire.ts +99 -0
- package/packages/hub/src/execution/wording.ts +38 -0
- package/packages/hub/src/fns/auto.ts +109 -0
- package/packages/hub/src/fns/client-logs.ts +83 -0
- package/packages/hub/src/fns/costs.ts +139 -0
- package/packages/hub/src/fns/create.ts +140 -0
- package/packages/hub/src/fns/decided.ts +313 -0
- package/packages/hub/src/fns/env.ts +23 -0
- package/packages/hub/src/fns/examples.ts +184 -0
- package/packages/hub/src/fns/facts.ts +251 -0
- package/packages/hub/src/fns/gate.ts +40 -0
- package/packages/hub/src/fns/index.ts +149 -0
- package/packages/hub/src/fns/search.ts +351 -0
- package/packages/hub/src/graph/graph.ts +667 -0
- package/packages/hub/src/graph/source.ts +42 -0
- package/packages/hub/src/index/batch.ts +96 -0
- package/packages/hub/src/index/context-sections.ts +51 -0
- package/packages/hub/src/index/embedders.ts +242 -0
- package/packages/hub/src/index/env.ts +25 -0
- package/packages/hub/src/index/image-setting.ts +55 -0
- package/packages/hub/src/index/images.ts +43 -0
- package/packages/hub/src/index/index.ts +168 -0
- package/packages/hub/src/index/indexer.ts +663 -0
- package/packages/hub/src/index/search.ts +168 -0
- package/packages/hub/src/index/sectioners.ts +209 -0
- package/packages/hub/src/index/sectioning.ts +57 -0
- package/packages/hub/src/index/suggester.ts +65 -0
- package/packages/hub/src/index/testing.ts +113 -0
- package/packages/hub/src/index.ts +19 -0
- package/packages/hub/src/link/auto-pair.ts +225 -0
- package/packages/hub/src/link/build.ts +216 -0
- package/packages/hub/src/link/config-secrets.ts +171 -0
- package/packages/hub/src/link/config.ts +140 -0
- package/packages/hub/src/link/connections.ts +139 -0
- package/packages/hub/src/link/describer.ts +29 -0
- package/packages/hub/src/link/env.ts +42 -0
- package/packages/hub/src/link/events.ts +123 -0
- package/packages/hub/src/link/gate.ts +117 -0
- package/packages/hub/src/link/grants.ts +346 -0
- package/packages/hub/src/link/handlers.ts +301 -0
- package/packages/hub/src/link/index.ts +232 -0
- package/packages/hub/src/link/install.ts +92 -0
- package/packages/hub/src/link/keys.ts +32 -0
- package/packages/hub/src/link/lifecycle.ts +520 -0
- package/packages/hub/src/link/migrate-api.ts +210 -0
- package/packages/hub/src/link/migrate.ts +44 -0
- package/packages/hub/src/link/output.ts +63 -0
- package/packages/hub/src/link/owner-runs.ts +313 -0
- package/packages/hub/src/link/package/data.ts +53 -0
- package/packages/hub/src/link/package/format.ts +126 -0
- package/packages/hub/src/link/package/index.ts +9 -0
- package/packages/hub/src/link/package/zip.ts +137 -0
- package/packages/hub/src/link/packages.ts +180 -0
- package/packages/hub/src/link/pairing.ts +503 -0
- package/packages/hub/src/link/process.ts +93 -0
- package/packages/hub/src/link/reads.ts +91 -0
- package/packages/hub/src/link/resources.ts +166 -0
- package/packages/hub/src/link/review-summary.ts +279 -0
- package/packages/hub/src/link/rig.ts +335 -0
- package/packages/hub/src/link/router.ts +118 -0
- package/packages/hub/src/link/services.ts +294 -0
- package/packages/hub/src/link/status.ts +126 -0
- package/packages/hub/src/link/supervisor.ts +547 -0
- package/packages/hub/src/link/systems.ts +101 -0
- package/packages/hub/src/link/tokens.ts +30 -0
- package/packages/hub/src/main.ts +19 -0
- package/packages/hub/src/mcp/calls.ts +153 -0
- package/packages/hub/src/mcp/create.ts +51 -0
- package/packages/hub/src/mcp/endpoints.ts +206 -0
- package/packages/hub/src/mcp/env.ts +19 -0
- package/packages/hub/src/mcp/fns.ts +23 -0
- package/packages/hub/src/mcp/index.ts +76 -0
- package/packages/hub/src/mcp/registry.ts +150 -0
- package/packages/hub/src/mcp/scopes.ts +218 -0
- package/packages/hub/src/mcp/sources.ts +154 -0
- package/packages/hub/src/mcp/tokens.ts +72 -0
- package/packages/hub/src/mcp/tools.ts +173 -0
- package/packages/hub/src/metrics/calls.ts +123 -0
- package/packages/hub/src/metrics/create.ts +15 -0
- package/packages/hub/src/metrics/fn-metrics.ts +97 -0
- package/packages/hub/src/metrics/index.ts +58 -0
- package/packages/hub/src/metrics/rollup.ts +188 -0
- package/packages/hub/src/models/create.ts +65 -0
- package/packages/hub/src/models/decide.ts +134 -0
- package/packages/hub/src/models/gateway.ts +102 -0
- package/packages/hub/src/models/index.ts +82 -0
- package/packages/hub/src/models/pinned.ts +10 -0
- package/packages/hub/src/models/remote.ts +386 -0
- package/packages/hub/src/models/roles.ts +160 -0
- package/packages/hub/src/models/structured.ts +30 -0
- package/packages/hub/src/query/columns.ts +55 -0
- package/packages/hub/src/query/contexts.ts +102 -0
- package/packages/hub/src/query/env.ts +17 -0
- package/packages/hub/src/query/evaluate.ts +181 -0
- package/packages/hub/src/query/index.ts +32 -0
- package/packages/hub/src/query/service.ts +64 -0
- package/packages/hub/src/query/sources.ts +344 -0
- package/packages/hub/src/query/sql-source.ts +93 -0
- package/packages/hub/src/resources/browse.ts +131 -0
- package/packages/hub/src/resources/content.ts +183 -0
- package/packages/hub/src/resources/context.ts +405 -0
- package/packages/hub/src/resources/converters.ts +78 -0
- package/packages/hub/src/resources/create.ts +88 -0
- package/packages/hub/src/resources/env.ts +24 -0
- package/packages/hub/src/resources/fetch.ts +140 -0
- package/packages/hub/src/resources/fns.ts +172 -0
- package/packages/hub/src/resources/forms.ts +285 -0
- package/packages/hub/src/resources/images.ts +182 -0
- package/packages/hub/src/resources/index.ts +186 -0
- package/packages/hub/src/resources/library.ts +228 -0
- package/packages/hub/src/resources/models.ts +116 -0
- package/packages/hub/src/resources/pdf-pages.ts +455 -0
- package/packages/hub/src/resources/raw.ts +108 -0
- package/packages/hub/src/resources/reader.ts +224 -0
- package/packages/hub/src/resources/rules.ts +110 -0
- package/packages/hub/src/resources/sqlite-files.ts +140 -0
- package/packages/hub/src/resources/storage.ts +40 -0
- package/packages/hub/src/resources/testing.ts +292 -0
- package/packages/hub/src/store/always-for.ts +46 -0
- package/packages/hub/src/store/auxTables.ts +97 -0
- package/packages/hub/src/store/codec.ts +109 -0
- package/packages/hub/src/store/db.ts +137 -0
- package/packages/hub/src/store/env.ts +13 -0
- package/packages/hub/src/store/errors.ts +36 -0
- package/packages/hub/src/store/fixtures.ts +53 -0
- package/packages/hub/src/store/fn-renames.ts +72 -0
- package/packages/hub/src/store/hybrid.ts +130 -0
- package/packages/hub/src/store/index.ts +231 -0
- package/packages/hub/src/store/lists.ts +172 -0
- package/packages/hub/src/store/migrate-fn-names.ts +135 -0
- package/packages/hub/src/store/migrate.ts +121 -0
- package/packages/hub/src/store/ports.ts +163 -0
- package/packages/hub/src/store/query.ts +166 -0
- package/packages/hub/src/store/records.ts +119 -0
- package/packages/hub/src/store/rows.ts +105 -0
- package/packages/hub/src/store/schema.ts +184 -0
- package/packages/hub/src/store/sqlite.ts +136 -0
- package/packages/hub/src/store/table.ts +113 -0
- package/packages/hub/src/store/text.ts +92 -0
- package/packages/hub/src/store/vectors.ts +232 -0
- package/packages/hub/src/tables/env.ts +15 -0
- package/packages/hub/src/tables/fns.ts +29 -0
- package/packages/hub/src/tables/index.ts +45 -0
- package/packages/hub/src/tables/migrate.ts +105 -0
- package/packages/hub/src/tables/service.ts +245 -0
- package/packages/hub/src/testing.ts +128 -0
- package/packages/hub/tsconfig.json +6 -0
- package/packages/sdk/AUTHORING.md +25228 -0
- package/packages/sdk/package.json +58 -0
- package/packages/sdk/src/a-gin.ts +132 -0
- package/packages/sdk/src/agent.ts +121 -0
- package/packages/sdk/src/authoring.ts +546 -0
- package/packages/sdk/src/build.ts +97 -0
- package/packages/sdk/src/chat-prompt.ts +202 -0
- package/packages/sdk/src/claims.ts +20 -0
- package/packages/sdk/src/client-runtime.ts +514 -0
- package/packages/sdk/src/client.ts +672 -0
- package/packages/sdk/src/ctx.ts +659 -0
- package/packages/sdk/src/declare.ts +480 -0
- package/packages/sdk/src/fn.ts +514 -0
- package/packages/sdk/src/gin.ts +245 -0
- package/packages/sdk/src/hub.ts +1065 -0
- package/packages/sdk/src/impl.ts +35 -0
- package/packages/sdk/src/index.ts +87 -0
- package/packages/sdk/src/links.ts +35 -0
- package/packages/sdk/src/manifest.ts +372 -0
- package/packages/sdk/src/page-parts.ts +153 -0
- package/packages/sdk/src/program/env.ts +29 -0
- package/packages/sdk/src/program/index.ts +13 -0
- package/packages/sdk/src/program/lookups.ts +82 -0
- package/packages/sdk/src/program/runtime.ts +576 -0
- package/packages/sdk/src/program/tools.ts +268 -0
- package/packages/sdk/src/providers.ts +77 -0
- package/packages/sdk/src/refs.ts +161 -0
- package/packages/sdk/src/relative-dates.ts +197 -0
- package/packages/sdk/src/remote-auth.ts +113 -0
- package/packages/sdk/src/resources.ts +28 -0
- package/packages/sdk/src/results.ts +47 -0
- package/packages/sdk/src/server/address.ts +167 -0
- package/packages/sdk/src/server/asks.ts +111 -0
- package/packages/sdk/src/server/assets.ts +47 -0
- package/packages/sdk/src/server/authored-names.ts +79 -0
- package/packages/sdk/src/server/calls.ts +260 -0
- package/packages/sdk/src/server/content.ts +124 -0
- package/packages/sdk/src/server/context-check.ts +214 -0
- package/packages/sdk/src/server/context-files.ts +244 -0
- package/packages/sdk/src/server/data.ts +90 -0
- package/packages/sdk/src/server/env.ts +144 -0
- package/packages/sdk/src/server/fake-hub-fns.ts +124 -0
- package/packages/sdk/src/server/fake-hub-widgets.ts +67 -0
- package/packages/sdk/src/server/fake-models.ts +89 -0
- package/packages/sdk/src/server/fake-records.ts +217 -0
- package/packages/sdk/src/server/files.ts +118 -0
- package/packages/sdk/src/server/host.ts +742 -0
- package/packages/sdk/src/server/hosted-network-guard.ts +18 -0
- package/packages/sdk/src/server/index.ts +220 -0
- package/packages/sdk/src/server/journal.ts +131 -0
- package/packages/sdk/src/server/js-yaml.d.ts +19 -0
- package/packages/sdk/src/server/keys.ts +148 -0
- package/packages/sdk/src/server/link.ts +93 -0
- package/packages/sdk/src/server/live.ts +22 -0
- package/packages/sdk/src/server/llm-wire.ts +647 -0
- package/packages/sdk/src/server/llm.ts +555 -0
- package/packages/sdk/src/server/log.ts +108 -0
- package/packages/sdk/src/server/manifest-state.ts +113 -0
- package/packages/sdk/src/server/mcp-caller.ts +15 -0
- package/packages/sdk/src/server/mcp-prompts.ts +54 -0
- package/packages/sdk/src/server/mcp-resources.ts +130 -0
- package/packages/sdk/src/server/mcp.ts +194 -0
- package/packages/sdk/src/server/owner-runs.ts +109 -0
- package/packages/sdk/src/server/package.ts +141 -0
- package/packages/sdk/src/server/pairing.ts +97 -0
- package/packages/sdk/src/server/process.ts +53 -0
- package/packages/sdk/src/server/providers.ts +180 -0
- package/packages/sdk/src/server/proxy.ts +196 -0
- package/packages/sdk/src/server/renderers.ts +28 -0
- package/packages/sdk/src/server/resources.ts +89 -0
- package/packages/sdk/src/server/results.ts +121 -0
- package/packages/sdk/src/server/run.ts +492 -0
- package/packages/sdk/src/server/runs.ts +103 -0
- package/packages/sdk/src/server/runtime.ts +597 -0
- package/packages/sdk/src/server/socket-guard.ts +162 -0
- package/packages/sdk/src/server/state.ts +112 -0
- package/packages/sdk/src/server/supervise.ts +257 -0
- package/packages/sdk/src/server/table.ts +490 -0
- package/packages/sdk/src/server/testing.ts +883 -0
- package/packages/sdk/src/server/types.ts +26 -0
- package/packages/sdk/src/server/wire.ts +172 -0
- package/packages/sdk/src/status.ts +50 -0
- package/packages/sdk/src/system.ts +459 -0
- package/packages/sdk/src/testing/context.ts +48 -0
- package/packages/sdk/src/testing/env.ts +28 -0
- package/packages/sdk/src/testing/fixtures/NoteCard.vue +17 -0
- package/packages/sdk/src/testing/fixtures/context/guide.md +12 -0
- package/packages/sdk/src/testing/hub.ts +294 -0
- package/packages/sdk/src/testing/index.ts +30 -0
- package/packages/sdk/src/testing/models.ts +192 -0
- package/packages/sdk/src/testing/openrouter.ts +94 -0
- package/packages/sdk/src/testing/preview.ts +207 -0
- package/packages/sdk/src/testing/scratch.ts +58 -0
- package/packages/sdk/src/testing/shots.ts +17 -0
- package/packages/sdk/src/util.ts +35 -0
- package/packages/sdk/src/widget-check.ts +182 -0
- package/packages/sdk/src/widget-schema.ts +251 -0
- package/packages/sdk/src/widgets.ts +386 -0
- package/packages/sdk/src/zod-gin.ts +213 -0
- package/packages/sdk/tsconfig.json +6 -0
- package/packages/web/dist/assets/ActorSettingsView-BuMYRDqv.js +2 -0
- package/packages/web/dist/assets/ActorSettingsView-GTxPZw8N.css +1 -0
- package/packages/web/dist/assets/AdminLayout-1hbRPV3d.css +1 -0
- package/packages/web/dist/assets/AdminLayout-sLjVTrmV.js +2 -0
- package/packages/web/dist/assets/ApiServiceForm-BrMTU-7u.js +2 -0
- package/packages/web/dist/assets/ApiServiceForm-BxprSaAq.css +1 -0
- package/packages/web/dist/assets/ApiServiceView-BMF2zD6Q.js +2 -0
- package/packages/web/dist/assets/ApiServiceView-BVmdRCjR.css +1 -0
- package/packages/web/dist/assets/ApiServicesView-BTLV6c8n.css +1 -0
- package/packages/web/dist/assets/ApiServicesView-bjLAWO_j.js +2 -0
- package/packages/web/dist/assets/AppPage-BBzZ0Pru.css +1 -0
- package/packages/web/dist/assets/AppPage-DSzDKCFz.js +2 -0
- package/packages/web/dist/assets/AutoPairPicker-ClF4nB0n.css +1 -0
- package/packages/web/dist/assets/AutoPairPicker-nV38ALjl.js +2 -0
- package/packages/web/dist/assets/BrowserFrame-Bic7U7jN.js +2 -0
- package/packages/web/dist/assets/BrowserFrame-BzEdhmsF.css +1 -0
- package/packages/web/dist/assets/ChartVisual-BnFG9aFi.css +1 -0
- package/packages/web/dist/assets/ChartVisual-DWw7WsfN.js +11 -0
- package/packages/web/dist/assets/ChatPage-7Yebk7rl.js +4 -0
- package/packages/web/dist/assets/ChatPage-CbsRmktV.css +1 -0
- package/packages/web/dist/assets/CodeViewer-D6A30AJ9.css +1 -0
- package/packages/web/dist/assets/CodeViewer-xHS3Xah9.js +5 -0
- package/packages/web/dist/assets/ConfigWithCustom-C74DTXuy.css +1 -0
- package/packages/web/dist/assets/ConfigWithCustom-DreTUdf0.js +3 -0
- package/packages/web/dist/assets/ConfirmDialog-DjQUzNqk.js +2 -0
- package/packages/web/dist/assets/ConfirmDialog-oABDbIMz.css +1 -0
- package/packages/web/dist/assets/ConnectPage-CfRDrXvJ.js +2 -0
- package/packages/web/dist/assets/ConnectPage-Zz1nFbcn.css +1 -0
- package/packages/web/dist/assets/ContextItemPage-B6rJG3OT.js +2 -0
- package/packages/web/dist/assets/ContextItemPage-BRsWxOmu.css +1 -0
- package/packages/web/dist/assets/ContextPage-CloIZ_2y.js +2 -0
- package/packages/web/dist/assets/ContextPage-rYKxjiVI.css +1 -0
- package/packages/web/dist/assets/ContextRow-Byz_7HG-.css +1 -0
- package/packages/web/dist/assets/ContextRow-Dvv8CTFk.js +2 -0
- package/packages/web/dist/assets/DataPage-CLgJtQwS.css +1 -0
- package/packages/web/dist/assets/DataPage-wSIoGcb5.js +2 -0
- package/packages/web/dist/assets/DataTypePage-Ba_zBV4b.js +4 -0
- package/packages/web/dist/assets/DataTypePage-Cr238Hx_.css +1 -0
- package/packages/web/dist/assets/DesignPage-BFC4A-wO.css +1 -0
- package/packages/web/dist/assets/DesignPage-DidMUX8m.js +49 -0
- package/packages/web/dist/assets/ExplorePage-DJmOOIhs.css +1 -0
- package/packages/web/dist/assets/ExplorePage-MUyVydVB.js +2 -0
- package/packages/web/dist/assets/FactList-CeAbKajD.js +2 -0
- package/packages/web/dist/assets/FactList-DuDPr7n7.css +1 -0
- package/packages/web/dist/assets/FnList-BCnb4kOB.css +1 -0
- package/packages/web/dist/assets/FnList-CjQRwYaT.js +2 -0
- package/packages/web/dist/assets/FnPill-BNIWrqXN.css +1 -0
- package/packages/web/dist/assets/FnPill-BshAvm2I.js +2 -0
- package/packages/web/dist/assets/FnView-B8MGAOoB.js +2 -0
- package/packages/web/dist/assets/FnView-BBFbPAQz.css +1 -0
- package/packages/web/dist/assets/FnsView-CeqIoaBT.js +2 -0
- package/packages/web/dist/assets/FnsView-D575syq-.css +1 -0
- package/packages/web/dist/assets/GinExprView-DYVUwZrd.js +4 -0
- package/packages/web/dist/assets/GinExprView-dqtf5BKF.css +1 -0
- package/packages/web/dist/assets/GinForm-CVEsGoBo.css +1 -0
- package/packages/web/dist/assets/GinForm-D3mwMRTQ.js +2 -0
- package/packages/web/dist/assets/GinTypeView-B5CGqWvh.css +1 -0
- package/packages/web/dist/assets/GinTypeView-C0YifSmE.js +2 -0
- package/packages/web/dist/assets/GinValueView-HfEPq9le.js +4 -0
- package/packages/web/dist/assets/GinValueView-zhWn-X48.css +1 -0
- package/packages/web/dist/assets/GraphPage-ySnuA4Hp.js +2 -0
- package/packages/web/dist/assets/GraphPanel-B9jxpJfb.css +1 -0
- package/packages/web/dist/assets/GraphPanel-Cy5-KGo1.js +2 -0
- package/packages/web/dist/assets/HubPicker-C_vA752L.js +2 -0
- package/packages/web/dist/assets/InboxApprovals-DcPCCmZ5.js +2 -0
- package/packages/web/dist/assets/InboxApprovals-DmC94LNf.css +1 -0
- package/packages/web/dist/assets/InboxPage-C2DT2nuF.js +2 -0
- package/packages/web/dist/assets/InjectedList-BgxdlaHJ.css +1 -0
- package/packages/web/dist/assets/InjectedList-CJsEFEbz.js +2 -0
- package/packages/web/dist/assets/InstallDialog-C9GDoUI2.js +2 -0
- package/packages/web/dist/assets/InstallDialog-yWLZK_zN.css +1 -0
- package/packages/web/dist/assets/InstanceTypes-D8Jcxn70.js +2 -0
- package/packages/web/dist/assets/InstanceTypes-DAowwLB7.css +1 -0
- package/packages/web/dist/assets/InstanceView-CuBD3JPU.css +1 -0
- package/packages/web/dist/assets/InstanceView-p7tMaylE.js +2 -0
- package/packages/web/dist/assets/ItemHistory-CUGa8b6s.js +2 -0
- package/packages/web/dist/assets/ItemHistory-Czzpyiud.css +1 -0
- package/packages/web/dist/assets/LimitsView-DlPW-cLw.css +1 -0
- package/packages/web/dist/assets/LimitsView-DsZG6u5P.js +2 -0
- package/packages/web/dist/assets/ListSearch-BK4p7Nxa.js +2 -0
- package/packages/web/dist/assets/ListSearch-CdxSo6UW.css +1 -0
- package/packages/web/dist/assets/LlmCallDetails-2yQftCqd.js +2 -0
- package/packages/web/dist/assets/LlmCallDetails-gymdroc_.css +1 -0
- package/packages/web/dist/assets/LlmCallsView-B1yHEIBG.css +1 -0
- package/packages/web/dist/assets/LlmCallsView-DOHX3r0K.js +2 -0
- package/packages/web/dist/assets/LoadState-C4VYnFly.css +1 -0
- package/packages/web/dist/assets/LoadState-DeXfLvYv.js +2 -0
- package/packages/web/dist/assets/McpDialog-BSCt_jWB.css +1 -0
- package/packages/web/dist/assets/McpDialog-CA_0WKWF.js +2 -0
- package/packages/web/dist/assets/McpServerForm-CAG8Wp2N.js +2 -0
- package/packages/web/dist/assets/McpServerForm-DsHaf5Um.css +1 -0
- package/packages/web/dist/assets/McpServerView-7I76EznB.css +1 -0
- package/packages/web/dist/assets/McpServerView-CD8qw6W_.js +2 -0
- package/packages/web/dist/assets/McpServersView-DNycG35u.js +2 -0
- package/packages/web/dist/assets/McpView-CC2oNOMa.js +2 -0
- package/packages/web/dist/assets/McpView-W5PhGI4_.css +1 -0
- package/packages/web/dist/assets/McpsView-CwJvyyxV.js +2 -0
- package/packages/web/dist/assets/McpsView-yH-K4ifd.css +1 -0
- package/packages/web/dist/assets/MemoryDialog-CpfIsygL.css +1 -0
- package/packages/web/dist/assets/MemoryDialog-Dbvh5uLq.js +2 -0
- package/packages/web/dist/assets/ModelCallsView-B__CIDge.css +1 -0
- package/packages/web/dist/assets/ModelCallsView-RvnW3EBP.js +2 -0
- package/packages/web/dist/assets/ModelPicker-5BC8W10p.css +1 -0
- package/packages/web/dist/assets/ModelPicker-DcjwQFHC.js +2 -0
- package/packages/web/dist/assets/ModelsView-C_iN19xt.js +2 -0
- package/packages/web/dist/assets/ModelsView-DjD8H9vc.css +1 -0
- package/packages/web/dist/assets/NotFoundPage-CeSwzTV-.js +2 -0
- package/packages/web/dist/assets/NotFoundPage-ZUNomG9O.css +1 -0
- package/packages/web/dist/assets/PairPage-Bs2KuRjC.css +1 -0
- package/packages/web/dist/assets/PairPage-TEXPpsqi.js +2 -0
- package/packages/web/dist/assets/PanelHost-BkrFAnPa.js +2 -0
- package/packages/web/dist/assets/PanelHost-_z5RyAnS.css +1 -0
- package/packages/web/dist/assets/PeopleView-CJ8yArTh.css +1 -0
- package/packages/web/dist/assets/PeopleView-D1QGPYp7.js +2 -0
- package/packages/web/dist/assets/PoliciesView-BU1fudNF.js +2 -0
- package/packages/web/dist/assets/PoliciesView-yVE8d8mj.css +1 -0
- package/packages/web/dist/assets/RefusalList-B3OBAsYc.css +1 -0
- package/packages/web/dist/assets/RefusalList-DQoyUoPG.js +2 -0
- package/packages/web/dist/assets/RemoteAuthFields-Dm44vz2t.css +1 -0
- package/packages/web/dist/assets/RemoteAuthFields-nxGWfmhf.js +2 -0
- package/packages/web/dist/assets/ResourceViewer-A9ZSaLUH.css +1 -0
- package/packages/web/dist/assets/ResourceViewer-Po24y4pj.js +2 -0
- package/packages/web/dist/assets/ResourcesPage-YluNBqIv.js +2 -0
- package/packages/web/dist/assets/ResourcesPage-mr0U0l6U.css +1 -0
- package/packages/web/dist/assets/ResultGrid-CuUQyTjW.css +1 -0
- package/packages/web/dist/assets/ResultGrid-uoq4yUYj.js +2 -0
- package/packages/web/dist/assets/ReviewSummaryStrip-B3ZQs5wR.css +1 -0
- package/packages/web/dist/assets/ReviewSummaryStrip-k3HevESg.js +2 -0
- package/packages/web/dist/assets/ReviewView-79Z5rU1v.js +3 -0
- package/packages/web/dist/assets/ReviewView-CxbVjz_R.css +1 -0
- package/packages/web/dist/assets/RuleRow-CG_XCvUu.css +1 -0
- package/packages/web/dist/assets/RuleRow-CoXDA-SH.js +2 -0
- package/packages/web/dist/assets/RunCard-CBSGdwdQ.js +2 -0
- package/packages/web/dist/assets/RunCard-CfyRaDLS.css +1 -0
- package/packages/web/dist/assets/RunDetails-CGhQQ6OI.js +2 -0
- package/packages/web/dist/assets/RunDetails-CHHCWGrP.css +1 -0
- package/packages/web/dist/assets/RunDot-Ch_45985.js +2 -0
- package/packages/web/dist/assets/RunDot-CkNUsFwg.css +1 -0
- package/packages/web/dist/assets/RunPage-C_t20pB7.js +2 -0
- package/packages/web/dist/assets/RunPage-Cq6UV6h-.css +1 -0
- package/packages/web/dist/assets/RunProgress-Bq2yc7Il.css +1 -0
- package/packages/web/dist/assets/RunProgress-VrZUHUEC.js +2 -0
- package/packages/web/dist/assets/RunsView-Dz9Xsvu5.js +2 -0
- package/packages/web/dist/assets/RunsView-fBMrETRF.css +1 -0
- package/packages/web/dist/assets/ServiceRows-6BU4-MeL.css +1 -0
- package/packages/web/dist/assets/ServiceRows-DNzDiutg.js +2 -0
- package/packages/web/dist/assets/SettingsPage-CykfuYj1.js +3 -0
- package/packages/web/dist/assets/SettingsPage-t03BqXw8.css +1 -0
- package/packages/web/dist/assets/SignInPage-Djx-M-0U.css +1 -0
- package/packages/web/dist/assets/SignInPage-DrXZ1sG2.js +2 -0
- package/packages/web/dist/assets/StatusBadge-Dpb9uG5e.js +2 -0
- package/packages/web/dist/assets/SystemConfig-72qKRkUk.js +2 -0
- package/packages/web/dist/assets/SystemConfig-CDtMyVWy.css +1 -0
- package/packages/web/dist/assets/SystemPageHost-BeZ-6N0-.css +1 -0
- package/packages/web/dist/assets/SystemPageHost-DLNg2FYK.js +2 -0
- package/packages/web/dist/assets/SystemView-C8ScHUe2.css +1 -0
- package/packages/web/dist/assets/SystemView-Es5wtkYU.js +2 -0
- package/packages/web/dist/assets/SystemsView-B6HEL9VS.css +1 -0
- package/packages/web/dist/assets/SystemsView-CeuSFhlF.js +2 -0
- package/packages/web/dist/assets/TableViewer-1Jf5BNat.css +1 -0
- package/packages/web/dist/assets/TableViewer-BQ7bYLOP.js +6 -0
- package/packages/web/dist/assets/ThemePicker-C2nJ21Vd.js +2 -0
- package/packages/web/dist/assets/TurnTree-CORdfTHj.js +2 -0
- package/packages/web/dist/assets/TurnTree-CPivE4sF.css +1 -0
- package/packages/web/dist/assets/UserMessage-BtECa8ka.css +1 -0
- package/packages/web/dist/assets/UserMessage-qyc8dG5D.js +9 -0
- package/packages/web/dist/assets/ValueVisual-D5Rw7PlS.css +1 -0
- package/packages/web/dist/assets/ValueVisual-aXEUaQ5Y.js +2 -0
- package/packages/web/dist/assets/WidgetView-BZyDyYRI.js +3 -0
- package/packages/web/dist/assets/WidgetView-DQUDeFkB.css +1 -0
- package/packages/web/dist/assets/_plugin-vue_export-helper-BDNMzG2s.js +1 -0
- package/packages/web/dist/assets/abap-CLvhMVsD.js +2 -0
- package/packages/web/dist/assets/abnfDiagram-S7VZAUFO-CzFPJy4G.js +2 -0
- package/packages/web/dist/assets/actionscript-3-Cs6JJXT5.js +2 -0
- package/packages/web/dist/assets/ada-X3Y2mlq2.js +2 -0
- package/packages/web/dist/assets/ahk-DwADkxyd.js +2 -0
- package/packages/web/dist/assets/ahk2-_6rzW9BS.js +2 -0
- package/packages/web/dist/assets/angular-html-wiqevbIE.js +2 -0
- package/packages/web/dist/assets/angular-ts-C32iChAu.js +2 -0
- package/packages/web/dist/assets/apache-U0d_L8uA.js +2 -0
- package/packages/web/dist/assets/apex-KFGFyKwG.js +2 -0
- package/packages/web/dist/assets/apl-Bl61Unn0.js +2 -0
- package/packages/web/dist/assets/applescript-CCn79oCD.js +2 -0
- package/packages/web/dist/assets/ara-4CJ0cIlV.js +2 -0
- package/packages/web/dist/assets/architecture-WOLXFQ4H-_l4nRfFJ.js +1 -0
- package/packages/web/dist/assets/architectureDiagram-YGSQEFNW-CMpVysh5.js +37 -0
- package/packages/web/dist/assets/asciidoc-SCjQUq34.js +2 -0
- package/packages/web/dist/assets/asm-Cmm7eHzH.js +2 -0
- package/packages/web/dist/assets/astro-CojMNcHO.js +2 -0
- package/packages/web/dist/assets/awk-BWXHIvNe.js +2 -0
- package/packages/web/dist/assets/ballerina-B7ZEbQpA.js +2 -0
- package/packages/web/dist/assets/bat-qdxAdBWQ.js +2 -0
- package/packages/web/dist/assets/beancount-C2IN4Vk8.js +2 -0
- package/packages/web/dist/assets/berry-DKpUyyne.js +2 -0
- package/packages/web/dist/assets/bibtex-Ci_nEsc7.js +2 -0
- package/packages/web/dist/assets/bicep-CUHmPFLl.js +2 -0
- package/packages/web/dist/assets/bird2-CYIUgYqB.js +2 -0
- package/packages/web/dist/assets/blade-CRk3fo4p.js +2 -0
- package/packages/web/dist/assets/blockDiagram-APKKGZFW-Jua4t10S.js +141 -0
- package/packages/web/dist/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +2 -0
- package/packages/web/dist/assets/browser-BHOqNy7R.js +9 -0
- package/packages/web/dist/assets/browsers-BSc3bW3l.js +2 -0
- package/packages/web/dist/assets/bsl-_VjlB9mv.js +2 -0
- package/packages/web/dist/assets/c-CiNtTPN_.js +2 -0
- package/packages/web/dist/assets/c3-D0apG41V.js +2 -0
- package/packages/web/dist/assets/c4Diagram-KJ2TOQU5-08x9w6G9.js +39 -0
- package/packages/web/dist/assets/cadence-CQ2zXKGN.js +2 -0
- package/packages/web/dist/assets/cairo-DLTphjLi.js +2 -0
- package/packages/web/dist/assets/chapel-D5ik6Ccv.js +2 -0
- package/packages/web/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +2 -0
- package/packages/web/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +16 -0
- package/packages/web/dist/assets/chunk-6MUBBAK2-BHXbrulB.js +3 -0
- package/packages/web/dist/assets/chunk-AXFCVDMN-CI0arS1F.js +63 -0
- package/packages/web/dist/assets/chunk-BG4553SI-DGn4S0JL.js +130 -0
- package/packages/web/dist/assets/chunk-DQASFODM-ClbbgMVy.js +11 -0
- package/packages/web/dist/assets/chunk-DUW6YSOI-Dgx8z5s3.js +2 -0
- package/packages/web/dist/assets/chunk-HFQBQIA3-BNltuj9p.js +2 -0
- package/packages/web/dist/assets/chunk-J5ZVWO5B-oDCd-gWO.js +2 -0
- package/packages/web/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +2 -0
- package/packages/web/dist/assets/chunk-KQLB2F66-DsHe5EtY.js +3 -0
- package/packages/web/dist/assets/chunk-KS47KZWR-BZg3mYeD.js +2 -0
- package/packages/web/dist/assets/chunk-LEVMRMFU-paszafIt.js +2 -0
- package/packages/web/dist/assets/chunk-M57EVK23-qYz6TUV4.js +2 -0
- package/packages/web/dist/assets/chunk-NGNAAXSQ-DI_UYJZ4.js +137 -0
- package/packages/web/dist/assets/chunk-OY52VR5R-Ct_YDCfL.js +89 -0
- package/packages/web/dist/assets/chunk-QB3YPZ4I-i7-AWGNa.js +214 -0
- package/packages/web/dist/assets/chunk-R3KSYZAL-DW0WB_9q.js +2 -0
- package/packages/web/dist/assets/chunk-STOXU5M4-D5Gd-wq9.js +73 -0
- package/packages/web/dist/assets/chunk-TU62E6Q5-WtwDME_1.js +2 -0
- package/packages/web/dist/assets/chunk-X4PVCEUW-YYhMSieL.js +2 -0
- package/packages/web/dist/assets/chunk-XXDRQBXY-i7MKP1NY.js +2 -0
- package/packages/web/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +2 -0
- package/packages/web/dist/assets/clarity-CtfBBspg.js +2 -0
- package/packages/web/dist/assets/classDiagram-v2-L25IHNXF-d25-M1pJ.js +218 -0
- package/packages/web/dist/assets/clojure-DqKBuwfJ.js +2 -0
- package/packages/web/dist/assets/cmake-Bj61d0ZC.js +2 -0
- package/packages/web/dist/assets/cobol-BRB8FTbz.js +2 -0
- package/packages/web/dist/assets/codeowners-C8r90Shi.js +2 -0
- package/packages/web/dist/assets/codeql-oeQT6MSM.js +2 -0
- package/packages/web/dist/assets/coffee-B1WQFatZ.js +2 -0
- package/packages/web/dist/assets/common-lisp-Cv5bFMCO.js +2 -0
- package/packages/web/dist/assets/coq-CGaSfhwR.js +2 -0
- package/packages/web/dist/assets/core-DdF778CY.js +13 -0
- package/packages/web/dist/assets/cose-bilkent-JH36ORCC-CYLhHv3W.js +2 -0
- package/packages/web/dist/assets/cpp-CxyntmKf.js +2 -0
- package/packages/web/dist/assets/crystal-CayBj_Aw.js +2 -0
- package/packages/web/dist/assets/csharp-dmMxLVLW.js +2 -0
- package/packages/web/dist/assets/css-CB_fh0k2.js +2 -0
- package/packages/web/dist/assets/csv-Dx-8-gkx.js +2 -0
- package/packages/web/dist/assets/cue-CE9AQfxI.js +2 -0
- package/packages/web/dist/assets/cynefin-EF2NZ3EQ-BOE_VX_3.js +1 -0
- package/packages/web/dist/assets/cynefinDiagram-L36ESFBY-cDLwrPve.js +63 -0
- package/packages/web/dist/assets/cypher-ClKdZ_lG.js +2 -0
- package/packages/web/dist/assets/cytoscape.esm-DpfQbjy7.js +322 -0
- package/packages/web/dist/assets/d-qD-0Kul2.js +2 -0
- package/packages/web/dist/assets/d3-scale-CElPUUud.js +2 -0
- package/packages/web/dist/assets/d3-selection-COWvaQNI.js +2 -0
- package/packages/web/dist/assets/dagre-SPEB5RXH-ChUYszsQ.js +5 -0
- package/packages/web/dist/assets/dart-CHZY9Xhz.js +2 -0
- package/packages/web/dist/assets/dax-BkyTk9wS.js +2 -0
- package/packages/web/dist/assets/desktop-Dlh5hvp9.js +2 -0
- package/packages/web/dist/assets/diagram-3B7GL73J-C4RMi43c.js +201 -0
- package/packages/web/dist/assets/diagram-DNEMPZML-COQGGiEP.js +25 -0
- package/packages/web/dist/assets/diagram-L3MUGCDN-mowv9Itp.js +42 -0
- package/packages/web/dist/assets/diagram-LA4NIPWU-hNJQSGhv.js +25 -0
- package/packages/web/dist/assets/diagram-MHCOC4E2-Dp-COOAx.js +4 -0
- package/packages/web/dist/assets/diagram-XPFHEONP-D2wzCykS.js +31 -0
- package/packages/web/dist/assets/diff-woXpYk--.js +2 -0
- package/packages/web/dist/assets/dist-DdXDFcej.js +2 -0
- package/packages/web/dist/assets/docker-IyjqRm3v.js +2 -0
- package/packages/web/dist/assets/dotenv-CuH5my32.js +2 -0
- package/packages/web/dist/assets/dream-maker-DW3nJb8Q.js +2 -0
- package/packages/web/dist/assets/ebnfDiagram-UZSYDL2S-5WCudwet.js +2 -0
- package/packages/web/dist/assets/edge-6p6a27tD.js +2 -0
- package/packages/web/dist/assets/elixir-fXwtrlGU.js +2 -0
- package/packages/web/dist/assets/elk-XV6XMXQE-BknTcAbm.js +28 -0
- package/packages/web/dist/assets/elm-rUi9A3mh.js +2 -0
- package/packages/web/dist/assets/emacs-lisp-DR2vtWaj.js +2 -0
- package/packages/web/dist/assets/engine-javascript-C30F4iNc.js +142 -0
- package/packages/web/dist/assets/erDiagram-EYBAPDEH-UOE6iZ1t.js +100 -0
- package/packages/web/dist/assets/erb-BvmuIdN-.js +2 -0
- package/packages/web/dist/assets/erlang-Cphh6RMH.js +2 -0
- package/packages/web/dist/assets/eventmodeling-K75KTNOO-CIs2h_8S.js +1 -0
- package/packages/web/dist/assets/export-BwFkEtcm.js +15 -0
- package/packages/web/dist/assets/fennel-DQxkIbk2.js +2 -0
- package/packages/web/dist/assets/fish-BJitypiv.js +2 -0
- package/packages/web/dist/assets/flowDiagram-MALGAFMO-CQLEuZ0I.js +1 -0
- package/packages/web/dist/assets/fluent-C03EYrpw.js +2 -0
- package/packages/web/dist/assets/fn-modal-DqcxUhOQ.js +2 -0
- package/packages/web/dist/assets/fn-notices-BYaH6IoA.js +2 -0
- package/packages/web/dist/assets/fn-notices-Da4tVHqJ.css +1 -0
- package/packages/web/dist/assets/formats-DI__ADVG.js +2 -0
- package/packages/web/dist/assets/fortran-fixed-form-DEKoE2YW.js +2 -0
- package/packages/web/dist/assets/fortran-free-form-CYNrtFtB.js +2 -0
- package/packages/web/dist/assets/fsharp-D13ZGOAj.js +2 -0
- package/packages/web/dist/assets/ganttDiagram-23REXITY-KBK93CXW.js +293 -0
- package/packages/web/dist/assets/gdresource-xMC7jr7x.js +2 -0
- package/packages/web/dist/assets/gdscript-DYvRD3hg.js +2 -0
- package/packages/web/dist/assets/gdshader-CBce3t8t.js +2 -0
- package/packages/web/dist/assets/genie-CV2tkWYe.js +2 -0
- package/packages/web/dist/assets/gherkin-DExj1W_8.js +2 -0
- package/packages/web/dist/assets/git-commit-BSykSTBG.js +2 -0
- package/packages/web/dist/assets/git-rebase-B09wAERM.js +2 -0
- package/packages/web/dist/assets/gitGraph-VSP46ZUC-Dwmw1QLM.js +1 -0
- package/packages/web/dist/assets/gitGraphDiagram-STJD7YCW-B2T13-ZJ.js +107 -0
- package/packages/web/dist/assets/gleam-CSRkHgEL.js +2 -0
- package/packages/web/dist/assets/glimmer-js-CpWvy9gf.js +2 -0
- package/packages/web/dist/assets/glimmer-ts-BAH8Czr9.js +2 -0
- package/packages/web/dist/assets/glsl-CVY0WJyt.js +2 -0
- package/packages/web/dist/assets/gn-CAXYAgV-.js +2 -0
- package/packages/web/dist/assets/gnuplot-7GGW24-e.js +2 -0
- package/packages/web/dist/assets/go-rLFTqkRN.js +2 -0
- package/packages/web/dist/assets/graphlib-DS17s2tU.js +2 -0
- package/packages/web/dist/assets/graphql-CDPCtuoQ.js +2 -0
- package/packages/web/dist/assets/groovy-CacY0gHj.js +2 -0
- package/packages/web/dist/assets/hack-CLEpeEqq.js +2 -0
- package/packages/web/dist/assets/haml-Bvpgs3uG.js +2 -0
- package/packages/web/dist/assets/handlebars-vXY9zmj1.js +2 -0
- package/packages/web/dist/assets/haskell-D8IpX4py.js +2 -0
- package/packages/web/dist/assets/haxe-C8oCnwJJ.js +2 -0
- package/packages/web/dist/assets/hcl-Dh228itO.js +2 -0
- package/packages/web/dist/assets/hjson-CxZEssPk.js +2 -0
- package/packages/web/dist/assets/hlsl-Cvrh5tZx.js +2 -0
- package/packages/web/dist/assets/html-CKMeXkCW.js +2 -0
- package/packages/web/dist/assets/html-derivative-C8trdkzI.js +2 -0
- package/packages/web/dist/assets/http-UJwVfHv3.js +2 -0
- package/packages/web/dist/assets/hurl-7erhC4fM.js +2 -0
- package/packages/web/dist/assets/hxml-Dcm88srW.js +2 -0
- package/packages/web/dist/assets/hy-CZbG8q4J.js +2 -0
- package/packages/web/dist/assets/imba-DsUTQ-LC.js +2 -0
- package/packages/web/dist/assets/index-Bv42jNvr.js +4 -0
- package/packages/web/dist/assets/index-CSisx5mi.css +1 -0
- package/packages/web/dist/assets/info-OHQRW6UA-Ob4q-Ec6.js +1 -0
- package/packages/web/dist/assets/infoDiagram-KBXO4MBG-CGQ6MwL3.js +3 -0
- package/packages/web/dist/assets/ini-B5eOa1yu.js +2 -0
- package/packages/web/dist/assets/ishikawaDiagram-M35NCXHK-CuoxiCk-.js +71 -0
- package/packages/web/dist/assets/java-DGv6_9mf.js +2 -0
- package/packages/web/dist/assets/javascript-wyDA4Fnk.js +2 -0
- package/packages/web/dist/assets/jinja-CRKn4_DT.js +2 -0
- package/packages/web/dist/assets/jison-C5fjf-e-.js +2 -0
- package/packages/web/dist/assets/journeyDiagram-OPLOXDXO-zEDEMkq6.js +140 -0
- package/packages/web/dist/assets/json-B_qwZ7m_.js +2 -0
- package/packages/web/dist/assets/json5-BR5RXkoi.js +2 -0
- package/packages/web/dist/assets/jsonc-CYpm1nAK.js +2 -0
- package/packages/web/dist/assets/jsonl-CmCQp5Yx.js +2 -0
- package/packages/web/dist/assets/jsonnet-CJTPZ8u_.js +2 -0
- package/packages/web/dist/assets/jssm-DXw9l8Rf.js +2 -0
- package/packages/web/dist/assets/jsx-Ba8EQqYd.js +2 -0
- package/packages/web/dist/assets/julia-mJS6zhvp.js +2 -0
- package/packages/web/dist/assets/just-n_L73pBN.js +2 -0
- package/packages/web/dist/assets/kanban-definition-BZKZHSQY-q5yqVxKo.js +90 -0
- package/packages/web/dist/assets/katex-MEuSR36T.js +258 -0
- package/packages/web/dist/assets/kdl-CsD5j6eV.js +2 -0
- package/packages/web/dist/assets/kotlin-DhhofPvG.js +2 -0
- package/packages/web/dist/assets/kusto-C7mF5XQf.js +2 -0
- package/packages/web/dist/assets/labels-BhJpmLWA.js +2 -0
- package/packages/web/dist/assets/langs-CVIiVMBh.js +3 -0
- package/packages/web/dist/assets/latex-0iQGLWul.js +2 -0
- package/packages/web/dist/assets/layout-DQKldU13.js +2 -0
- package/packages/web/dist/assets/lean-CewbzKMR.js +2 -0
- package/packages/web/dist/assets/less-DVTAwKKz.js +2 -0
- package/packages/web/dist/assets/liquid-B8kEVR50.js +2 -0
- package/packages/web/dist/assets/live-kTMxmy8I.js +2 -0
- package/packages/web/dist/assets/llvm-DqHOMS-s.js +2 -0
- package/packages/web/dist/assets/log-BNLmms1o.js +2 -0
- package/packages/web/dist/assets/logo-Cluzi2Zq.js +2 -0
- package/packages/web/dist/assets/lua-BDnDZ8k4.js +2 -0
- package/packages/web/dist/assets/luau-VGWVLoqX.js +2 -0
- package/packages/web/dist/assets/made-DYU0Ohi4.js +2 -0
- package/packages/web/dist/assets/make-Dixweg8N.js +2 -0
- package/packages/web/dist/assets/markdown-BYOwaDjH.js +2 -0
- package/packages/web/dist/assets/marko-Bk0_iGvT.js +2 -0
- package/packages/web/dist/assets/matlab-D7qyCx1q.js +2 -0
- package/packages/web/dist/assets/mdc-DhizV3YK.js +2 -0
- package/packages/web/dist/assets/mdx-DQZ5AkYe.js +2 -0
- package/packages/web/dist/assets/mermaid-BxpfTIzt.js +2 -0
- package/packages/web/dist/assets/mermaid-parser.core-BGN5zmcs.js +8 -0
- package/packages/web/dist/assets/mermaid.core-BNF3dRf5.js +45 -0
- package/packages/web/dist/assets/metrics-Cio5ykX6.js +2 -0
- package/packages/web/dist/assets/mindmap-definition-I2QAS2VK-CoiSJ4W4.js +99 -0
- package/packages/web/dist/assets/mipsasm-BMqwQI7S.js +2 -0
- package/packages/web/dist/assets/mojo-fg40_ntQ.js +2 -0
- package/packages/web/dist/assets/moonbit-D9W784E_.js +2 -0
- package/packages/web/dist/assets/move-BYnGhZoM.js +2 -0
- package/packages/web/dist/assets/narrat-_X_XdTYD.js +2 -0
- package/packages/web/dist/assets/nextflow-CSgcYZcx.js +2 -0
- package/packages/web/dist/assets/nextflow-groovy-D7IRt6Pp.js +2 -0
- package/packages/web/dist/assets/nginx-DoalMtUh.js +2 -0
- package/packages/web/dist/assets/nim-DdsQnl3h.js +2 -0
- package/packages/web/dist/assets/nix-IvuFDN5E.js +2 -0
- package/packages/web/dist/assets/now-40JhSjx0.js +2 -0
- package/packages/web/dist/assets/nsis-CjNLYCLg.js +2 -0
- package/packages/web/dist/assets/nushell--0fT3PI1.js +2 -0
- package/packages/web/dist/assets/objective-c-D1A_Heim.js +2 -0
- package/packages/web/dist/assets/objective-cpp-BsSzOQcm.js +2 -0
- package/packages/web/dist/assets/ocaml-O90oeIOV.js +2 -0
- package/packages/web/dist/assets/odin-B1RWQWA5.js +2 -0
- package/packages/web/dist/assets/openscad-BUDT5pXO.js +2 -0
- package/packages/web/dist/assets/org-B2d-Pz26.js +2 -0
- package/packages/web/dist/assets/packet-JDAUHWVQ-kID5-AEG.js +1 -0
- package/packages/web/dist/assets/pascal-4ZHwLPI5.js +2 -0
- package/packages/web/dist/assets/pdf-YwugTw7Y.js +55 -0
- package/packages/web/dist/assets/pdf.worker.min-CIqJB0yW.mjs +28 -0
- package/packages/web/dist/assets/pdf.worker.min-UqOn5EDC.js +2 -0
- package/packages/web/dist/assets/pegDiagram-FD4XPPHP-DvO7r8qd.js +2 -0
- package/packages/web/dist/assets/perl-CpJxFnsT.js +2 -0
- package/packages/web/dist/assets/php-CG5ES-ob.js +2 -0
- package/packages/web/dist/assets/pie-XZMESJXO-By0gro0O.js +1 -0
- package/packages/web/dist/assets/pieDiagram-J4AKIIQI-f_Jeo_8D.js +40 -0
- package/packages/web/dist/assets/pkl-ot-7Btpt.js +2 -0
- package/packages/web/dist/assets/plsql-DGHpHOYJ.js +2 -0
- package/packages/web/dist/assets/po-BiJDBrnU.js +2 -0
- package/packages/web/dist/assets/polar-C7UOKdEL.js +2 -0
- package/packages/web/dist/assets/postcss-BXeXVLqQ.js +2 -0
- package/packages/web/dist/assets/powerquery-DNMTfnFr.js +2 -0
- package/packages/web/dist/assets/powershell-QtSnmXcu.js +2 -0
- package/packages/web/dist/assets/preload-helper-7y9sWmk5.js +1 -0
- package/packages/web/dist/assets/prisma-DMgNhnYS.js +2 -0
- package/packages/web/dist/assets/problems-BZY0Dwif.js +2 -0
- package/packages/web/dist/assets/prolog-iXnhIJG7.js +2 -0
- package/packages/web/dist/assets/proto-DB4EqR-F.js +2 -0
- package/packages/web/dist/assets/pug-b31sGWmp.js +2 -0
- package/packages/web/dist/assets/puppet-CDv2pdJW.js +2 -0
- package/packages/web/dist/assets/purescript-9MfHhQsQ.js +2 -0
- package/packages/web/dist/assets/push-payload-D5efGCzd.js +402 -0
- package/packages/web/dist/assets/python-gzcpVVnB.js +2 -0
- package/packages/web/dist/assets/qml-Dd7VLkrA.js +2 -0
- package/packages/web/dist/assets/qmldir-DCQb3MpD.js +2 -0
- package/packages/web/dist/assets/qss-Fe1Jh2GI.js +2 -0
- package/packages/web/dist/assets/quadrantDiagram-XTYBLID2-Cr6SWkGn.js +8 -0
- package/packages/web/dist/assets/r-yyMNTq5r.js +2 -0
- package/packages/web/dist/assets/racket-DcIDlBhZ.js +2 -0
- package/packages/web/dist/assets/radar-ABXABTNO-yHosJs_M.js +1 -0
- package/packages/web/dist/assets/railroad-I3PHUGI6-C-LR5A-v.js +1 -0
- package/packages/web/dist/assets/railroad-abnf-LNEFI6M7-DjGnF9uf.js +1 -0
- package/packages/web/dist/assets/railroad-ebnf-DWYD2UWJ-BgsDVMJk.js +1 -0
- package/packages/web/dist/assets/railroad-peg-JR7BVNR7-DkSNpypW.js +1 -0
- package/packages/web/dist/assets/railroadDiagram-MRQ6NCDL-BdGdKtFJ.js +2 -0
- package/packages/web/dist/assets/raku-B3gFvitq.js +2 -0
- package/packages/web/dist/assets/razor-B0rzWF9b.js +2 -0
- package/packages/web/dist/assets/rbs-C0MpOrj4.js +2 -0
- package/packages/web/dist/assets/record-edits-CveFEsal.js +2 -0
- package/packages/web/dist/assets/reg-CRGYupPL.js +2 -0
- package/packages/web/dist/assets/regexp-DYMieNym.js +2 -0
- package/packages/web/dist/assets/rel-BtDbiS_P.js +2 -0
- package/packages/web/dist/assets/remote-config-BkaarDf3.js +2 -0
- package/packages/web/dist/assets/requirementDiagram-Y7LWUY3S-ImkACz5a.js +85 -0
- package/packages/web/dist/assets/review-CGUGvRV9.js +4 -0
- package/packages/web/dist/assets/riscv-Ckw8ddFX.js +2 -0
- package/packages/web/dist/assets/rolldown-runtime-COiEfhsA.js +1 -0
- package/packages/web/dist/assets/ron-VUp2lXgN.js +2 -0
- package/packages/web/dist/assets/rosmsg-CAekHB0j.js +2 -0
- package/packages/web/dist/assets/rough.esm-Dy-Kn_BL.js +2 -0
- package/packages/web/dist/assets/routes-qP_j74V5.js +4 -0
- package/packages/web/dist/assets/rst-BtnuOAUZ.js +2 -0
- package/packages/web/dist/assets/ruby-Dx9fBFuB.js +2 -0
- package/packages/web/dist/assets/runs-k76usGfd.js +2 -0
- package/packages/web/dist/assets/runtime-core.esm-bundler-wlpNGAAZ.js +4 -0
- package/packages/web/dist/assets/rust-DpiIf5JO.js +2 -0
- package/packages/web/dist/assets/sankeyDiagram-WGJFYUXA-Crpx7BLQ.js +41 -0
- package/packages/web/dist/assets/sas-CYVU3X7O.js +2 -0
- package/packages/web/dist/assets/sass-DXrisJhu.js +2 -0
- package/packages/web/dist/assets/scala-BiFt_7mu.js +2 -0
- package/packages/web/dist/assets/scheme-DQCgrYNe.js +2 -0
- package/packages/web/dist/assets/scss-BAOTDanj.js +2 -0
- package/packages/web/dist/assets/sdbl-bTVj8UrX.js +2 -0
- package/packages/web/dist/assets/sequenceDiagram-5NDRBG5M-Ch5L-aWg.js +170 -0
- package/packages/web/dist/assets/shaderlab-TOUzSsQk.js +2 -0
- package/packages/web/dist/assets/shared-DTpYDMc_.js +2 -0
- package/packages/web/dist/assets/shellscript-DUxm18QR.js +2 -0
- package/packages/web/dist/assets/shellsession-DphNsVk1.js +2 -0
- package/packages/web/dist/assets/size-BwnshyOe.js +2 -0
- package/packages/web/dist/assets/sizeCapture-INFHLROL-3uHXrFqA.js +2 -0
- package/packages/web/dist/assets/smalltalk-BHpQb5nM.js +2 -0
- package/packages/web/dist/assets/smithy-Dgaz7aur.js +2 -0
- package/packages/web/dist/assets/solidity-Bj7E1mRn.js +2 -0
- package/packages/web/dist/assets/sources-Bm-TrxhL.js +2 -0
- package/packages/web/dist/assets/soy-BprueKgI.js +2 -0
- package/packages/web/dist/assets/sparql-D_iOobhT.js +2 -0
- package/packages/web/dist/assets/splunk-BC2Px7Mm.js +2 -0
- package/packages/web/dist/assets/sql-D4n2TlMc.js +2 -0
- package/packages/web/dist/assets/src-DLK1P7oz.js +43 -0
- package/packages/web/dist/assets/ssh-config-BgfXC-Er.js +2 -0
- package/packages/web/dist/assets/stata-D3X-un4D.js +2 -0
- package/packages/web/dist/assets/state-CjE-qA2w.js +2 -0
- package/packages/web/dist/assets/state-J8VdpZXA.css +1 -0
- package/packages/web/dist/assets/stateDiagram-v2-FJ4FJNEA-8fpbogV7.js +292 -0
- package/packages/web/dist/assets/stores-BMEvTe-I.js +2 -0
- package/packages/web/dist/assets/stylus-B6D30XZt.js +2 -0
- package/packages/web/dist/assets/surrealql-5--I0FKd.js +2 -0
- package/packages/web/dist/assets/svelte-DlUga76i.js +2 -0
- package/packages/web/dist/assets/swift-CyEgAFGc.js +2 -0
- package/packages/web/dist/assets/swimlanes-UMQ2AFYF-2-xKzyRO.js +2 -0
- package/packages/web/dist/assets/swimlanesDiagram-OMPLPG4O-DHJrYwQz.js +9 -0
- package/packages/web/dist/assets/system-verilog-Dh5ihWbf.js +2 -0
- package/packages/web/dist/assets/systemd-BxMlprV5.js +2 -0
- package/packages/web/dist/assets/systems-DIp94AET.js +2 -0
- package/packages/web/dist/assets/table-LcEs15kL.js +4 -0
- package/packages/web/dist/assets/talonscript-CohzipZa.js +2 -0
- package/packages/web/dist/assets/tasl-DMoTqEGO.js +2 -0
- package/packages/web/dist/assets/tcl-CZd0xW_V.js +2 -0
- package/packages/web/dist/assets/templ-SgILQMBm.js +2 -0
- package/packages/web/dist/assets/terraform-DswuEJGm.js +2 -0
- package/packages/web/dist/assets/tex-B_j0g-0C.js +2 -0
- package/packages/web/dist/assets/timeline-definition-SEUHKTQE-Czq0i_qO.js +121 -0
- package/packages/web/dist/assets/toml-CcmNWLt0.js +2 -0
- package/packages/web/dist/assets/treeView-D4JQ5SDB-B3NKij_H.js +1 -0
- package/packages/web/dist/assets/treemap-SAJKECNS-Dt7uNpkP.js +1 -0
- package/packages/web/dist/assets/ts-tags-Bb2M6NRT.js +2 -0
- package/packages/web/dist/assets/tsv-sltzmVWM.js +2 -0
- package/packages/web/dist/assets/tsx-D2H2cqPj.js +2 -0
- package/packages/web/dist/assets/turtle-ByJddavk.js +2 -0
- package/packages/web/dist/assets/twig-DqWgw3C7.js +2 -0
- package/packages/web/dist/assets/types-D1t1HqPm.js +2 -0
- package/packages/web/dist/assets/typescript-DVfyLS1i.js +2 -0
- package/packages/web/dist/assets/typespec-BGhR2SqG.js +2 -0
- package/packages/web/dist/assets/typst-Cs7gYQVT.js +2 -0
- package/packages/web/dist/assets/ui-C7ZH_6oC.css +1 -0
- package/packages/web/dist/assets/ui-W12UYhVu.js +17 -0
- package/packages/web/dist/assets/url-BIg5IhGs.js +2 -0
- package/packages/web/dist/assets/usecaseDiagram-AFA6YXN4-D3m4xj4y.js +329 -0
- package/packages/web/dist/assets/v-DBj4K9d_.js +2 -0
- package/packages/web/dist/assets/vala-zf12oZj6.js +2 -0
- package/packages/web/dist/assets/vb-DOwzaHZ0.js +2 -0
- package/packages/web/dist/assets/vennDiagram-NNMJR3RB-DeIkukMz.js +35 -0
- package/packages/web/dist/assets/verilog-B2gwz-sJ.js +2 -0
- package/packages/web/dist/assets/vhdl-BroJfC0k.js +2 -0
- package/packages/web/dist/assets/viml-DvXPmvsu.js +2 -0
- package/packages/web/dist/assets/vue-D0OpHdq8.js +2 -0
- package/packages/web/dist/assets/vue-html-DYZahZaV.js +2 -0
- package/packages/web/dist/assets/vue-vine-BsFhbSla.js +2 -0
- package/packages/web/dist/assets/vyper-CgoNMtux.js +2 -0
- package/packages/web/dist/assets/wardley-7MLQ67FV-DSzBQKe8.js +1 -0
- package/packages/web/dist/assets/wardleyDiagram-S7YFUSEH-ef9ee0JD.js +79 -0
- package/packages/web/dist/assets/wasm-ByWQv1Qj.js +2 -0
- package/packages/web/dist/assets/wenyan-C8pVoKbM.js +2 -0
- package/packages/web/dist/assets/wgsl-BsKzXJz4.js +2 -0
- package/packages/web/dist/assets/widget-host-BCf6Tlt5.js +2 -0
- package/packages/web/dist/assets/widgets-CrbkovMT.js +2 -0
- package/packages/web/dist/assets/wikitext-ClFFjSW2.js +2 -0
- package/packages/web/dist/assets/wit-DdvCle-K.js +2 -0
- package/packages/web/dist/assets/wolfram-DLL8P-h_.js +2 -0
- package/packages/web/dist/assets/xml-Cz9mX3j0.js +2 -0
- package/packages/web/dist/assets/xsl-fJeiXJlj.js +2 -0
- package/packages/web/dist/assets/xychartDiagram-GGNKY7IX-CuWtZyN1.js +8 -0
- package/packages/web/dist/assets/yaml-BtwsWWqX.js +2 -0
- package/packages/web/dist/assets/zenscript-BnlCZFoB.js +2 -0
- package/packages/web/dist/assets/zig-CMLA9XwU.js +2 -0
- package/packages/web/dist/favicon.svg +1 -0
- package/packages/web/dist/icons/apple-touch-icon.png +0 -0
- package/packages/web/dist/icons/icon-192.png +0 -0
- package/packages/web/dist/icons/icon-512.png +0 -0
- package/packages/web/dist/icons/maskable-512.png +0 -0
- package/packages/web/dist/index.html +95 -0
- package/packages/web/dist/offline.html +39 -0
- package/packages/web/dist/screenshots/narrow.png +0 -0
- package/packages/web/dist/screenshots/wide.png +0 -0
- package/packages/web/dist/sw.js +2 -0
- package/packages/web/dist/zod-config.js +7 -0
- package/packages/web/package.json +25 -0
- package/scripts/dev-env.ts +30 -0
- package/scripts/hub-client.ts +2 -0
- package/scripts/release/link.cjs +73 -0
- package/scripts/run-stack.ts +98 -0
- package/scripts/stack.ts +302 -0
- package/scripts/start.ts +110 -0
- package/scripts/supervise.ts +98 -0
- package/systems/api/package.json +20 -0
- package/systems/api/server/authoring.ts +348 -0
- package/systems/api/server/env.ts +16 -0
- package/systems/api/server/guard.ts +44 -0
- package/systems/api/server/http.ts +274 -0
- package/systems/api/server/impl.ts +233 -0
- package/systems/api/server/index.ts +10 -0
- package/systems/api/server/main.ts +27 -0
- package/systems/api/server/openapi.ts +51 -0
- package/systems/api/server/program.ts +158 -0
- package/systems/api/server/services.ts +121 -0
- package/systems/api/shared/http.ts +61 -0
- package/systems/api/shared/index.ts +244 -0
- package/systems/api/system.json +9 -0
- package/systems/api/tsconfig.json +6 -0
- package/systems/claude/client/FleetPage.vue +132 -0
- package/systems/claude/client/NewSessionForm.vue +62 -0
- package/systems/claude/client/SessionList.vue +64 -0
- package/systems/claude/client/SessionPage.vue +199 -0
- package/systems/claude/client/TaskList.vue +61 -0
- package/systems/claude/client/fakes.ts +186 -0
- package/systems/claude/client/host.ts +23 -0
- package/systems/claude/client/index.ts +15 -0
- package/systems/claude/client/logic.ts +270 -0
- package/systems/claude/client/state.ts +344 -0
- package/systems/claude/package.json +23 -0
- package/systems/claude/server/agent-sdk.ts +379 -0
- package/systems/claude/server/driver.ts +153 -0
- package/systems/claude/server/env.ts +64 -0
- package/systems/claude/server/fake-driver.ts +112 -0
- package/systems/claude/server/fleet.ts +376 -0
- package/systems/claude/server/impl.ts +568 -0
- package/systems/claude/server/index.ts +8 -0
- package/systems/claude/server/main.ts +38 -0
- package/systems/claude/server/preview.ts +76 -0
- package/systems/claude/server/questions.ts +117 -0
- package/systems/claude/server/transcript.ts +83 -0
- package/systems/claude/shared/index.ts +262 -0
- package/systems/claude/shared/session.ts +284 -0
- package/systems/claude/shared/shapes.ts +106 -0
- package/systems/claude/system.json +18 -0
- package/systems/claude/tsconfig.json +6 -0
- package/systems/code/package.json +20 -0
- package/systems/code/server/authoring.ts +233 -0
- package/systems/code/server/env.ts +13 -0
- package/systems/code/server/impl.ts +128 -0
- package/systems/code/server/index.ts +5 -0
- package/systems/code/server/main.ts +27 -0
- package/systems/code/shared/index.ts +130 -0
- package/systems/code/system.json +9 -0
- package/systems/code/tsconfig.json +6 -0
- package/systems/database/package.json +25 -0
- package/systems/database/server/author.ts +41 -0
- package/systems/database/server/authoring.ts +322 -0
- package/systems/database/server/catalog.ts +117 -0
- package/systems/database/server/compile.ts +332 -0
- package/systems/database/server/dialects.ts +17 -0
- package/systems/database/server/drivers/database.ts +71 -0
- package/systems/database/server/drivers/index.ts +23 -0
- package/systems/database/server/drivers/postgres.ts +157 -0
- package/systems/database/server/drivers/sqlite.ts +151 -0
- package/systems/database/server/drivers/sqlserver.ts +176 -0
- package/systems/database/server/env.ts +35 -0
- package/systems/database/server/fixture.ts +169 -0
- package/systems/database/server/impl.ts +793 -0
- package/systems/database/server/index.ts +7 -0
- package/systems/database/server/instance.ts +398 -0
- package/systems/database/server/main.ts +47 -0
- package/systems/database/server/pick.ts +97 -0
- package/systems/database/server/queries.ts +390 -0
- package/systems/database/server/results.ts +39 -0
- package/systems/database/server/schema.ts +59 -0
- package/systems/database/server/table-fns.ts +237 -0
- package/systems/database/server/types.ts +253 -0
- package/systems/database/shared/index.ts +544 -0
- package/systems/database/shared/shapes.ts +413 -0
- package/systems/database/system.json +14 -0
- package/systems/database/tsconfig.json +6 -0
- package/systems/embedder/package.json +19 -0
- package/systems/embedder/server/env.ts +27 -0
- package/systems/embedder/server/http.ts +154 -0
- package/systems/embedder/server/impl.ts +104 -0
- package/systems/embedder/server/index.ts +22 -0
- package/systems/embedder/server/main.ts +37 -0
- package/systems/embedder/server/provider.ts +60 -0
- package/systems/embedder/shared/index.ts +74 -0
- package/systems/embedder/system.json +9 -0
- package/systems/embedder/tsconfig.json +6 -0
- package/systems/fs/client/BashView.vue +165 -0
- package/systems/fs/client/ChangesView.vue +132 -0
- package/systems/fs/client/DiffBody.vue +95 -0
- package/systems/fs/client/DiffView.vue +73 -0
- package/systems/fs/client/EntryInput.vue +102 -0
- package/systems/fs/client/InstallView.vue +72 -0
- package/systems/fs/client/OutputBlock.vue +65 -0
- package/systems/fs/client/bash.ts +40 -0
- package/systems/fs/client/changes.ts +87 -0
- package/systems/fs/client/diff.ts +151 -0
- package/systems/fs/client/fakes.ts +58 -0
- package/systems/fs/client/index.ts +19 -0
- package/systems/fs/client/preview/Preview.vue +70 -0
- package/systems/fs/client/preview/index.html +12 -0
- package/systems/fs/client/preview/main.ts +9 -0
- package/systems/fs/client/preview/shots.ts +71 -0
- package/systems/fs/client/rerun.ts +36 -0
- package/systems/fs/context/authoring/index.md +42 -0
- package/systems/fs/context/authoring/parts/actions.md +56 -0
- package/systems/fs/context/authoring/parts/actions.reference.md +90 -0
- package/systems/fs/context/authoring/parts/calling.md +71 -0
- package/systems/fs/context/authoring/parts/calling.reference.md +134 -0
- package/systems/fs/context/authoring/parts/client.md +273 -0
- package/systems/fs/context/authoring/parts/client.reference/client.md +638 -0
- package/systems/fs/context/authoring/parts/client.reference/fnpillprops.md +141 -0
- package/systems/fs/context/authoring/parts/client.reference/resultview.md +619 -0
- package/systems/fs/context/authoring/parts/client.reference.md +24 -0
- package/systems/fs/context/authoring/parts/context.md +119 -0
- package/systems/fs/context/authoring/parts/context.reference.md +458 -0
- package/systems/fs/context/authoring/parts/contract.md +167 -0
- package/systems/fs/context/authoring/parts/contract.reference.md +286 -0
- package/systems/fs/context/authoring/parts/core-types/access-ts.md +39 -0
- package/systems/fs/context/authoring/parts/core-types/admin-ts.md +41 -0
- package/systems/fs/context/authoring/parts/core-types/api-index-ts.md +28 -0
- package/systems/fs/context/authoring/parts/core-types/approvals-ts.md +494 -0
- package/systems/fs/context/authoring/parts/core-types/auto-pair-ts.md +28 -0
- package/systems/fs/context/authoring/parts/core-types/checks-ts.md +42 -0
- package/systems/fs/context/authoring/parts/core-types/claims-ts.md +26 -0
- package/systems/fs/context/authoring/parts/core-types/config-secrets-ts.md +24 -0
- package/systems/fs/context/authoring/parts/core-types/connections-ts.md +178 -0
- package/systems/fs/context/authoring/parts/core-types/context-files-ts.md +103 -0
- package/systems/fs/context/authoring/parts/core-types/context-graph-ts.md +22 -0
- package/systems/fs/context/authoring/parts/core-types/contextdecl.md +477 -0
- package/systems/fs/context/authoring/parts/core-types/data-ts.md +236 -0
- package/systems/fs/context/authoring/parts/core-types/decisions-ts.md +52 -0
- package/systems/fs/context/authoring/parts/core-types/fn-block-ts.md +31 -0
- package/systems/fs/context/authoring/parts/core-types/fn-facts-ts.md +228 -0
- package/systems/fs/context/authoring/parts/core-types/gin-ts.md +24 -0
- package/systems/fs/context/authoring/parts/core-types/grants-ts.md +55 -0
- package/systems/fs/context/authoring/parts/core-types/lifecycle-ts.md +658 -0
- package/systems/fs/context/authoring/parts/core-types/link-ts.md +410 -0
- package/systems/fs/context/authoring/parts/core-types/llm-ts.md +268 -0
- package/systems/fs/context/authoring/parts/core-types/manifest.md +460 -0
- package/systems/fs/context/authoring/parts/core-types/manifestpatch.md +519 -0
- package/systems/fs/context/authoring/parts/core-types/mention-search-ts.md +29 -0
- package/systems/fs/context/authoring/parts/core-types/model-calls-ts.md +200 -0
- package/systems/fs/context/authoring/parts/core-types/model-names-ts.md +31 -0
- package/systems/fs/context/authoring/parts/core-types/modes-ts.md +89 -0
- package/systems/fs/context/authoring/parts/core-types/owner-runs-ts.md +47 -0
- package/systems/fs/context/authoring/parts/core-types/package-ts.md +83 -0
- package/systems/fs/context/authoring/parts/core-types/primitives-ts.md +170 -0
- package/systems/fs/context/authoring/parts/core-types/query-ts.md +50 -0
- package/systems/fs/context/authoring/parts/core-types/records-actors-ts.md +259 -0
- package/systems/fs/context/authoring/parts/core-types/records-chat-ts.md +217 -0
- package/systems/fs/context/authoring/parts/core-types/records-content-ts.md +24 -0
- package/systems/fs/context/authoring/parts/core-types/records-runs-ts.md +24 -0
- package/systems/fs/context/authoring/parts/core-types/records-systems-ts.md +69 -0
- package/systems/fs/context/authoring/parts/core-types/registries-ts.md +376 -0
- package/systems/fs/context/authoring/parts/core-types/remote-auth-ts.md +60 -0
- package/systems/fs/context/authoring/parts/core-types/resources-ts.md +250 -0
- package/systems/fs/context/authoring/parts/core-types/run-ts.md +425 -0
- package/systems/fs/context/authoring/parts/core-types/sensitivity-ts.md +52 -0
- package/systems/fs/context/authoring/parts/core-types/system-events-ts.md +90 -0
- package/systems/fs/context/authoring/parts/core-types/system-pages-ts.md +50 -0
- package/systems/fs/context/authoring/parts/core-types/system-providers-ts.md +46 -0
- package/systems/fs/context/authoring/parts/core-types/validation-ts.md +45 -0
- package/systems/fs/context/authoring/parts/core-types/visuals-ts.md +107 -0
- package/systems/fs/context/authoring/parts/core-types/web-ts.md +22 -0
- package/systems/fs/context/authoring/parts/core-types/widgets-ts.md +299 -0
- package/systems/fs/context/authoring/parts/core-types.md +164 -0
- package/systems/fs/context/authoring/parts/ctx.md +94 -0
- package/systems/fs/context/authoring/parts/ctx.reference/fnctx.md +516 -0
- package/systems/fs/context/authoring/parts/ctx.reference/hubai.md +309 -0
- package/systems/fs/context/authoring/parts/ctx.reference.md +21 -0
- package/systems/fs/context/authoring/parts/data.md +162 -0
- package/systems/fs/context/authoring/parts/data.reference.md +119 -0
- package/systems/fs/context/authoring/parts/examples/client-findview-vue.md +77 -0
- package/systems/fs/context/authoring/parts/examples/client-index-ts.md +48 -0
- package/systems/fs/context/authoring/parts/examples/client-notecard-vue.md +43 -0
- package/systems/fs/context/authoring/parts/examples/client-noteinput-vue.md +73 -0
- package/systems/fs/context/authoring/parts/examples/client-notespage-vue.md +82 -0
- package/systems/fs/context/authoring/parts/examples/client-reviewform-vue.md +57 -0
- package/systems/fs/context/authoring/parts/examples/client-wordcount-vue.md +58 -0
- package/systems/fs/context/authoring/parts/examples/package-json.md +40 -0
- package/systems/fs/context/authoring/parts/examples/server-env-ts.md +40 -0
- package/systems/fs/context/authoring/parts/examples/server-impl-ts.md +323 -0
- package/systems/fs/context/authoring/parts/examples/server-index-ts.md +34 -0
- package/systems/fs/context/authoring/parts/examples/server-main-ts.md +57 -0
- package/systems/fs/context/authoring/parts/examples/server-notes-test-ts.md +95 -0
- package/systems/fs/context/authoring/parts/examples/shared-index-ts.md +310 -0
- package/systems/fs/context/authoring/parts/examples/system-json.md +36 -0
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-1-189.md +214 -0
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-190-370.md +202 -0
- package/systems/fs/context/authoring/parts/examples/systems-fs-shared-index-ts-lines-371-533.md +183 -0
- package/systems/fs/context/authoring/parts/examples/tsconfig-json.md +27 -0
- package/systems/fs/context/authoring/parts/examples.md +76 -0
- package/systems/fs/context/authoring/parts/fns.md +225 -0
- package/systems/fs/context/authoring/parts/fns.reference/fillclaims.md +267 -0
- package/systems/fs/context/authoring/parts/fns.reference/fn.md +530 -0
- package/systems/fs/context/authoring/parts/fns.reference.md +21 -0
- package/systems/fs/context/authoring/parts/folder.md +472 -0
- package/systems/fs/context/authoring/parts/gin.md +122 -0
- package/systems/fs/context/authoring/parts/gin.reference.md +483 -0
- package/systems/fs/context/authoring/parts/handlers-progress.md +100 -0
- package/systems/fs/context/authoring/parts/handlers-progress.reference.md +197 -0
- package/systems/fs/context/authoring/parts/hooks.md +56 -0
- package/systems/fs/context/authoring/parts/hooks.reference.md +110 -0
- package/systems/fs/context/authoring/parts/hub/hub-auto-pair-revoke.md +189 -0
- package/systems/fs/context/authoring/parts/hub/hub-fns-load.md +470 -0
- package/systems/fs/context/authoring/parts/hub/hub-run-background.md +562 -0
- package/systems/fs/context/authoring/parts/hub/kinds-of-hub.md +95 -0
- package/systems/fs/context/authoring/parts/hub.md +45 -0
- package/systems/fs/context/authoring/parts/hub.reference.md +476 -0
- package/systems/fs/context/authoring/parts/internals/manifestof.md +721 -0
- package/systems/fs/context/authoring/parts/internals/permissionargs.md +652 -0
- package/systems/fs/context/authoring/parts/internals/usagefromwire.md +257 -0
- package/systems/fs/context/authoring/parts/internals.md +39 -0
- package/systems/fs/context/authoring/parts/kinds-agents.md +278 -0
- package/systems/fs/context/authoring/parts/kinds-agents.reference/authoringsession.md +195 -0
- package/systems/fs/context/authoring/parts/kinds-agents.reference/kind.md +496 -0
- package/systems/fs/context/authoring/parts/kinds-agents.reference.md +21 -0
- package/systems/fs/context/authoring/parts/lifecycle.md +89 -0
- package/systems/fs/context/authoring/parts/lifecycle.reference.md +60 -0
- package/systems/fs/context/authoring/parts/mentions.md +76 -0
- package/systems/fs/context/authoring/parts/mentions.reference.md +105 -0
- package/systems/fs/context/authoring/parts/mistakes.md +465 -0
- package/systems/fs/context/authoring/parts/named-types.md +97 -0
- package/systems/fs/context/authoring/parts/named-types.reference.md +168 -0
- package/systems/fs/context/authoring/parts/outcomes.md +120 -0
- package/systems/fs/context/authoring/parts/outcomes.reference.md +287 -0
- package/systems/fs/context/authoring/parts/owner-runs.md +62 -0
- package/systems/fs/context/authoring/parts/owner-runs.reference.md +224 -0
- package/systems/fs/context/authoring/parts/packaging.md +201 -0
- package/systems/fs/context/authoring/parts/packaging.reference.md +206 -0
- package/systems/fs/context/authoring/parts/providers.md +63 -0
- package/systems/fs/context/authoring/parts/providers.reference.md +88 -0
- package/systems/fs/context/authoring/parts/remote.md +63 -0
- package/systems/fs/context/authoring/parts/remote.reference.md +175 -0
- package/systems/fs/context/authoring/parts/resources.md +58 -0
- package/systems/fs/context/authoring/parts/resources.reference.md +130 -0
- package/systems/fs/context/authoring/parts/server.md +120 -0
- package/systems/fs/context/authoring/parts/server.reference.md +569 -0
- package/systems/fs/context/authoring/parts/settings-attachments.md +55 -0
- package/systems/fs/context/authoring/parts/settings-attachments.reference.md +100 -0
- package/systems/fs/context/authoring/parts/start.md +67 -0
- package/systems/fs/context/authoring/parts/state-forms.md +103 -0
- package/systems/fs/context/authoring/parts/state-forms.reference.md +32 -0
- package/systems/fs/context/authoring/parts/testing.md +160 -0
- package/systems/fs/context/authoring/parts/testing.reference/fakehub.md +396 -0
- package/systems/fs/context/authoring/parts/testing.reference/memoryjournal.md +539 -0
- package/systems/fs/context/authoring/parts/testing.reference/toolcall.md +509 -0
- package/systems/fs/context/authoring/parts/testing.reference.md +24 -0
- package/systems/fs/context/authoring/parts/widgets.md +165 -0
- package/systems/fs/context/authoring/parts/widgets.reference/hub-visuals.md +623 -0
- package/systems/fs/context/authoring/parts/widgets.reference/sourcecompatible.md +150 -0
- package/systems/fs/context/authoring/parts/widgets.reference.md +21 -0
- package/systems/fs/context/authoring/topics/begin.md +37 -0
- package/systems/fs/context/authoring/topics/client.md +25 -0
- package/systems/fs/context/authoring/topics/declare.md +40 -0
- package/systems/fs/context/authoring/topics/examples.md +25 -0
- package/systems/fs/context/authoring/topics/fns.md +37 -0
- package/systems/fs/context/authoring/topics/server.md +40 -0
- package/systems/fs/context/authoring/topics/types.md +28 -0
- package/systems/fs/package.json +28 -0
- package/systems/fs/server/authoring.ts +103 -0
- package/systems/fs/server/builds.ts +101 -0
- package/systems/fs/server/changes.ts +430 -0
- package/systems/fs/server/commands.ts +133 -0
- package/systems/fs/server/documents.ts +96 -0
- package/systems/fs/server/env.ts +123 -0
- package/systems/fs/server/files.ts +218 -0
- package/systems/fs/server/git.ts +99 -0
- package/systems/fs/server/hosting.ts +742 -0
- package/systems/fs/server/impl.ts +451 -0
- package/systems/fs/server/index.ts +151 -0
- package/systems/fs/server/loader.ts +47 -0
- package/systems/fs/server/main.ts +143 -0
- package/systems/fs/server/mentions.ts +176 -0
- package/systems/fs/server/network-guard.ts +10 -0
- package/systems/fs/server/paths.ts +148 -0
- package/systems/fs/server/problem.ts +26 -0
- package/systems/fs/server/resources.ts +236 -0
- package/systems/fs/server/reveal.ts +33 -0
- package/systems/fs/server/run-tests.ts +17 -0
- package/systems/fs/server/runner.ts +221 -0
- package/systems/fs/server/safe.ts +83 -0
- package/systems/fs/server/search.ts +214 -0
- package/systems/fs/server/sections.ts +17 -0
- package/systems/fs/server/sensitive.ts +560 -0
- package/systems/fs/server/shell.ts +255 -0
- package/systems/fs/server/snapshots.ts +119 -0
- package/systems/fs/server/stale.ts +92 -0
- package/systems/fs/server/testing.ts +256 -0
- package/systems/fs/server/tests.ts +203 -0
- package/systems/fs/server/tree.ts +44 -0
- package/systems/fs/server/walk.ts +82 -0
- package/systems/fs/shared/format.ts +29 -0
- package/systems/fs/shared/hosting.ts +65 -0
- package/systems/fs/shared/index.ts +533 -0
- package/systems/fs/system.json +10 -0
- package/systems/fs/tsconfig.json +6 -0
- package/systems/google-calendar/package.json +18 -0
- package/systems/google-calendar/server/calendar.ts +164 -0
- package/systems/google-calendar/server/connector.ts +73 -0
- package/systems/google-calendar/server/env.ts +25 -0
- package/systems/google-calendar/server/fake.ts +127 -0
- package/systems/google-calendar/server/google.ts +234 -0
- package/systems/google-calendar/server/impl.ts +140 -0
- package/systems/google-calendar/server/index.ts +7 -0
- package/systems/google-calendar/server/main.ts +29 -0
- package/systems/google-calendar/shared/index.ts +198 -0
- package/systems/google-calendar/system.json +9 -0
- package/systems/google-calendar/tsconfig.json +6 -0
- package/systems/input/client/FieldInput.vue +118 -0
- package/systems/input/client/FormCard.vue +223 -0
- package/systems/input/client/form.ts +152 -0
- package/systems/input/client/host.ts +13 -0
- package/systems/input/client/index.ts +28 -0
- package/systems/input/package.json +22 -0
- package/systems/input/server/authoring.ts +240 -0
- package/systems/input/server/env.ts +17 -0
- package/systems/input/server/impl.ts +177 -0
- package/systems/input/server/index.ts +4 -0
- package/systems/input/server/main.ts +31 -0
- package/systems/input/shared/forms.ts +106 -0
- package/systems/input/shared/index.ts +389 -0
- package/systems/input/system.json +10 -0
- package/systems/input/tsconfig.json +6 -0
- package/systems/mcp/package.json +21 -0
- package/systems/mcp/server/dial.ts +102 -0
- package/systems/mcp/server/elicitation.ts +103 -0
- package/systems/mcp/server/env.ts +27 -0
- package/systems/mcp/server/fixtures/stdio-server.ts +8 -0
- package/systems/mcp/server/impl.ts +190 -0
- package/systems/mcp/server/index.ts +10 -0
- package/systems/mcp/server/instance.ts +442 -0
- package/systems/mcp/server/main.ts +42 -0
- package/systems/mcp/server/mirror.ts +179 -0
- package/systems/mcp/server/oauth.ts +163 -0
- package/systems/mcp/server/schema.ts +56 -0
- package/systems/mcp/server/server-link.ts +216 -0
- package/systems/mcp/shared/index.ts +130 -0
- package/systems/mcp/shared/shapes.ts +42 -0
- package/systems/mcp/system.json +10 -0
- package/systems/mcp/tsconfig.json +6 -0
- package/systems/ollama/client/ServersPage.vue +242 -0
- package/systems/ollama/client/index.ts +13 -0
- package/systems/ollama/client/logic.ts +108 -0
- package/systems/ollama/package.json +22 -0
- package/systems/ollama/server/api.ts +106 -0
- package/systems/ollama/server/detect.ts +59 -0
- package/systems/ollama/server/env.ts +43 -0
- package/systems/ollama/server/fakes.ts +212 -0
- package/systems/ollama/server/impl.ts +362 -0
- package/systems/ollama/server/index.ts +10 -0
- package/systems/ollama/server/install.ts +348 -0
- package/systems/ollama/server/main.ts +67 -0
- package/systems/ollama/server/models.ts +93 -0
- package/systems/ollama/server/provider.ts +42 -0
- package/systems/ollama/server/serve.ts +315 -0
- package/systems/ollama/shared/index.ts +178 -0
- package/systems/ollama/shared/schemas.ts +258 -0
- package/systems/ollama/system.json +11 -0
- package/systems/ollama/tsconfig.json +6 -0
- package/systems/schedule/client/AgendaList.vue +74 -0
- package/systems/schedule/client/AllSchedulesPage.vue +129 -0
- package/systems/schedule/client/CalendarGrid.vue +155 -0
- package/systems/schedule/client/CalendarPage.vue +203 -0
- package/systems/schedule/client/ChangeResult.vue +23 -0
- package/systems/schedule/client/FiringResult.vue +45 -0
- package/systems/schedule/client/ScheduleCard.vue +63 -0
- package/systems/schedule/client/ScheduleForm.vue +227 -0
- package/systems/schedule/client/ScheduleListResult.vue +36 -0
- package/systems/schedule/client/SchedulePage.vue +342 -0
- package/systems/schedule/client/ScheduleResult.vue +23 -0
- package/systems/schedule/client/host.ts +31 -0
- package/systems/schedule/client/index.ts +29 -0
- package/systems/schedule/client/logic.ts +655 -0
- package/systems/schedule/client/results.ts +114 -0
- package/systems/schedule/client/state.ts +372 -0
- package/systems/schedule/package.json +27 -0
- package/systems/schedule/server/args.ts +137 -0
- package/systems/schedule/server/authoring.ts +202 -0
- package/systems/schedule/server/env.ts +32 -0
- package/systems/schedule/server/fns.ts +791 -0
- package/systems/schedule/server/impl.ts +52 -0
- package/systems/schedule/server/index.ts +10 -0
- package/systems/schedule/server/kind.ts +48 -0
- package/systems/schedule/server/main.ts +33 -0
- package/systems/schedule/server/store.ts +195 -0
- package/systems/schedule/server/summary.ts +184 -0
- package/systems/schedule/server/timer.ts +893 -0
- package/systems/schedule/shared/index.ts +376 -0
- package/systems/schedule/shared/types.ts +264 -0
- package/systems/schedule/shared/when.ts +395 -0
- package/systems/schedule/shared/zoned.ts +44 -0
- package/systems/schedule/system.json +15 -0
- package/systems/schedule/tsconfig.json +6 -0
- package/systems/template/README.md +46 -0
- package/systems/template/client/index.ts +16 -0
- package/systems/template/client/vue-shim.d.ts +13 -0
- package/systems/template/package.json +20 -0
- package/systems/template/server/env.ts +19 -0
- package/systems/template/server/impl.ts +58 -0
- package/systems/template/server/index.ts +13 -0
- package/systems/template/server/main.ts +30 -0
- package/systems/template/shared/index.ts +81 -0
- package/systems/template/system.json +15 -0
- package/systems/template/tsconfig.json +6 -0
- package/systems/web/client/ReadView.vue +110 -0
- package/systems/web/client/SearchView.vue +215 -0
- package/systems/web/client/StatusChip.vue +38 -0
- package/systems/web/client/fakes.ts +48 -0
- package/systems/web/client/index.ts +15 -0
- package/systems/web/client/view.ts +131 -0
- package/systems/web/package.json +22 -0
- package/systems/web/server/chrome.ts +121 -0
- package/systems/web/server/crawl.ts +333 -0
- package/systems/web/server/env.ts +63 -0
- package/systems/web/server/guard.ts +60 -0
- package/systems/web/server/http.ts +89 -0
- package/systems/web/server/impl.ts +203 -0
- package/systems/web/server/index.ts +71 -0
- package/systems/web/server/loader.ts +104 -0
- package/systems/web/server/main.ts +70 -0
- package/systems/web/server/mentions.ts +111 -0
- package/systems/web/server/problem.ts +72 -0
- package/systems/web/server/renderer.ts +243 -0
- package/systems/web/server/robots.ts +75 -0
- package/systems/web/server/searches.ts +29 -0
- package/systems/web/server/tavily.ts +144 -0
- package/systems/web/server/testing.ts +165 -0
- package/systems/web/server/uploads.ts +33 -0
- package/systems/web/shared/index.ts +343 -0
- package/systems/web/shared/urls.ts +60 -0
- package/systems/web/system.json +15 -0
- package/systems/web/tsconfig.json +6 -0
- package/systems/widgets/client/ProposalCard.vue +83 -0
- package/systems/widgets/client/SavedWidget.vue +35 -0
- package/systems/widgets/client/WidgetsPage.vue +112 -0
- package/systems/widgets/client/index.ts +19 -0
- package/systems/widgets/client/proposal.ts +52 -0
- package/systems/widgets/package.json +23 -0
- package/systems/widgets/server/authoring.ts +261 -0
- package/systems/widgets/server/env.ts +21 -0
- package/systems/widgets/server/impl.ts +252 -0
- package/systems/widgets/server/index.ts +6 -0
- package/systems/widgets/server/main.ts +32 -0
- package/systems/widgets/server/run.ts +104 -0
- package/systems/widgets/shared/index.ts +194 -0
- package/systems/widgets/system.json +10 -0
- package/systems/widgets/tsconfig.json +6 -0
- package/tsconfig.base.json +30 -0
|
@@ -0,0 +1,1381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent loop: every `hub/llm` run is an aeye `Prompt`, run one iteration per queued LLM job. An iteration renders
|
|
3
|
+
* the agent's instructions and context, offers its tools (built from fn signatures), and streams one model answer
|
|
4
|
+
* (aeye retries bad tool arguments and bad output inside the job). Each tool call the model makes suspends the prompt
|
|
5
|
+
* and becomes a queued run; when every run of the iteration has settled or gone to the background, the next job
|
|
6
|
+
* continues from the saved conversation with the results appended. The run ends when the model answers without
|
|
7
|
+
* tool calls. A system's agent with an output hook (`validate.output`) has its answer checked by its system first: a
|
|
8
|
+
* refusal goes back to the model to answer again, as many times as `HARNESS_VALIDATE_RETRIES` allows, then fails it.
|
|
9
|
+
*
|
|
10
|
+
* A session's agent continues the session's transcript and streams its answer into an assistant message; any other
|
|
11
|
+
* agent keeps its conversation on its run. The run's `resume` holds the loop's state (`AgentState`), so a pause, a
|
|
12
|
+
* cancel or a restart picks up exactly where it was.
|
|
13
|
+
*/
|
|
14
|
+
import { fillRequest, planRequest, Prompt, ToolInputError, type Context, type Message, type PromptInput, type Request, type Streamer, type Usage } from '@aeye/core';
|
|
15
|
+
import { a, fillDeferred, plainDeferred, type Bindable, type Bundle } from '@aeye/schema';
|
|
16
|
+
import { LlmPayloadType, parseValue } from '@harness/sdk';
|
|
17
|
+
import {
|
|
18
|
+
ArgRepair, FnExamplesPage, HarnessGrammar, InstanceName, isSettled, Json, JsonObject, LlmInteractionId, type FnNameSpelling, type HarnessGrammarArgs, type ModelFnNames, LlmMessage, MessageId, ModelChoice, modelFnName, namesModel, QualifiedName, RunId, SelectionReport, type PromptPreview, splitName, type ActorId, type FnError, type FnRecord, type InvalidInput,
|
|
19
|
+
type OutcomeWire, type Run, type RunSettled, type Session, type RunControlAction, type TableReading, type UserInfo,
|
|
20
|
+
} from '@harness/core';
|
|
21
|
+
import { z } from 'zod';
|
|
22
|
+
import { HUB_SYSTEM } from '../catalog/availability.ts';
|
|
23
|
+
import type { FnSignature } from '../catalog/index.ts';
|
|
24
|
+
import { bindable, isObjectBound, jsonSchemaOf } from '../catalog/signature.ts';
|
|
25
|
+
import type { MessageEnricher } from '../chat/index.ts';
|
|
26
|
+
import { ensureAgentActor } from '../chat/support.ts';
|
|
27
|
+
import { citationsNotice, withCiteId } from '../chat/cite-rule.ts';
|
|
28
|
+
import { pictureParts, SEND_FN, shownMessage, type ConversationMedia } from '../chat/shown.ts';
|
|
29
|
+
import type { Asking } from '../resources/index.ts';
|
|
30
|
+
import type { CallPlan, ExposedTo, ModelCallOut, PromptPlanner } from '../contextor/index.ts';
|
|
31
|
+
import { inlineDeferred, spelled } from '../contextor/examples.ts';
|
|
32
|
+
import { AUTO_MODEL } from '../contextor/limits.ts';
|
|
33
|
+
import { suggestedExamples } from '../chat/enrich.ts';
|
|
34
|
+
import { parseRunBlocks, problemLines, resultText, RunBlockFilter, splitThinking, ThinkingFilter } from '../contextor/render.ts';
|
|
35
|
+
import { causeOf, fnError, messageOf, RunRefused } from './errors.ts';
|
|
36
|
+
import { OUTPUT_REFUSED, SystemGone } from './executors.ts';
|
|
37
|
+
import { rows } from '../store/rows.ts';
|
|
38
|
+
import { AGENT_KIND, type AgentKind, type AgentLoop, type RunInput } from './index.ts';
|
|
39
|
+
import type { ModelResolver } from './models.ts';
|
|
40
|
+
import type { ControlAnswer, Conversation, ExecutionDeps, ExecutionJob, LlmEngine, RunExecutor } from './ports.ts';
|
|
41
|
+
import { transientDelay, type ExecutionQueues } from './queues.ts';
|
|
42
|
+
import { DECLINED_CODE, PROPOSED_KEY, settledOf, type HubRunService } from './runs.ts';
|
|
43
|
+
import { LlmCallScope, type HubCallContext, type HubCallMetadata } from './scope.ts';
|
|
44
|
+
import { stepWaits } from './claims.ts';
|
|
45
|
+
import { agentTools, PendingCalls, type AgentTool } from './tools.ts';
|
|
46
|
+
import { messageFromWire, messageToWire, replyText } from './wire.ts';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A call held back until earlier calls of its iteration have settled, since they claim the same things (`claims.ts`):
|
|
50
|
+
* which calls it waits for, and what it starts with then. Kept on the agent's state, so a restart starts it as well.
|
|
51
|
+
*/
|
|
52
|
+
export const HeldCall = z.object({
|
|
53
|
+
/** The tool call ids of the earlier calls it waits for, in the model's order. */
|
|
54
|
+
after: z.array(z.string()).min(1),
|
|
55
|
+
args: Json,
|
|
56
|
+
/** The fleet instance the model named. */
|
|
57
|
+
on: InstanceName.optional(),
|
|
58
|
+
/** The model call that made it. */
|
|
59
|
+
llmCall: LlmInteractionId.optional(),
|
|
60
|
+
/** What core repaired in the args it decoded (a field sent as a string of its JSON), recorded on the run. */
|
|
61
|
+
repairs: z.array(ArgRepair).optional(),
|
|
62
|
+
});
|
|
63
|
+
export type HeldCall = z.infer<typeof HeldCall>;
|
|
64
|
+
|
|
65
|
+
/** One call of the last iteration (a native tool call, or a `<run>` block), and the run it became (or why it didn't). */
|
|
66
|
+
export const PendingCall = z.object({
|
|
67
|
+
toolCallId: z.string(),
|
|
68
|
+
/** The fn it runs; for a call refused before it ran, the name the model gave. */
|
|
69
|
+
fn: z.string(),
|
|
70
|
+
run: RunId.optional(),
|
|
71
|
+
error: z.string().optional(),
|
|
72
|
+
/** Refused before it ran (invalid input): the reply the model reads, with what was wrong. */
|
|
73
|
+
invalid: z.string().optional(),
|
|
74
|
+
/** It came as a `<run>` block in the model's text, so its reply goes back as a `<result>` message. */
|
|
75
|
+
block: z.boolean().optional(),
|
|
76
|
+
/** Not started yet: it waits for earlier calls that claim the same things. Cleared when it starts. */
|
|
77
|
+
held: HeldCall.optional(),
|
|
78
|
+
/** A held call that will never start: the agent stopped waiting (cancelled, timed out, or let its calls run on). */
|
|
79
|
+
skipped: z.literal(true).optional(),
|
|
80
|
+
});
|
|
81
|
+
export type PendingCall = z.infer<typeof PendingCall>;
|
|
82
|
+
|
|
83
|
+
/** The agent loop's state, kept on the agent run (`run.resume`). */
|
|
84
|
+
export const AgentState = z.object({
|
|
85
|
+
/** The next iteration to run. */
|
|
86
|
+
iteration: z.number().int().min(0),
|
|
87
|
+
/** The iteration its step limit counts from: 0, or where a person last continued it (Continue gives a fresh budget). */
|
|
88
|
+
from: z.number().int().min(0).optional(),
|
|
89
|
+
/** The tool calls of the last iteration, in call order, waiting to be answered. */
|
|
90
|
+
pending: z.array(PendingCall),
|
|
91
|
+
/** Where the assistant message holding those calls is in the conversation. */
|
|
92
|
+
anchor: z.number().int(),
|
|
93
|
+
/** Iterations in a row whose tool calls all failed. */
|
|
94
|
+
failures: z.number().int().min(0),
|
|
95
|
+
/** The conversation, for an agent that isn't a session's (a session's agent continues the session's transcript). */
|
|
96
|
+
messages: z.array(LlmMessage).optional(),
|
|
97
|
+
/** The assistant message a session's agent streams its answer into. */
|
|
98
|
+
message: MessageId.optional(),
|
|
99
|
+
/** Whether a session's agent has put its turn's user message into the transcript. */
|
|
100
|
+
seeded: z.boolean().optional(),
|
|
101
|
+
/** What the contextor chose for this message, so later and retried iterations keep it (`perMessage`). */
|
|
102
|
+
selection: SelectionReport.optional(),
|
|
103
|
+
/** Answers its fn's output hook sent back so far (a system's agent with `validate.output`). */
|
|
104
|
+
refusals: z.number().int().min(0).optional(),
|
|
105
|
+
});
|
|
106
|
+
export type AgentState = z.infer<typeof AgentState>;
|
|
107
|
+
|
|
108
|
+
/** What an agent's earlier run says when a new message takes over. */
|
|
109
|
+
export const INTERRUPTED = 'A new message came in; carrying on there.';
|
|
110
|
+
|
|
111
|
+
/** The code of an agent run that stopped at its step limit (`maxIterations`); Continue can carry it on. */
|
|
112
|
+
export const MAX_ITERATIONS = 'max-iterations';
|
|
113
|
+
|
|
114
|
+
/** A fresh agent's state. */
|
|
115
|
+
export const START: AgentState = { iteration: 0, pending: [], anchor: -1, failures: 0 };
|
|
116
|
+
|
|
117
|
+
/** The marker a tool call gets when its run goes to the background. */
|
|
118
|
+
export function backgroundReply(run: RunId): string {
|
|
119
|
+
return `Running in the background as run ${run}; its result will be posted when it finishes.`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** What the model reads for a settled tool run; a table result shows its first `reading.rows` rows, said to be shown or not. */
|
|
123
|
+
export function settledReply(settled: RunSettled, reading: TableReading, encode?: (value: Json) => Json): string {
|
|
124
|
+
switch (settled.status) {
|
|
125
|
+
case 'done': return replyText(settled.result, reading, encode);
|
|
126
|
+
case 'failed': return `Error: ${settled.error.message}`;
|
|
127
|
+
case 'cancelled': return settled.error === undefined ? 'The run was cancelled before it finished.' : settled.error.message;
|
|
128
|
+
case 'background': return backgroundReply(settled.run);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** A session agent's conversation: the session's transcript, which chat appends each user message to. */
|
|
133
|
+
export class SessionConversation implements Conversation {
|
|
134
|
+
readonly #deps: Pick<ExecutionDeps, 'store'>;
|
|
135
|
+
readonly #session: Session['id'];
|
|
136
|
+
|
|
137
|
+
constructor(deps: Pick<ExecutionDeps, 'store'>, session: Session['id']) {
|
|
138
|
+
this.#deps = deps;
|
|
139
|
+
this.#session = session;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async messages(): Promise<LlmMessage[]> {
|
|
143
|
+
return (await this.#deps.store.table('sessions').get(this.#session))?.transcript ?? [];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
append(messages: readonly LlmMessage[]): Promise<number> {
|
|
147
|
+
return this.#change((transcript) => {
|
|
148
|
+
const at = transcript.length;
|
|
149
|
+
return { transcript: [...transcript, ...messages], result: at };
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
answer(anchor: number, replies: readonly LlmMessage[]): Promise<void> {
|
|
154
|
+
return this.#change((transcript) => ({ transcript: [...transcript.slice(0, anchor + 1), ...replies, ...transcript.slice(anchor + 1)], result: undefined }));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async #change<T>(change: (transcript: LlmMessage[]) => { transcript: LlmMessage[]; result: T }): Promise<T> {
|
|
158
|
+
return this.#deps.store.tx(async (tx) => {
|
|
159
|
+
const session = await tx.table('sessions').get(this.#session);
|
|
160
|
+
if (session === undefined) throw new Error(`no session ${this.#session}`);
|
|
161
|
+
const { transcript, result } = change(session.transcript);
|
|
162
|
+
await tx.table('sessions').update(session.id, { transcript });
|
|
163
|
+
return result;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Any other agent's conversation: kept in its state, saved with it. */
|
|
169
|
+
export class RunConversation implements Conversation {
|
|
170
|
+
#messages: LlmMessage[];
|
|
171
|
+
|
|
172
|
+
constructor(messages: readonly LlmMessage[]) {
|
|
173
|
+
this.#messages = [...messages];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
get saved(): LlmMessage[] {
|
|
177
|
+
return [...this.#messages];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
messages(): Promise<LlmMessage[]> {
|
|
181
|
+
return Promise.resolve([...this.#messages]);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
append(messages: readonly LlmMessage[]): Promise<number> {
|
|
185
|
+
const at = this.#messages.length;
|
|
186
|
+
this.#messages.push(...messages);
|
|
187
|
+
return Promise.resolve(at);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
answer(anchor: number, replies: readonly LlmMessage[]): Promise<void> {
|
|
191
|
+
this.#messages.splice(anchor + 1, 0, ...replies);
|
|
192
|
+
return Promise.resolve();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** What the agent loop uses. */
|
|
197
|
+
export interface AgentLoopDeps extends ExecutionDeps {
|
|
198
|
+
readonly runs: Pick<HubRunService, 'start' | 'get' | 'wait' | 'settle' | 'background' | 'cancel' | 'info' | 'reopen' | 'onSettled'>;
|
|
199
|
+
readonly queues: Pick<ExecutionQueues, 'enqueueLlm' | 'cancel'>;
|
|
200
|
+
readonly llm: Pick<LlmEngine, 'streamer'> & Partial<Pick<LlmEngine, 'models'>>;
|
|
201
|
+
readonly models: Pick<ModelResolver, 'resolve'>;
|
|
202
|
+
/** How a chat message reads to the LLM (mentions, extras and hooks as tagged blocks). */
|
|
203
|
+
readonly enrich: Pick<MessageEnricher, 'render'>;
|
|
204
|
+
/**
|
|
205
|
+
* Resources shown in a conversation, made for the model each call goes to (`chat/shown.ts`): pictures for a model
|
|
206
|
+
* that sees, `<image>` blocks it can ask about otherwise. Absent: the conversation goes as it is kept.
|
|
207
|
+
*/
|
|
208
|
+
readonly media?: Pick<ConversationMedia, 'expand'> | undefined;
|
|
209
|
+
/** What each prompt holds, within the model's limits, and what the model's calls mean. */
|
|
210
|
+
readonly planner: Pick<PromptPlanner, 'plan' | 'interpret' | 'exposed' | 'settled' | 'names' | 'draft' | 'writeArgs'>;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** An agent prompt's tools (given each iteration by `retool`), typed so the prompt's events name them. */
|
|
214
|
+
type AgentTools = [AgentTool, ...AgentTool[]];
|
|
215
|
+
|
|
216
|
+
/** An agent's prompt; it logs when aeye's `forget` drops messages, which the planner's budget should never let happen. */
|
|
217
|
+
class AgentPrompt extends Prompt<HubCallContext, HubCallMetadata, 'agent', AgentInput, AgentOutput, AgentTools> {
|
|
218
|
+
readonly #forgot: (dropped: number) => void;
|
|
219
|
+
|
|
220
|
+
constructor(input: PromptInput<HubCallContext, HubCallMetadata, 'agent', AgentInput, AgentOutput, AgentTools>, forgot: (dropped: number) => void) {
|
|
221
|
+
super(input);
|
|
222
|
+
this.#forgot = forgot;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
protected override forget(request: Request, ctx: Context<HubCallContext, HubCallMetadata>, usage?: Usage): Message[] {
|
|
226
|
+
const kept = super.forget(request, ctx, usage);
|
|
227
|
+
if (kept.length < request.messages.length) this.#forgot(request.messages.length - kept.length);
|
|
228
|
+
return kept;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** The input an agent's instructions are rendered with. */
|
|
233
|
+
interface AgentInput {
|
|
234
|
+
args: Json;
|
|
235
|
+
context: string;
|
|
236
|
+
/** The agent's injected section (`PlannedPrompt.injectedContext`). */
|
|
237
|
+
injectedContext?: string;
|
|
238
|
+
/** The agent's step limit (`payload.maxIterations`), for instructions that tell the model how many steps it has. */
|
|
239
|
+
maxIterations?: number;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** An agent's answer: text, or a structured value (wrapped in `result` when it isn't an object). */
|
|
243
|
+
type AgentOutput = string | object;
|
|
244
|
+
|
|
245
|
+
/** How one iteration went. */
|
|
246
|
+
type IterationEnd = 'waiting-for-tools' | 'done' | { failed: FnError };
|
|
247
|
+
|
|
248
|
+
/** The agent loop, also the executor of `hub/llm` runs. */
|
|
249
|
+
export class HubAgentLoop implements AgentLoop, RunExecutor {
|
|
250
|
+
readonly #deps: AgentLoopDeps;
|
|
251
|
+
readonly #iterating = new Map<RunId, AbortController>();
|
|
252
|
+
readonly #jobs = new Map<RunId, string>();
|
|
253
|
+
readonly #agents = new Map<QualifiedName, ActorId>();
|
|
254
|
+
|
|
255
|
+
constructor(deps: AgentLoopDeps) {
|
|
256
|
+
this.#deps = deps;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async start(input: RunInput & { kind: AgentKind }): Promise<{ run: RunId }> {
|
|
260
|
+
const { kind: _kind, ...run } = input;
|
|
261
|
+
const started = await this.#deps.runs.start(run);
|
|
262
|
+
return { run: started.run };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* The run worker dequeued an agent run (new, or resumed): queue its next iteration, after its tool calls settle if
|
|
267
|
+
* it was waiting on some. The loop settles the run itself.
|
|
268
|
+
*/
|
|
269
|
+
async execute(job: ExecutionJob): Promise<'detached'> {
|
|
270
|
+
const state = stateOf(job.run);
|
|
271
|
+
if (state.pending.length === 0) {
|
|
272
|
+
this.#queue(job.run, state.iteration);
|
|
273
|
+
} else {
|
|
274
|
+
const waiting = await this.#deps.store.table('runs').update(job.run.id, { status: 'waiting' });
|
|
275
|
+
void this.#await(waiting, state);
|
|
276
|
+
}
|
|
277
|
+
return 'detached';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** The LLM queue's handler: run one iteration; transient limits are rethrown so the queue defers the job. */
|
|
281
|
+
async handle(job: { run: RunId; iteration: number }, signal: AbortSignal): Promise<void> {
|
|
282
|
+
this.#jobs.delete(job.run);
|
|
283
|
+
const end = await this.iterate(job.run, job.iteration, signal);
|
|
284
|
+
if (typeof end === 'object') this.#deps.log.warn('agent.failed', { run: job.run, iteration: job.iteration, error: end.failed.message });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async iterate(id: RunId, iteration: number, signal: AbortSignal): Promise<IterationEnd> {
|
|
288
|
+
const { runs, store, log } = this.#deps;
|
|
289
|
+
const run = await runs.get(id);
|
|
290
|
+
if (run === undefined || (run.status !== 'running' && run.status !== 'waiting')) return 'done';
|
|
291
|
+
const state = stateOf(run);
|
|
292
|
+
if (state.iteration !== iteration) return 'done';
|
|
293
|
+
const controller = new AbortController();
|
|
294
|
+
const stop = (): void => { controller.abort(signal.reason); };
|
|
295
|
+
signal.addEventListener('abort', stop, { once: true });
|
|
296
|
+
this.#iterating.set(id, controller);
|
|
297
|
+
try {
|
|
298
|
+
if (run.status === 'waiting') await store.table('runs').update(id, { status: 'running' });
|
|
299
|
+
return await this.#iterate(run, state, controller.signal);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if (controller.signal.aborted) return 'done';
|
|
302
|
+
if (transientDelay(error) !== undefined) throw error;
|
|
303
|
+
const failed = fnError(causeOf(error, RunRefused)?.error.class ?? 'fatal', messageOf(error), 'agent');
|
|
304
|
+
log.error('agent.error', { run: id, iteration, error: failed.message });
|
|
305
|
+
const latest = await runs.get(id);
|
|
306
|
+
await this.#fail(run, latest === undefined ? state : stateOf(latest), failed);
|
|
307
|
+
return { failed };
|
|
308
|
+
} finally {
|
|
309
|
+
signal.removeEventListener('abort', stop);
|
|
310
|
+
this.#iterating.delete(id);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The request a session's agent would send for a new message (`message`: as the model reads it, the hub's and hooks'
|
|
316
|
+
* blocks added), built as a turn's first step builds it: the planner's draft (which keeps nothing) and the same aeye
|
|
317
|
+
* prompt, whose request is caught before it reaches any model. For the admins' prompt preview.
|
|
318
|
+
*/
|
|
319
|
+
async preview(input: { session: Session; user: ActorId; message: string; model?: string | undefined; count?: readonly string[] | undefined }): Promise<PromptPreview> {
|
|
320
|
+
const { catalog } = this.#deps;
|
|
321
|
+
const { session } = input;
|
|
322
|
+
const fn = await catalog.fn(session.agent);
|
|
323
|
+
if (fn === undefined) throw new Error(`${session.agent} no longer exists`);
|
|
324
|
+
const payload = parseValue(LlmPayloadType, fn.decl.payload);
|
|
325
|
+
const metadata = await this.#deps.models.resolve(input.model === undefined ? session.model ?? ModelChoice.optional().parse(payload.model) : { model: input.model });
|
|
326
|
+
const model = metadata.model ?? AUTO_MODEL;
|
|
327
|
+
const instructions = session.instructions ?? payload.instructions;
|
|
328
|
+
const cites = citationsNotice(session.citationsTold, session.citations === true);
|
|
329
|
+
const message = cites.notice === undefined ? input.message : `${cites.notice}\n\n${input.message}`;
|
|
330
|
+
const planned = await this.#deps.planner.draft({
|
|
331
|
+
session, agent: fn, model, instructions, user: input.user,
|
|
332
|
+
transcript: await this.#media([...session.transcript, { role: 'user', content: message }], model, { actor: input.user, session: session.id }),
|
|
333
|
+
});
|
|
334
|
+
const own = modelFnName(fn.name);
|
|
335
|
+
const tools = agentTools(planned.tools.filter((tool) => tool.name !== own), new PendingCalls());
|
|
336
|
+
const output = outputOf(await catalog.signature(fn.name), planned.rendered.names);
|
|
337
|
+
const prompt = new AgentPrompt({
|
|
338
|
+
name: 'agent', description: fn.decl.description, content: `${planned.instructions}{{#if context}}\n\n{{{context}}}{{/if}}`,
|
|
339
|
+
input: (given) => ({ args: given?.args ?? null, context: given?.context ?? '', injectedContext: given?.injectedContext ?? '', maxIterations: given?.maxIterations ?? payload.maxIterations }),
|
|
340
|
+
...(output.schema === undefined ? {} : { schema: output.schema }), schemaDelivery: tools.length > 0 ? 'prompt' : 'auto', config: { maxTokens: planned.maxTokens }, retool: () => tools, toolExecution: payload.toolExecution, metadata,
|
|
341
|
+
}, () => undefined);
|
|
342
|
+
let caught: Request | undefined;
|
|
343
|
+
const stop = new AbortController();
|
|
344
|
+
// the request is caught where a model would be called, and the prompt stopped there
|
|
345
|
+
const capture = async function* (request: Request): AsyncGenerator<never, never> {
|
|
346
|
+
caught = request;
|
|
347
|
+
stop.abort();
|
|
348
|
+
await Promise.resolve();
|
|
349
|
+
yield* [];
|
|
350
|
+
throw new Error('preview: no model is called');
|
|
351
|
+
};
|
|
352
|
+
const ctx = { messages: planned.messages.map(messageFromWire), signal: stop.signal, stream: capture, contextWindow: planned.contextWindow, maxOutputTokens: planned.maxTokens };
|
|
353
|
+
try {
|
|
354
|
+
for await (const _event of prompt.get('stream', { args: null, context: planned.context, injectedContext: planned.injectedContext, maxIterations: payload.maxIterations }, ctx)) { /* nothing streams */ }
|
|
355
|
+
} catch (error) {
|
|
356
|
+
if (caught === undefined) throw error;
|
|
357
|
+
}
|
|
358
|
+
if (caught === undefined) throw new Error('the prompt sent no request');
|
|
359
|
+
// its examples written through the plan its provider makes for the model (`fillRequest`), as the model reads them
|
|
360
|
+
const info = this.#deps.llm.models?.().find((one) => namesModel(model, one));
|
|
361
|
+
const plan = planRequest(caught, info);
|
|
362
|
+
const request: Request = { ...caught, ...fillRequest(caught, plan) };
|
|
363
|
+
const context = fillDeferred(planned.context, plan);
|
|
364
|
+
const { estimator } = planned.ctx;
|
|
365
|
+
const textOf = (content: Message['content']): string => (typeof content === 'string' ? content : content.map((part) => (part.type === 'text' && typeof part.content === 'string' ? part.content : `[${part.type}]`)).join('\n'));
|
|
366
|
+
const system = request.messages.filter((m) => m.role === 'system').map((m) => textOf(m.content)).join('\n\n');
|
|
367
|
+
// the instructions as rendered: the system message without what follows them and without the injected section
|
|
368
|
+
let instructionsText = context !== '' && system.endsWith(context) ? system.slice(0, system.length - context.length).trimEnd() : system;
|
|
369
|
+
if (planned.injectedContext !== '') instructionsText = instructionsText.replace(planned.injectedContext, '').replace(/\n{3,}/g, '\n\n').trim();
|
|
370
|
+
// the tools as the request carries them (what core plans for the model), their parameters in the code shape
|
|
371
|
+
const specs = new Map(planned.tools.map((tool) => [tool.name, tool.spec]));
|
|
372
|
+
const guide = planned.rendered.names.text(planned.mode.guide(planned.ctx));
|
|
373
|
+
return {
|
|
374
|
+
agent: fn.name, model, window: planned.contextWindow, maxTokens: planned.maxTokens, estimate: planned.estimate, system,
|
|
375
|
+
tools: (request.tools ?? []).map((tool) => {
|
|
376
|
+
const spec = specs.get(tool.name);
|
|
377
|
+
return { name: tool.name, description: tool.description ?? '', parameters: Json.parse(jsonSchemaOf(tool.parameters)), tokens: spec === undefined ? 0 : estimator.tool(spec) };
|
|
378
|
+
}),
|
|
379
|
+
messages: request.messages.filter((m) => m.role !== 'system').map((m) => ({ role: m.role, content: textOf(m.content), tokens: estimator.text(textOf(m.content)) })),
|
|
380
|
+
parts: {
|
|
381
|
+
instructions: instructionsText, injected: planned.injectedContext, context, guide,
|
|
382
|
+
tokens: {
|
|
383
|
+
instructions: estimator.text(instructionsText), injected: estimator.text(planned.injectedContext), context: estimator.text(context), guide: estimator.text(guide), system: estimator.text(system),
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
counts: (input.count ?? []).map((text) => estimator.text(text)),
|
|
387
|
+
report: SelectionReport.parse(planned.report),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
async #iterate(run: Run, given: AgentState, signal: AbortSignal): Promise<IterationEnd> {
|
|
392
|
+
let state = given;
|
|
393
|
+
const { catalog, store, clock } = this.#deps;
|
|
394
|
+
const fn = await catalog.fn(run.fn);
|
|
395
|
+
if (fn === undefined) throw new Error(`${run.fn} no longer exists`);
|
|
396
|
+
const payload = parseValue(LlmPayloadType, fn.decl.payload);
|
|
397
|
+
const session = await this.#session(run);
|
|
398
|
+
const conversation = this.#conversation(session, state);
|
|
399
|
+
const turn = await store.table('turns').get(run.turn);
|
|
400
|
+
if (turn === undefined) throw new Error(`run ${run.id} names no turn ${run.turn}`);
|
|
401
|
+
// a chat's own model choice wins over the one its agent fn makes
|
|
402
|
+
const metadata = await this.#deps.models.resolve(session?.model ?? ModelChoice.optional().parse(payload.model));
|
|
403
|
+
const model = metadata.model ?? AUTO_MODEL;
|
|
404
|
+
if (session !== undefined && state.seeded !== true) {
|
|
405
|
+
await this.#seed(conversation, turn.message, session, { session, agent: fn, model, access: await this.#deps.access.scope(turn.user.id) });
|
|
406
|
+
state = { ...state, seeded: true };
|
|
407
|
+
await store.table('runs').update(run.id, { resume: Json.parse(state) });
|
|
408
|
+
}
|
|
409
|
+
// a chat's own system prompt (`Session.instructions`, a compare variant's too) wins over its agent fn's
|
|
410
|
+
const instructions = session?.instructions ?? payload.instructions;
|
|
411
|
+
if (state.pending.length > 0) {
|
|
412
|
+
// Answered and saved at once, so a job that runs again (after a rate limit) never answers twice.
|
|
413
|
+
const replies = await this.#replies(state.pending, { session, agent: fn, model, access: await this.#deps.access.scope(turn.user.id) });
|
|
414
|
+
await conversation.answer(state.anchor, replies.messages);
|
|
415
|
+
state = { ...state, pending: [], failures: replies.allFailed ? state.failures + 1 : 0, ...this.#saved(conversation) };
|
|
416
|
+
await store.table('runs').update(run.id, { resume: Json.parse(state) });
|
|
417
|
+
if (replies.stopped !== undefined) {
|
|
418
|
+
await this.#fail(run, state, replies.stopped);
|
|
419
|
+
return { failed: replies.stopped };
|
|
420
|
+
}
|
|
421
|
+
if (state.failures >= this.#deps.settings.execution.HARNESS_AGENT_TOOL_FAILURES) {
|
|
422
|
+
const failed = fnError('fatal', `${run.fn} stopped: its tool calls failed ${state.failures} times in a row.`, 'tool-failures');
|
|
423
|
+
await this.#fail(run, state, failed);
|
|
424
|
+
return { failed };
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
// checked once the last iteration's calls are answered, so their real results are in the transcript (and no call is
|
|
428
|
+
// left without a reply) when the run stops; Continue carries on from there
|
|
429
|
+
if (state.iteration - (state.from ?? 0) >= payload.maxIterations) {
|
|
430
|
+
const failed = fnError('fatal', `${run.fn} stopped after ${payload.maxIterations} iterations without an answer.`, MAX_ITERATIONS);
|
|
431
|
+
await this.#fail(run, state, failed);
|
|
432
|
+
return { failed };
|
|
433
|
+
}
|
|
434
|
+
const planned = await this.#deps.planner.plan({
|
|
435
|
+
session, turn, agent: fn, model, instructions, cached: state.selection,
|
|
436
|
+
// shown resources and images as this model takes them: pictures for one that sees, blocks it can ask about otherwise
|
|
437
|
+
transcript: await this.#media(await conversation.messages(), model, {
|
|
438
|
+
actor: turn.user.id, run: run.id, admin: turn.user.role === 'admin', ...(run.session === undefined ? {} : { session: run.session }),
|
|
439
|
+
}),
|
|
440
|
+
});
|
|
441
|
+
if (state.selection === undefined) {
|
|
442
|
+
if (planned.considered !== undefined && session !== undefined && turn.message !== undefined) await this.#deps.turns.suggested(turn.message, planned.considered);
|
|
443
|
+
state = { ...state, selection: planned.report };
|
|
444
|
+
await store.table('runs').update(run.id, { resume: Json.parse(state) });
|
|
445
|
+
}
|
|
446
|
+
const calls = new PendingCalls();
|
|
447
|
+
// an agent never calls itself: a session that loaded its fn would otherwise offer it back to it
|
|
448
|
+
const own = modelFnName(fn.name);
|
|
449
|
+
const tools = agentTools(planned.tools.filter((tool) => tool.name !== own), calls);
|
|
450
|
+
const blocks = planned.rendered.protocol === 'text' ? new RunBlockFilter() : undefined;
|
|
451
|
+
const signature = await catalog.signature(fn.name);
|
|
452
|
+
const output = outputOf(signature, planned.rendered.names);
|
|
453
|
+
const message = session === undefined ? undefined : await this.#message(run, state, turn.message);
|
|
454
|
+
if (message !== undefined && state.message !== message) {
|
|
455
|
+
state = { ...state, message };
|
|
456
|
+
await store.table('runs').update(run.id, { resume: Json.parse(state) });
|
|
457
|
+
}
|
|
458
|
+
const scope = new LlmCallScope({
|
|
459
|
+
run: run.id, turn: run.turn, session: run.session, fn: run.fn, actor: run.actor, iteration: state.iteration, priority: run.priority, limits: turn.limits, queuedAt: clock(),
|
|
460
|
+
});
|
|
461
|
+
const prompt = new AgentPrompt({
|
|
462
|
+
name: 'agent',
|
|
463
|
+
description: fn.decl.description,
|
|
464
|
+
// the injected section is the hub's own text, filled in raw where the instructions say (never read as a template)
|
|
465
|
+
content: `${planned.instructions}{{#if context}}\n\n{{{context}}}{{/if}}`,
|
|
466
|
+
input: (input) => ({ args: input?.args ?? null, context: input?.context ?? '', injectedContext: input?.injectedContext ?? '', maxIterations: input?.maxIterations ?? payload.maxIterations }),
|
|
467
|
+
...(output.schema === undefined ? {} : { schema: output.schema }),
|
|
468
|
+
// with tools, the answer's schema goes in the prompt: a wire schema makes many models answer at once instead of calling them
|
|
469
|
+
schemaDelivery: tools.length > 0 ? 'prompt' : 'auto',
|
|
470
|
+
config: { maxTokens: planned.maxTokens },
|
|
471
|
+
retool: () => tools,
|
|
472
|
+
toolExecution: payload.toolExecution,
|
|
473
|
+
metadata,
|
|
474
|
+
}, (dropped) => { this.#deps.log.warn('agent.forget', { run: run.id, iteration: state.iteration, model, dropped, estimate: planned.estimate }); });
|
|
475
|
+
|
|
476
|
+
const collected: LlmMessage[] = [];
|
|
477
|
+
let answer: AgentOutput | undefined;
|
|
478
|
+
let suspended = false;
|
|
479
|
+
let reasoning = '';
|
|
480
|
+
const stream = (text: string): void => { if (message !== undefined && text !== '') this.#deps.turns.stream(message, { text }); };
|
|
481
|
+
// thinking a model writes into its answer (`<think>…</think>`) streams as reasoning, never as the answer
|
|
482
|
+
const thinking = new ThinkingFilter();
|
|
483
|
+
const answerText = (split: { text: string; reasoning: string }): void => {
|
|
484
|
+
if (message !== undefined && split.reasoning !== '') this.#deps.turns.stream(message, { reasoning: split.reasoning });
|
|
485
|
+
stream(blocks === undefined ? split.text : blocks.push(split.text));
|
|
486
|
+
};
|
|
487
|
+
const ctx = {
|
|
488
|
+
// a cut model name in a call reads back only once learned: each finished call is learned before core decodes it
|
|
489
|
+
call: scope, messages: planned.messages.map(messageFromWire), signal, stream: learning(this.#deps.llm.streamer, planned.rendered.names), contextWindow: planned.contextWindow,
|
|
490
|
+
maxOutputTokens: planned.maxTokens,
|
|
491
|
+
};
|
|
492
|
+
// calls core answered itself (args that don't fit their tool), and what it repaired in the calls it decoded
|
|
493
|
+
const refusedCalls: RefusedCall[] = [];
|
|
494
|
+
const repaired = new Map<string, ArgRepair[]>();
|
|
495
|
+
for await (const event of prompt.get('stream', { args: run.args, context: planned.context, injectedContext: planned.injectedContext, maxIterations: payload.maxIterations }, ctx)) {
|
|
496
|
+
switch (event.type) {
|
|
497
|
+
case 'textPartial':
|
|
498
|
+
scope.markFirstToken(clock());
|
|
499
|
+
answerText(thinking.push(event.content));
|
|
500
|
+
break;
|
|
501
|
+
case 'reasonPartial': {
|
|
502
|
+
scope.markFirstToken(clock());
|
|
503
|
+
const full = event.reasoning.content ?? '';
|
|
504
|
+
if (message !== undefined && full.length > reasoning.length) this.#deps.turns.stream(message, { reasoning: full.slice(reasoning.length) });
|
|
505
|
+
reasoning = full;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
case 'toolParseName':
|
|
509
|
+
scope.markFirstToken(clock());
|
|
510
|
+
break;
|
|
511
|
+
case 'message':
|
|
512
|
+
collected.push(messageToWire(event.message));
|
|
513
|
+
break;
|
|
514
|
+
case 'complete':
|
|
515
|
+
answer = event.output;
|
|
516
|
+
break;
|
|
517
|
+
case 'suspend':
|
|
518
|
+
suspended = true;
|
|
519
|
+
break;
|
|
520
|
+
// the rest are seen through the scope's own hooks (usage, requests) or do not change the turn
|
|
521
|
+
case 'text': case 'textReset': case 'textComplete': case 'reason': case 'audioPartial': case 'images': case 'citations':
|
|
522
|
+
case 'refusal': case 'moderation': case 'request': case 'requestUsage': case 'responseTokens': case 'usage':
|
|
523
|
+
case 'reviewStart': case 'reviewPass': case 'reviewFeedback': case 'schemaFallback':
|
|
524
|
+
case 'toolParseArguments': case 'toolStart': case 'toolOutput': case 'toolInterrupt': case 'toolSuspend':
|
|
525
|
+
break;
|
|
526
|
+
case 'toolArgRepairAttempt':
|
|
527
|
+
if (event.success) repaired.set(event.toolCallId, repairsOfFields(event.tool.name, event.fields));
|
|
528
|
+
break;
|
|
529
|
+
case 'toolError':
|
|
530
|
+
// core answered it (the tool reply is in the conversation already); the hub records it as a run. What was
|
|
531
|
+
// repaired in it goes with it: a retry may reuse the call id, and its own repairs (if any) come again.
|
|
532
|
+
if (event.failure instanceof ToolInputError) repaired.delete(event.toolCallId);
|
|
533
|
+
if (event.failure instanceof ToolInputError) refusedCalls.push({ toolCallId: event.toolCallId, tool: toolNameOf(event.tool, event.failure.tool), error: event.error, ...(event.rawArgs === undefined ? {} : { rawArgs: event.rawArgs }) });
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
if (signal.aborted) return 'done';
|
|
538
|
+
answerText(thinking.end());
|
|
539
|
+
if (blocks !== undefined) stream(blocks.end());
|
|
540
|
+
const at = await conversation.append(collected);
|
|
541
|
+
const last = scope.last;
|
|
542
|
+
// every call of the iteration (its retries and repairs too) was made from the same selection
|
|
543
|
+
for (const call of scope.calls) { await store.table('llmInteractions').update(call.interaction, { selection: planned.report }); }
|
|
544
|
+
await this.#recordRefused(run, state.iteration, refusedCalls, planned.rendered.names, planned.rendered.fns, last?.interaction, message);
|
|
545
|
+
|
|
546
|
+
const made = suspended ? this.#toolCalls(collected, calls) : this.#blockCalls(collected, answer, state.iteration);
|
|
547
|
+
if (made !== undefined) {
|
|
548
|
+
const interpreted = await Promise.all(made.calls.map(async (call) => ({ ...call, plan: await this.#deps.planner.interpret(call.out, planned) })));
|
|
549
|
+
const pending = await this.#startCalls(run, state.iteration, interpreted, last?.interaction, { user: turn.user, sequential: payload.toolExecution === 'sequential' }, repaired);
|
|
550
|
+
const used = pending.flatMap((call) => ((call.run === undefined && call.held === undefined) || call.invalid !== undefined ? [] : [QualifiedName.parse(call.fn)]));
|
|
551
|
+
await this.#deps.planner.settled({ model, estimate: planned.estimate, actual: last?.usage.input, used });
|
|
552
|
+
if (message !== undefined) await this.#deps.turns.track(message, pending.flatMap((call) => {
|
|
553
|
+
const fn = QualifiedName.safeParse(call.fn);
|
|
554
|
+
return call.run === undefined || !fn.success ? [] : [{ run: call.run, fn: fn.data }];
|
|
555
|
+
}));
|
|
556
|
+
const next: AgentState = { ...state, iteration: state.iteration + 1, pending, anchor: at + made.index, ...this.#saved(conversation) };
|
|
557
|
+
await store.table('runs').update(run.id, { status: 'waiting', resume: Json.parse(next) });
|
|
558
|
+
void this.#await(run, next);
|
|
559
|
+
return 'waiting-for-tools';
|
|
560
|
+
}
|
|
561
|
+
await this.#deps.planner.settled({ model, estimate: planned.estimate, actual: last?.usage.input, used: [] });
|
|
562
|
+
|
|
563
|
+
if (answer === undefined) throw new Error(`${run.fn} ended without an answer`);
|
|
564
|
+
const produced = output.result(answer);
|
|
565
|
+
const result = typeof produced === 'string' ? splitThinking(produced).text : produced;
|
|
566
|
+
const refused = await this.#refused(run, fn, result, state, signal);
|
|
567
|
+
if (refused?.action === 'retry') {
|
|
568
|
+
// the model reads why and answers again, in the same conversation
|
|
569
|
+
await conversation.append([{ role: 'user', content: `Your answer was not accepted: ${refused.reason}` }]);
|
|
570
|
+
const next: AgentState = { ...state, iteration: state.iteration + 1, refusals: (state.refusals ?? 0) + 1, ...this.#saved(conversation) };
|
|
571
|
+
await store.table('runs').update(run.id, { resume: Json.parse(next) });
|
|
572
|
+
this.#queue(run, next.iteration);
|
|
573
|
+
return 'waiting-for-tools';
|
|
574
|
+
}
|
|
575
|
+
if (refused !== undefined) {
|
|
576
|
+
const failed = fnError('fatal', refused.reason, OUTPUT_REFUSED);
|
|
577
|
+
await this.#fail(run, state, failed);
|
|
578
|
+
return { failed };
|
|
579
|
+
}
|
|
580
|
+
await store.table('runs').update(run.id, { resume: Json.parse({ ...state, ...this.#saved(conversation) }) });
|
|
581
|
+
if (message !== undefined) await this.#deps.turns.finish(message, [{ type: 'text', text: replyText(result, { rows: this.#deps.settings.execution.HARNESS_TOOL_RESULT_ROWS, watched: true }) }], 'done');
|
|
582
|
+
await this.#deps.runs.settle(run.id, { status: 'done', result });
|
|
583
|
+
return 'done';
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Whether the output hook of a system's agent (`validate.output`) refuses its answer: `retry` while tries are left
|
|
588
|
+
* (`HARNESS_VALIDATE_RETRIES`), else `stop`; undefined when it passes or the fn has no hook.
|
|
589
|
+
*/
|
|
590
|
+
async #refused(run: Run, fn: FnRecord, result: Json, state: AgentState, signal: AbortSignal): Promise<{ action: 'retry' | 'stop'; reason: string } | undefined> {
|
|
591
|
+
if (fn.decl.validate?.output !== true || fn.system === HUB_SYSTEM) return undefined;
|
|
592
|
+
// an agent runs in the hub; the system that declared it answers its hook
|
|
593
|
+
const connection = run.system === fn.system ? this.#deps.link.connection(fn.system, run.instance) : this.#deps.link.connection(fn.system);
|
|
594
|
+
if (connection === undefined) throw new SystemGone(fn.system);
|
|
595
|
+
const refusals = state.refusals ?? 0;
|
|
596
|
+
const verdict = await connection.peer.call('validate', {
|
|
597
|
+
phase: 'output', run: await this.#deps.runs.info(run), fn: splitName(fn.name).local, args: run.args, result, attempt: refusals + 1,
|
|
598
|
+
}, { signal: AbortSignal.any([signal, connection.signal]) });
|
|
599
|
+
if (verdict.ok) return undefined;
|
|
600
|
+
const action = 'action' in verdict ? verdict.action : 'retry';
|
|
601
|
+
return { action: action === 'retry' && refusals < this.#deps.settings.execution.HARNESS_VALIDATE_RETRIES ? 'retry' : 'stop', reason: verdict.reason };
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* A new user message arrived while the agent works on an earlier one: its tool calls go to the background and are
|
|
606
|
+
* answered with that in the transcript, its streaming stops, and the run ends, so the agent run of the new message
|
|
607
|
+
* continues the conversation (it sees the "still running" replies and the new message) and can answer at once.
|
|
608
|
+
*/
|
|
609
|
+
async interrupt(id: RunId): Promise<void> {
|
|
610
|
+
const run = await this.#deps.runs.get(id);
|
|
611
|
+
if (run === undefined || isSettled(run.status)) return;
|
|
612
|
+
this.#iterating.get(id)?.abort('interrupted');
|
|
613
|
+
const job = this.#jobs.get(id);
|
|
614
|
+
if (job !== undefined) await this.#deps.queues.cancel(job, 'interrupted');
|
|
615
|
+
this.#jobs.delete(id);
|
|
616
|
+
const state = stateOf(run);
|
|
617
|
+
await this.#backgroundCalls(state);
|
|
618
|
+
if (state.pending.length > 0) {
|
|
619
|
+
const conversation = this.#conversation(await this.#session(run), state);
|
|
620
|
+
await conversation.answer(state.anchor, (await this.#replies(state.pending, undefined)).messages);
|
|
621
|
+
await this.#deps.store.table('runs').update(id, { resume: Json.parse({ ...state, pending: [], ...this.#saved(conversation) }) });
|
|
622
|
+
}
|
|
623
|
+
if (state.message !== undefined) await this.#deps.turns.finish(state.message, [{ type: 'text', text: INTERRUPTED }], 'done');
|
|
624
|
+
await this.#deps.runs.settle(id, { status: 'done', result: INTERRUPTED });
|
|
625
|
+
this.#deps.log.info('agent.interrupted', { run: id, pending: state.pending.length });
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Carry on an agent run that stopped at its step limit or was cancelled (Continue): the same run, from where it
|
|
630
|
+
* stopped, with its conversation kept and a fresh step budget. Its calls left unanswered are answered first (a
|
|
631
|
+
* cancelled one says so), its failure count starts again, and its answer goes into a new message (the stopped one
|
|
632
|
+
* keeps saying why it stopped). Refused (`RunRefused`) for any other run.
|
|
633
|
+
*/
|
|
634
|
+
async continue(id: RunId, by: ActorId): Promise<void> {
|
|
635
|
+
const run = await this.#deps.runs.get(id);
|
|
636
|
+
if (run?.kind !== AGENT_KIND || !continuable(run)) throw new RunRefused(fnError('caller', 'Only an agent run that stopped at its step limit or was cancelled can continue.', 'not-continuable'));
|
|
637
|
+
const { message: _message, refusals: _refusals, ...state } = stateOf(run);
|
|
638
|
+
const next: AgentState = { ...state, from: state.iteration, failures: 0 };
|
|
639
|
+
if (!(await this.#deps.runs.reopen(id, Json.parse(next), by))) throw new RunRefused(fnError('caller', 'The run is no longer stopped.', 'not-continuable'));
|
|
640
|
+
this.#deps.log.info('agent.continued', { run: id, by, iteration: next.iteration, pending: next.pending.length });
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/** Move an iteration's running tool calls to the background (those that allow it). */
|
|
644
|
+
async #backgroundCalls(state: AgentState): Promise<void> {
|
|
645
|
+
for (const call of state.pending) {
|
|
646
|
+
if (call.run !== undefined) await this.#deps.runs.background(call.run);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** The session whose conversation an agent run continues: only a session's own agent (a turn's root run) has one. */
|
|
651
|
+
async #session(run: Run): Promise<Session | undefined> {
|
|
652
|
+
return run.session === undefined || run.parent !== undefined ? undefined : this.#deps.store.table('sessions').get(run.session);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** The conversation an agent run continues. */
|
|
656
|
+
#conversation(session: Session | undefined, state: AgentState): Conversation {
|
|
657
|
+
return session === undefined ? new RunConversation(state.messages ?? []) : new SessionConversation(this.#deps, session.id);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Put the turn's user message, as the LLM reads it, into the session transcript. When the chat's "Use citations"
|
|
662
|
+
* changed since the model was last told (a compare variant's own setting too), it starts with a hidden
|
|
663
|
+
* `<citations_changed>` block, once per change; what was told is kept on the session (and put back by undo).
|
|
664
|
+
*/
|
|
665
|
+
async #seed(conversation: Conversation, message: MessageId | undefined, session: Session, prompt: ExposedTo): Promise<void> {
|
|
666
|
+
if (message === undefined) return;
|
|
667
|
+
const row = await this.#deps.store.table('messages').get(message);
|
|
668
|
+
if (row === undefined) return;
|
|
669
|
+
const cites = citationsNotice(session.citationsTold, session.citations === true);
|
|
670
|
+
if (cites.told !== session.citationsTold) await this.#deps.store.table('sessions').update(session.id, { citationsTold: cites.told });
|
|
671
|
+
// a suggested fn's example args as the model would send them for that fn here
|
|
672
|
+
const asks = suggestedExamples(row);
|
|
673
|
+
const written = asks.length === 0 ? [] : await this.#deps.planner.writeArgs(prompt, asks);
|
|
674
|
+
const text = this.#deps.enrich.render(row, new Map(asks.map((ask, index) => [ask.fn, written[index] ?? JSON.stringify(ask.args)])));
|
|
675
|
+
await conversation.append([{ role: 'user', content: cites.notice === undefined ? text : `${cites.notice}\n\n${text}` }]);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
async control(run: Run, action: RunControlAction): Promise<ControlAnswer> {
|
|
679
|
+
this.#iterating.get(run.id)?.abort(action);
|
|
680
|
+
const job = this.#jobs.get(run.id);
|
|
681
|
+
if (job !== undefined) await this.#deps.queues.cancel(job, action);
|
|
682
|
+
this.#jobs.delete(run.id);
|
|
683
|
+
// Read after stopping: the iteration saves its state as it goes, so the run handed in may be behind.
|
|
684
|
+
const state = stateOf((await this.#deps.runs.get(run.id)) ?? run);
|
|
685
|
+
if (action === 'cancel') {
|
|
686
|
+
// held calls never start once it is cancelled, Continue included; a pause keeps them held
|
|
687
|
+
await this.#skipHeld(run.id);
|
|
688
|
+
for (const call of state.pending) if (call.run !== undefined) await this.#deps.runs.cancel(call.run, run.actor);
|
|
689
|
+
// read again: skipping held calls saved them
|
|
690
|
+
await this.#closeOpen(run, stateOf((await this.#deps.runs.get(run.id)) ?? run), 'cancelled');
|
|
691
|
+
if (state.message !== undefined) await this.#deps.turns.finish(state.message, [{ type: 'text', text: 'Cancelled.' }], 'failed');
|
|
692
|
+
await this.#deps.runs.settle(run.id, { status: 'cancelled' });
|
|
693
|
+
} else {
|
|
694
|
+
await this.#deps.runs.settle(run.id, { status: 'paused', resume: Json.parse(state) });
|
|
695
|
+
}
|
|
696
|
+
return { accepted: true };
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** The run's deadline passed: stop its iteration and its tool calls, and say so in its message. The run service settles it. */
|
|
700
|
+
async stop(run: Run, error: FnError): Promise<void> {
|
|
701
|
+
this.#iterating.get(run.id)?.abort('timeout');
|
|
702
|
+
const job = this.#jobs.get(run.id);
|
|
703
|
+
if (job !== undefined) await this.#deps.queues.cancel(job, 'timeout');
|
|
704
|
+
this.#jobs.delete(run.id);
|
|
705
|
+
const state = stateOf((await this.#deps.runs.get(run.id)) ?? run);
|
|
706
|
+
await this.#skipHeld(run.id);
|
|
707
|
+
for (const call of state.pending) if (call.run !== undefined) await this.#deps.runs.cancel(call.run, run.actor);
|
|
708
|
+
await this.#closeOpen(run, stateOf((await this.#deps.runs.get(run.id)) ?? run), 'stopped');
|
|
709
|
+
if (state.message !== undefined) await this.#deps.turns.finish(state.message, [{ type: 'text', text: failureText(error) }], 'failed');
|
|
710
|
+
this.#deps.log.info('agent.stopped', { run: run.id, code: error.code });
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/** Agents have no undo of their own: their tool runs are undone one by one. */
|
|
714
|
+
undo(): Promise<{ status: 'gone' }> {
|
|
715
|
+
return Promise.resolve({ status: 'gone' });
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* A run a session's agent no longer waits for has settled: a tool run it stopped waiting for (it went to the
|
|
720
|
+
* background), or a run a system proposed while serving one of its calls (`propose`), which waited for the person's
|
|
721
|
+
* approval after that call returned. How it ended goes into the session's transcript, for the agent alone to read, and
|
|
722
|
+
* the agent is woken to follow up in its own words (a new turn, unless it is answering in the session already and
|
|
723
|
+
* will read it on its next step). The run's card stays where it was, under the answer that started it, and resolves
|
|
724
|
+
* there. Runs of other callers, of agents that aren't the session's, and runs outside a session are left alone.
|
|
725
|
+
*/
|
|
726
|
+
async reportBack(run: Run, settled: RunSettled): Promise<void> {
|
|
727
|
+
if (run.parent === undefined || run.session === undefined || settled.status === 'background') return;
|
|
728
|
+
const proposed = run.key.startsWith(PROPOSED_KEY);
|
|
729
|
+
if (!run.background && !proposed) return;
|
|
730
|
+
// a background run is the agent's own tool call; a proposed run hangs under a system's run in the agent's turn
|
|
731
|
+
const parent = await this.#deps.runs.get(proposed ? run.root : run.parent);
|
|
732
|
+
if (parent?.kind !== AGENT_KIND || parent.parent !== undefined) return;
|
|
733
|
+
const session = await this.#deps.store.table('sessions').get(run.session);
|
|
734
|
+
if (session?.agent !== parent.fn) return;
|
|
735
|
+
const reading = await this.#reading(run);
|
|
736
|
+
const result = proposed ? proposedResult(run, settled, reading) : backgroundResult(run, settled, reading);
|
|
737
|
+
const content = session.citations === true ? withCiteId(run.id, result) : result;
|
|
738
|
+
await new SessionConversation(this.#deps, session.id).append([{ role: 'user', content }]);
|
|
739
|
+
const turn = await this.#deps.turns.followUp({ turn: run.turn, agent: await this.#agentActor(parent) });
|
|
740
|
+
this.#deps.log.info('agent.reported-back', { run: run.id, fn: run.fn, parent: parent.id, status: settled.status, followUp: turn ?? null });
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/** Re-arm the wait of every agent run that was waiting for its tools (after a restart). */
|
|
744
|
+
async recover(): Promise<void> {
|
|
745
|
+
for await (const run of rows(this.#deps.store.table('runs'), { where: { status: 'waiting', kind: AGENT_KIND } })) void this.#await(run, stateOf(run));
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* Wait until every call of an iteration has settled or gone to the background, then queue the next iteration. Held
|
|
750
|
+
* calls start as the calls they wait for settle (`#release`). Everything it goes by is on the stored state, so after a
|
|
751
|
+
* restart (`recover`) it carries on where it was. When the person is still there after the tool timeout, the running
|
|
752
|
+
* calls go to the background and the held ones are skipped: the agent answers with what it has.
|
|
753
|
+
*/
|
|
754
|
+
async #await(run: Run, state: AgentState): Promise<void> {
|
|
755
|
+
const { runs, presence, settings, log } = this.#deps;
|
|
756
|
+
const timeout = settings.queue.HARNESS_TOOL_TIMEOUT;
|
|
757
|
+
for (;;) {
|
|
758
|
+
const now = await this.#release(run.id, state.iteration);
|
|
759
|
+
if (now === undefined) return;
|
|
760
|
+
const held = now.state.pending.filter(isHeld);
|
|
761
|
+
// while calls are held, wake when one they wait for settles; then, when every call has settled or gone to the background
|
|
762
|
+
const watch = held.length === 0 ? undefined : this.#anySettled(blockersOf(now.state, held));
|
|
763
|
+
const progress = watch?.settled ?? Promise.all(now.state.pending.flatMap((call) => (call.run === undefined ? [] : [runs.wait(call.run)])));
|
|
764
|
+
const outcome = await Promise.race([progress.then(() => 'progress' as const), sleep(timeout).then(() => 'timeout' as const)]).finally(() => { watch?.stop(); });
|
|
765
|
+
if (outcome === 'progress') {
|
|
766
|
+
if (held.length === 0) break;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (run.session !== undefined && (await presence.active(run.session))) {
|
|
770
|
+
log.info('agent.tool-timeout', { run: run.id, iteration: state.iteration, held: held.length });
|
|
771
|
+
await this.#backgroundCalls(now.state);
|
|
772
|
+
await this.#skipHeld(run.id);
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
const current = await runs.get(run.id);
|
|
777
|
+
if (current?.status === 'waiting' && stateOf(current).iteration === state.iteration) this.#queue(current, state.iteration);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
#queue(run: Run, iteration: number): void {
|
|
781
|
+
this.#jobs.set(run.id, this.#deps.queues.enqueueLlm({
|
|
782
|
+
run: run.id, turn: run.turn, iteration, priority: run.priority, ...(run.session === undefined ? {} : { session: run.session }),
|
|
783
|
+
}));
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Record the calls core refused (args that don't fit their tool's schema) as runs settled invalid-input at once, so
|
|
788
|
+
* the chat shows each calmly, as retried, and the fn's metrics count it ("Thinking harder"). Core already answered
|
|
789
|
+
* each in the conversation and asked the model again in the same job, so nothing is answered here. A call that names
|
|
790
|
+
* no fn (a garbled name) is answered by core alone. Keyed by iteration and call id, like every call's run.
|
|
791
|
+
*/
|
|
792
|
+
async #recordRefused(
|
|
793
|
+
run: Run, iteration: number, refused: readonly RefusedCall[], names: ModelFnNames, fns: ReadonlyMap<string, QualifiedName>, llmCall: Run['llmCall'], message: MessageId | undefined,
|
|
794
|
+
): Promise<void> {
|
|
795
|
+
if (refused.length === 0) return;
|
|
796
|
+
const caller = await this.#agentActor(run);
|
|
797
|
+
const tracked: Array<{ run: RunId; fn: QualifiedName }> = [];
|
|
798
|
+
const seen = new Map<string, number>();
|
|
799
|
+
for (const call of refused) {
|
|
800
|
+
// core asks again in the same job, where a model may reuse a call's id: each refusal is its own run, and never
|
|
801
|
+
// the run of the call that finally fits
|
|
802
|
+
const attempt = seen.get(call.toolCallId) ?? 0;
|
|
803
|
+
seen.set(call.toolCallId, attempt + 1);
|
|
804
|
+
const { fn, args } = refusedFn(call, names, fns);
|
|
805
|
+
if (fn === undefined || (await this.#deps.catalog.fn(fn)) === undefined) continue;
|
|
806
|
+
const problem = call.error.replace(/^Error parsing tool arguments: /, '');
|
|
807
|
+
try {
|
|
808
|
+
const started = await this.#deps.runs.start({
|
|
809
|
+
fn, args, invalid: { source: 'schema', problems: [{ path: '', message: problem }] }, turn: run.turn, parent: run.id, key: `${toolCallKey(iteration, call.toolCallId)}${REFUSED_KEY}${attempt}`, actor: run.actor, caller,
|
|
810
|
+
priority: run.priority, background: false, handlers: [], toolCallId: call.toolCallId, ...(run.session === undefined ? {} : { session: run.session }), ...(llmCall === undefined ? {} : { llmCall }),
|
|
811
|
+
});
|
|
812
|
+
tracked.push({ run: started.run, fn });
|
|
813
|
+
this.#deps.log.info('agent.invalid-input', { run: run.id, iteration, fn, source: 'schema' });
|
|
814
|
+
} catch (error) {
|
|
815
|
+
this.#deps.log.warn('agent.invalid-input.unrecorded', { run: run.id, fn, error: messageOf(error) });
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
if (message !== undefined && tracked.length > 0) await this.#deps.turns.track(message, tracked);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/** The native tool calls of an iteration that suspended, in the order the model made them, with the message holding them. */
|
|
822
|
+
#toolCalls(collected: readonly LlmMessage[], calls: PendingCalls): { calls: ModelCalls; index: number } {
|
|
823
|
+
const index = lastToolCallsIndex(collected);
|
|
824
|
+
const ids = collected[index]?.toolCalls?.map((c) => c.id) ?? [];
|
|
825
|
+
return { index, calls: calls.inOrder(ids).map((call) => ({ toolCallId: call.toolCallId, block: false, out: { type: 'tool', id: call.toolCallId, name: call.name, args: call.args } })) };
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/** The `<run>` blocks of a text-protocol answer (none for native tools or an answer without blocks), each with a made-up call id. */
|
|
829
|
+
#blockCalls(collected: readonly LlmMessage[], answer: AgentOutput | undefined, iteration: number): { calls: ModelCalls; index: number } | undefined {
|
|
830
|
+
if (typeof answer !== 'string') return undefined;
|
|
831
|
+
const found = parseRunBlocks(answer).calls;
|
|
832
|
+
if (found.length === 0) return undefined;
|
|
833
|
+
const index = collected.findLastIndex((m) => m.role === 'assistant');
|
|
834
|
+
return {
|
|
835
|
+
index,
|
|
836
|
+
calls: found.map((block, i) => {
|
|
837
|
+
const id = `block_${iteration}_${i + 1}`;
|
|
838
|
+
return { toolCallId: id, block: true, out: { type: 'block', id, ...block } };
|
|
839
|
+
}),
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* Start an iteration's calls as child runs: each planned run of a fn (never a wrapper: a static `run` starts the fn
|
|
845
|
+
* it names), keyed by its iteration and call id, so a job that runs the iteration again gets the same runs back while
|
|
846
|
+
* a model that reuses ids across iterations (some do) still gets new runs. A call refused before it ran (invalid
|
|
847
|
+
* input) is answered with its reply; a run that can't start is answered with why. A call whose claims conflict with
|
|
848
|
+
* an earlier call's (`claims.ts`) is held instead: it starts once those have settled (`#release`).
|
|
849
|
+
*/
|
|
850
|
+
async #startCalls(
|
|
851
|
+
run: Run, iteration: number, calls: ReadonlyArray<ModelCalls[number] & { plan: CallPlan }>, llmCall: Run['llmCall'], step: { user: UserInfo; sequential: boolean },
|
|
852
|
+
repaired: ReadonlyMap<string, readonly ArgRepair[]> = new Map(),
|
|
853
|
+
): Promise<PendingCall[]> {
|
|
854
|
+
const caller = await this.#agentActor(run);
|
|
855
|
+
const waits = await stepWaits(this.#deps, { ...step, caller: run.id, session: run.session }, calls.map(({ toolCallId, plan }) => ({
|
|
856
|
+
toolCallId, fn: plan.type === 'run' ? plan.fn : undefined, args: plan.args ?? {},
|
|
857
|
+
})));
|
|
858
|
+
const pending: PendingCall[] = [];
|
|
859
|
+
for (const [index, { toolCallId, block, plan, out }] of calls.entries()) {
|
|
860
|
+
const marker = block ? { block: true } : {};
|
|
861
|
+
if (plan.type === 'invalid') {
|
|
862
|
+
// refused input for a fn the model named is still a run (settled invalid-input at once), so the chat shows it
|
|
863
|
+
// as retried and the fn's metrics count it; the model reads the plan's reply, with the fn's card
|
|
864
|
+
const recorded = plan.fn === undefined ? undefined : await this.#deps.runs.start({
|
|
865
|
+
fn: plan.fn, args: plan.args ?? {}, invalid: plan.invalid, turn: run.turn, parent: run.id, key: toolCallKey(iteration, toolCallId), actor: run.actor, caller,
|
|
866
|
+
priority: run.priority, background: false, handlers: [], toolCallId, ...(run.session === undefined ? {} : { session: run.session }), ...(llmCall === undefined ? {} : { llmCall }),
|
|
867
|
+
}).then((started) => started.run, (error: unknown) => {
|
|
868
|
+
this.#deps.log.warn('agent.invalid-input.unrecorded', { run: run.id, fn: plan.fn ?? null, error: messageOf(error) });
|
|
869
|
+
return undefined;
|
|
870
|
+
});
|
|
871
|
+
pending.push({ toolCallId, fn: plan.fn ?? (out.type === 'tool' ? out.name : out.fn ?? 'run'), invalid: plan.reply, ...(recorded === undefined ? {} : { run: recorded }), ...marker });
|
|
872
|
+
this.#deps.log.info('agent.invalid-input', { run: run.id, iteration, fn: plan.fn ?? null, source: plan.invalid.source });
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
const repairs = repaired.get(toolCallId) ?? [];
|
|
876
|
+
const held: HeldCall = {
|
|
877
|
+
after: waits[index] ?? [], args: plan.args, ...(plan.on === undefined ? {} : { on: plan.on }), ...(llmCall === undefined ? {} : { llmCall }), ...(repairs.length === 0 ? {} : { repairs: [...repairs] }),
|
|
878
|
+
};
|
|
879
|
+
if (held.after.length > 0) {
|
|
880
|
+
pending.push({ toolCallId, fn: plan.fn, held, ...marker });
|
|
881
|
+
this.#deps.log.info('agent.call-held', { run: run.id, iteration, fn: plan.fn, after: held.after });
|
|
882
|
+
continue;
|
|
883
|
+
}
|
|
884
|
+
pending.push(await this.#startCall(run, caller, iteration, { toolCallId, fn: plan.fn, held, ...marker }));
|
|
885
|
+
}
|
|
886
|
+
return pending;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** Start one call as a child run, keyed by its iteration and call id (so starting it again gets the same run back). */
|
|
890
|
+
async #startCall(run: Run, caller: ActorId, iteration: number, call: PendingCall & { held: HeldCall }): Promise<PendingCall> {
|
|
891
|
+
const { held, skipped: _skipped, ...rest } = call;
|
|
892
|
+
try {
|
|
893
|
+
const started = await this.#deps.runs.start({
|
|
894
|
+
fn: QualifiedName.parse(call.fn), args: held.args, turn: run.turn, parent: run.id, key: toolCallKey(iteration, call.toolCallId), actor: run.actor, caller, priority: run.priority,
|
|
895
|
+
background: false, handlers: [], toolCallId: call.toolCallId, ...(held.on === undefined ? {} : { on: held.on }), ...(run.session === undefined ? {} : { session: run.session }),
|
|
896
|
+
...(held.llmCall === undefined ? {} : { llmCall: held.llmCall }), ...(held.repairs === undefined ? {} : { repairs: held.repairs }),
|
|
897
|
+
});
|
|
898
|
+
return { ...rest, run: started.run };
|
|
899
|
+
} catch (error) {
|
|
900
|
+
return { ...rest, error: causeOf(error, RunRefused)?.error.message ?? messageOf(error) };
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Start the held calls of an iteration whose waits are over: every call each waits for has settled (one that never
|
|
906
|
+
* became a run counts as settled; one in the background is still running). Each start is saved on the agent's state
|
|
907
|
+
* at once, so a restart neither loses a held call nor starts it twice (a call started again gets its run back by its
|
|
908
|
+
* key). The agent run and its state as they are now, or undefined when the run no longer waits for this iteration.
|
|
909
|
+
*/
|
|
910
|
+
async #release(id: RunId, iteration: number): Promise<{ run: Run; state: AgentState } | undefined> {
|
|
911
|
+
for (;;) {
|
|
912
|
+
const run = await this.#deps.runs.get(id);
|
|
913
|
+
if (run?.status !== 'waiting') return undefined;
|
|
914
|
+
const state = stateOf(run);
|
|
915
|
+
if (state.iteration !== iteration) return undefined;
|
|
916
|
+
const ready = await this.#ready(state);
|
|
917
|
+
if (ready.length === 0) return { run, state };
|
|
918
|
+
const caller = await this.#agentActor(run);
|
|
919
|
+
// the state already names the iteration it runs next; its pending calls were made by the one before
|
|
920
|
+
const made = iteration - 1;
|
|
921
|
+
for (const call of ready) {
|
|
922
|
+
const started = await this.#startCall(run, caller, made, call);
|
|
923
|
+
this.#deps.log.info('agent.call-released', { run: id, iteration, fn: call.fn, child: started.run ?? null });
|
|
924
|
+
if (!(await this.#saveStarted(id, iteration, started))) {
|
|
925
|
+
// the agent stopped waiting while the call started: a cancelled or finished agent leaves no call running (a
|
|
926
|
+
// paused one finds it again by its key when it resumes)
|
|
927
|
+
const now = await this.#deps.runs.get(id);
|
|
928
|
+
if (started.run !== undefined && now?.status !== 'paused') await this.#deps.runs.cancel(started.run, run.actor);
|
|
929
|
+
return undefined;
|
|
930
|
+
}
|
|
931
|
+
if (started.run !== undefined && state.message !== undefined) await this.#deps.turns.track(state.message, [{ run: started.run, fn: QualifiedName.parse(started.fn) }]);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/** The held calls whose waits are over, in the model's order. */
|
|
937
|
+
async #ready(state: AgentState): Promise<Array<PendingCall & { held: HeldCall }>> {
|
|
938
|
+
const byId = new Map(state.pending.map((call) => [call.toolCallId, call]));
|
|
939
|
+
const settled = async (toolCallId: string): Promise<boolean> => {
|
|
940
|
+
const call = byId.get(toolCallId);
|
|
941
|
+
if (call === undefined || call.skipped === true) return true;
|
|
942
|
+
if (call.run === undefined) return call.held === undefined;
|
|
943
|
+
const child = await this.#deps.runs.get(call.run);
|
|
944
|
+
return child === undefined || isSettled(child.status);
|
|
945
|
+
};
|
|
946
|
+
const ready: Array<PendingCall & { held: HeldCall }> = [];
|
|
947
|
+
for (const call of state.pending) {
|
|
948
|
+
if (!isHeld(call)) continue;
|
|
949
|
+
const waits = await Promise.all(call.held.after.map(settled));
|
|
950
|
+
if (waits.every(Boolean)) ready.push(call);
|
|
951
|
+
}
|
|
952
|
+
return ready;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/** Save a held call as started (its run, or why it couldn't start), if the agent still waits for its iteration. */
|
|
956
|
+
async #saveStarted(id: RunId, iteration: number, started: PendingCall): Promise<boolean> {
|
|
957
|
+
return this.#deps.store.tx(async (tx) => {
|
|
958
|
+
const run = await tx.table('runs').get(id);
|
|
959
|
+
if (run?.status !== 'waiting') return false;
|
|
960
|
+
const state = stateOf(run);
|
|
961
|
+
if (state.iteration !== iteration) return false;
|
|
962
|
+
const pending = state.pending.map((call) => (call.toolCallId === started.toolCallId ? started : call));
|
|
963
|
+
await tx.table('runs').update(id, { resume: Json.parse({ ...state, pending }) });
|
|
964
|
+
return true;
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/** Mark an iteration's held calls as never to start: the agent stopped waiting for them. */
|
|
969
|
+
async #skipHeld(id: RunId): Promise<void> {
|
|
970
|
+
await this.#deps.store.tx(async (tx) => {
|
|
971
|
+
const run = await tx.table('runs').get(id);
|
|
972
|
+
if (run === undefined) return;
|
|
973
|
+
const state = stateOf(run);
|
|
974
|
+
if (!state.pending.some(isHeld)) return;
|
|
975
|
+
const pending = state.pending.map((call): PendingCall => (isHeld(call) ? { ...call, skipped: true } : call));
|
|
976
|
+
await tx.table('runs').update(id, { resume: Json.parse({ ...state, pending }) });
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* Settles once any of these runs settles (in the background a run is still running), or at once when none is
|
|
982
|
+
* running now. `stop` drops the listener.
|
|
983
|
+
*/
|
|
984
|
+
#anySettled(ids: readonly RunId[]): { settled: Promise<void>; stop: () => void } {
|
|
985
|
+
let stop = (): void => undefined;
|
|
986
|
+
const settled = new Promise<void>((resolve) => {
|
|
987
|
+
const heard = new Set<RunId>();
|
|
988
|
+
let open: ReadonlySet<RunId> | undefined;
|
|
989
|
+
// listening first, so a run that settles while the rows are read is still heard
|
|
990
|
+
stop = this.#deps.runs.onSettled((run) => {
|
|
991
|
+
heard.add(run.id);
|
|
992
|
+
if (open?.has(run.id) === true) resolve();
|
|
993
|
+
});
|
|
994
|
+
void Promise.all(ids.map((id) => this.#deps.runs.get(id))).then((rows) => {
|
|
995
|
+
open = new Set(rows.flatMap((row) => (row === undefined || isSettled(row.status) ? [] : [row.id])));
|
|
996
|
+
if (open.size === 0 || [...open].some((id) => heard.has(id))) resolve();
|
|
997
|
+
}, () => { resolve(); });
|
|
998
|
+
});
|
|
999
|
+
return { settled, stop: () => { stop(); } };
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* The replies for an iteration's calls, in call order: a tool message for a native call, a `<result>` user message
|
|
1004
|
+
* for a block. Refused input is answered with what was wrong and doesn't count as a failure; a run's exposed fns
|
|
1005
|
+
* follow its result. `allFailed` says whether every call failed; `stopped` is set when a fn's output hook stopped a
|
|
1006
|
+
* call (the agent run ends with that reason).
|
|
1007
|
+
*/
|
|
1008
|
+
async #replies(pending: readonly PendingCall[], prompt: ExposedTo | undefined): Promise<{ messages: LlmMessage[]; allFailed: boolean; stopped?: FnError }> {
|
|
1009
|
+
let stopped: FnError | undefined;
|
|
1010
|
+
let failed = 0;
|
|
1011
|
+
// out to the model: every fn a reply names is spelled as the model calls it in this session's mode
|
|
1012
|
+
const names = prompt === undefined ? undefined : await this.#deps.planner.names(prompt);
|
|
1013
|
+
// each reply is written first, then every name the replies hold is looked up in one batch and spelled
|
|
1014
|
+
// a call that showed the model a resource: the reference follows the replies, made for the model at each call
|
|
1015
|
+
const shown: LlmMessage[] = [];
|
|
1016
|
+
const unspoken = await Promise.all(pending.map(async (call): Promise<{ readonly call: PendingCall; readonly text: string }> => {
|
|
1017
|
+
const reply = (status: string, content: string) => ({ call, text: call.block === true ? resultText(call.fn, status, content) : content });
|
|
1018
|
+
if (call.invalid !== undefined) return reply('invalid-input', call.invalid);
|
|
1019
|
+
// a held call the agent stopped waiting for never ran; that isn't the call failing
|
|
1020
|
+
if (call.run === undefined && call.held !== undefined) return reply('skipped', heldReply({ ...call, held: call.held }, pending));
|
|
1021
|
+
if (call.run === undefined) {
|
|
1022
|
+
failed += 1;
|
|
1023
|
+
return reply('failed', `Error: ${call.error ?? 'the call could not start'}`);
|
|
1024
|
+
}
|
|
1025
|
+
const child = await this.#deps.runs.get(call.run);
|
|
1026
|
+
const outcome = child?.outcome;
|
|
1027
|
+
if (outcome?.status === 'invalid-input') return reply('invalid-input', invalidReply(outcome.invalid));
|
|
1028
|
+
const settled: RunSettled = child === undefined ? { status: 'failed', error: fnError('fatal', 'the run is gone') }
|
|
1029
|
+
: isSettled(child.status) ? settledOf(outcome, child.id) : { status: 'background', run: child.id };
|
|
1030
|
+
// a result read as JSON has its fn-name fields (`g.fnName()` in its fn's result type) as the model calls those fns
|
|
1031
|
+
const returns = names === undefined || child === undefined || settled.status !== 'done' ? undefined : (await this.#deps.catalog.fn(child.fn))?.decl.returns;
|
|
1032
|
+
const encode = names === undefined ? undefined : (value: Json): Json => names.value(value, returns);
|
|
1033
|
+
if (settled.status === 'failed') failed += 1;
|
|
1034
|
+
if (settled.status === 'failed' && settled.error.code === OUTPUT_REFUSED) stopped ??= settled.error;
|
|
1035
|
+
if (settled.status === 'done' && child?.fn === SEND_FN) shown.push(...shownOf(child.args));
|
|
1036
|
+
const exposed = outcome?.status === 'done' && outcome.expose !== undefined && prompt !== undefined ? await this.#deps.planner.exposed(outcome.expose, prompt) : '';
|
|
1037
|
+
const reading = child === undefined ? { rows: this.#deps.settings.execution.HARNESS_HEADLESS_RESULT_ROWS, watched: false } : await this.#reading(child);
|
|
1038
|
+
const examples = settled.status === 'done' && prompt !== undefined && encode !== undefined ? await this.#examplesPage(settled.result, prompt, encode) : undefined;
|
|
1039
|
+
const text = examples ?? settledReply(settled, reading, encode);
|
|
1040
|
+
const content = exposed === '' ? text : `${text}\n\n${exposed}`;
|
|
1041
|
+
// with citations on, the model reads each result's id first: what its cites name
|
|
1042
|
+
return reply(settled.status, prompt?.session?.citations === true ? withCiteId(call.run, content) : content);
|
|
1043
|
+
}));
|
|
1044
|
+
await names?.learn(unspoken.map((reply) => reply.text));
|
|
1045
|
+
// its fns spelled, then the examples kept from the speller (a page of examples' args) written as they are
|
|
1046
|
+
const spoken = (text: string): string => (names === undefined ? plainDeferred(text) : spelled(names, text));
|
|
1047
|
+
const messages = unspoken.map(({ call, text }): LlmMessage => (call.block === true
|
|
1048
|
+
? { role: 'user', content: spoken(text) }
|
|
1049
|
+
: { role: 'tool', toolCallId: call.toolCallId, content: spoken(text) }));
|
|
1050
|
+
messages.push(...shown);
|
|
1051
|
+
return { messages, allFailed: pending.length > 0 && failed === pending.length, ...(stopped === undefined ? {} : { stopped }) };
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/**
|
|
1055
|
+
* A page of a fn's examples (`hub/fns_examples`) as the model reads it: its fields as any result's (`encode`), each
|
|
1056
|
+
* example's args written as the model would send them for that fn here (`PromptPlanner.writeArgs`), kept from the
|
|
1057
|
+
* fn-name speller. Undefined for a result that isn't such a page.
|
|
1058
|
+
*/
|
|
1059
|
+
async #examplesPage(result: Json, prompt: ExposedTo, encode: (value: Json) => Json): Promise<string | undefined> {
|
|
1060
|
+
const page = FnExamplesPage.safeParse(result);
|
|
1061
|
+
if (!page.success) return undefined;
|
|
1062
|
+
const written = await this.#deps.planner.writeArgs(prompt, page.data.items.map((item) => ({ fn: page.data.fn, args: item.args })));
|
|
1063
|
+
const rest = JsonObject.parse(encode(Json.parse({ ...page.data, items: page.data.items.map(({ args: _args, ...item }) => item) })));
|
|
1064
|
+
const items = Array.isArray(rest['items']) ? rest['items'] : [];
|
|
1065
|
+
// each example's args go in as their text (a deferred value, put in place once the JSON is written)
|
|
1066
|
+
const asValue = (text: string | undefined): unknown => (text === undefined ? null : text.startsWith('⟦') ? text : JSON.parse(text));
|
|
1067
|
+
const shown = { ...rest, items: items.map((item, index) => ({ args: asValue(written[index]), ...(typeof item === 'object' && item !== null && !Array.isArray(item) ? item : {}) })) };
|
|
1068
|
+
return inlineDeferred(JSON.stringify(shown));
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* A conversation as the model takes it (`AgentLoopDeps.media`); as kept when there is no media service or it fails.
|
|
1073
|
+
* Either way no image part that isn't a real picture goes out (`pictureParts`): one would fail every turn after it.
|
|
1074
|
+
*/
|
|
1075
|
+
async #media(messages: readonly LlmMessage[], model: string, who: Asking): Promise<LlmMessage[]> {
|
|
1076
|
+
if (this.#deps.media === undefined) return pictureParts([...messages]);
|
|
1077
|
+
try {
|
|
1078
|
+
return await this.#deps.media.expand(messages, model, who);
|
|
1079
|
+
} catch (error) {
|
|
1080
|
+
this.#deps.log.warn('agent.media-failed', { model, error: messageOf(error) });
|
|
1081
|
+
return pictureParts([...messages]);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* How the model reads a tool run's table result: watched (`RunInfo.watched`, a chat turn on an open session) the
|
|
1087
|
+
* person sees the table and the model gets a few rows; unwatched no one sees it and the model gets more to answer from.
|
|
1088
|
+
*/
|
|
1089
|
+
async #reading(run: Run): Promise<TableReading> {
|
|
1090
|
+
const { execution } = this.#deps.settings;
|
|
1091
|
+
const watched = (await this.#deps.runs.info(run)).watched === true;
|
|
1092
|
+
return { rows: watched ? execution.HARNESS_TOOL_RESULT_ROWS : execution.HARNESS_HEADLESS_RESULT_ROWS, watched };
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
/** The assistant message a session's agent answers into, opened on its first iteration. */
|
|
1096
|
+
async #message(run: Run, state: AgentState, replyTo: MessageId | undefined): Promise<MessageId> {
|
|
1097
|
+
if (state.message !== undefined) return state.message;
|
|
1098
|
+
const opened = await this.#deps.turns.begin({ turn: run.turn, author: await this.#agentActor(run), ...(replyTo === undefined ? {} : { replyTo }) });
|
|
1099
|
+
return opened.id;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* The actor of an agent fn (the author of its messages and the caller of its tools), made on first use. Never the
|
|
1104
|
+
* person who ran it: an agent's tool calls are the agent's, so policies ask for them as they would in a session.
|
|
1105
|
+
*/
|
|
1106
|
+
async #agentActor(run: Run): Promise<ActorId> {
|
|
1107
|
+
const known = this.#agents.get(run.fn);
|
|
1108
|
+
if (known !== undefined) return known;
|
|
1109
|
+
const fn = await this.#deps.catalog.fn(run.fn);
|
|
1110
|
+
if (fn === undefined) throw new Error(`${run.fn} no longer exists`);
|
|
1111
|
+
const actor = await ensureAgentActor(this.#deps, fn);
|
|
1112
|
+
this.#agents.set(run.fn, actor.id);
|
|
1113
|
+
return actor.id;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/** The conversation to keep on the state (only for agents that aren't a session's). */
|
|
1117
|
+
#saved(conversation: Conversation): Pick<AgentState, 'messages'> {
|
|
1118
|
+
return conversation instanceof RunConversation ? { messages: conversation.saved } : {};
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* A run that stops (fails, is cancelled, or runs out of time) while its native tool calls wait for replies: each call
|
|
1123
|
+
* still without a `tool` reply in the session's transcript gets one (how its run stands, or that it has no result), so
|
|
1124
|
+
* the chat never holds a call with no reply (providers refuse every later request over one). Idempotent: calls
|
|
1125
|
+
* already answered are left alone. `<run>` block calls need no reply and stay pending (Continue answers them); a
|
|
1126
|
+
* conversation that isn't a session's is kept on the run and answered on Continue. Never throws (logged instead).
|
|
1127
|
+
*/
|
|
1128
|
+
async #closeOpen(run: Run, state: AgentState, reason: 'failed' | 'cancelled' | 'stopped'): Promise<AgentState> {
|
|
1129
|
+
const native = state.pending.filter((call) => call.block !== true);
|
|
1130
|
+
if (native.length === 0) return state;
|
|
1131
|
+
try {
|
|
1132
|
+
const session = await this.#session(run);
|
|
1133
|
+
if (session === undefined) return state;
|
|
1134
|
+
const conversation = this.#conversation(session, state);
|
|
1135
|
+
const after = (await conversation.messages()).slice(state.anchor + 1);
|
|
1136
|
+
const answered = new Set(after.flatMap((message) => (message.role === 'tool' && message.toolCallId !== undefined ? [message.toolCallId] : [])));
|
|
1137
|
+
const open = native.filter((call) => !answered.has(call.toolCallId));
|
|
1138
|
+
if (open.length > 0) {
|
|
1139
|
+
const fallback = (toolCallId: string): LlmMessage => ({ role: 'tool', toolCallId, content: `Error: this call has no result — the turn stopped (${reason}) before it came back.` });
|
|
1140
|
+
// a call whose run is still going says it has no result: the run is being stopped with this one, and nothing
|
|
1141
|
+
// posts its result later (only a run the agent let go on in the background has that)
|
|
1142
|
+
const going = new Set<string>();
|
|
1143
|
+
for (const call of open) {
|
|
1144
|
+
const child = call.run === undefined ? undefined : await this.#deps.runs.get(call.run);
|
|
1145
|
+
if (child !== undefined && !isSettled(child.status)) going.add(call.toolCallId);
|
|
1146
|
+
}
|
|
1147
|
+
let replies: LlmMessage[];
|
|
1148
|
+
try {
|
|
1149
|
+
const made = (await this.#replies(open, await this.#exposedTo(run, session))).messages;
|
|
1150
|
+
replies = made.map((message) => (message.role === 'tool' && message.toolCallId !== undefined && going.has(message.toolCallId) ? { ...message, content: fallback(message.toolCallId).content } : message));
|
|
1151
|
+
} catch (error) {
|
|
1152
|
+
this.#deps.log.warn('agent.close-replies-failed', { run: run.id, reason, error: messageOf(error) });
|
|
1153
|
+
replies = [];
|
|
1154
|
+
}
|
|
1155
|
+
// every open call answered, whatever the replies hold
|
|
1156
|
+
const replied = new Set(replies.flatMap((message) => (message.role === 'tool' && message.toolCallId !== undefined ? [message.toolCallId] : [])));
|
|
1157
|
+
await conversation.answer(state.anchor, [...replies, ...open.flatMap((call) => (replied.has(call.toolCallId) ? [] : [fallback(call.toolCallId)]))]);
|
|
1158
|
+
}
|
|
1159
|
+
const next: AgentState = { ...state, pending: state.pending.filter((call) => call.block === true) };
|
|
1160
|
+
await this.#deps.store.table('runs').update(run.id, { resume: Json.parse(next) });
|
|
1161
|
+
this.#deps.log.info('agent.closed-open', { run: run.id, reason, closed: open.length });
|
|
1162
|
+
return next;
|
|
1163
|
+
} catch (error) {
|
|
1164
|
+
this.#deps.log.warn('agent.close-failed', { run: run.id, reason, error: messageOf(error) });
|
|
1165
|
+
return state;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/** Who a session agent's replies are written for (fn names spelled as its model calls them); undefined when that can't be worked out. */
|
|
1170
|
+
async #exposedTo(run: Run, session: Session): Promise<ExposedTo | undefined> {
|
|
1171
|
+
try {
|
|
1172
|
+
const fn = await this.#deps.catalog.fn(run.fn);
|
|
1173
|
+
const turn = await this.#deps.store.table('turns').get(run.turn);
|
|
1174
|
+
if (fn === undefined || turn === undefined) return undefined;
|
|
1175
|
+
const payload = parseValue(LlmPayloadType, fn.decl.payload);
|
|
1176
|
+
const metadata = await this.#deps.models.resolve(session.model ?? ModelChoice.optional().parse(payload.model));
|
|
1177
|
+
return { session, agent: fn, model: metadata.model ?? AUTO_MODEL, access: await this.#deps.access.scope(turn.user.id) };
|
|
1178
|
+
} catch {
|
|
1179
|
+
return undefined;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
async #fail(run: Run, given: AgentState, failed: FnError): Promise<void> {
|
|
1184
|
+
const state = await this.#closeOpen(run, given, 'failed');
|
|
1185
|
+
await this.#deps.store.table('runs').update(run.id, { resume: Json.parse(state) });
|
|
1186
|
+
if (state.message !== undefined) await this.#deps.turns.finish(state.message, [{ type: 'text', text: failureText(failed) }], 'failed');
|
|
1187
|
+
const outcome: OutcomeWire = { status: 'failed', error: failed };
|
|
1188
|
+
await this.#deps.runs.settle(run.id, outcome);
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/**
|
|
1193
|
+
* What a session's agent reads when a run it stopped waiting for settles: the fn, how it ended and what it gave,
|
|
1194
|
+
* tagged so the agent can tell it from what a person wrote, and asked to tell the person what came of it.
|
|
1195
|
+
*/
|
|
1196
|
+
export function backgroundResult(run: Pick<Run, 'fn'>, settled: Exclude<RunSettled, { status: 'background' }>, reading: TableReading): string {
|
|
1197
|
+
return `<background-result fn="${run.fn}" status="${settled.status}">\n${settledReply(settled, reading)}\n</background-result>\n`
|
|
1198
|
+
+ 'A call you made earlier finished after you stopped waiting for it. Tell the person what came of it, briefly, in your own words.';
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* What a session's agent reads when a run proposed for the person's approval settles: approved and its result,
|
|
1203
|
+
* declined with who declined and why, or how else it ended, tagged so the agent can tell it from what a person wrote,
|
|
1204
|
+
* and asked to tell the person what came of it.
|
|
1205
|
+
*/
|
|
1206
|
+
export function proposedResult(run: Pick<Run, 'fn'>, settled: Exclude<RunSettled, { status: 'background' }>, reading: TableReading): string {
|
|
1207
|
+
const declined = settled.status === 'cancelled' && settled.error?.code === DECLINED_CODE;
|
|
1208
|
+
const outcome = declined ? 'declined' : settled.status === 'done' ? 'approved' : settled.status;
|
|
1209
|
+
const ask = declined
|
|
1210
|
+
? 'The person declined a change you proposed earlier. Acknowledge it briefly and, if the reason suggests another way, offer it.'
|
|
1211
|
+
: 'A change you proposed earlier was answered. Tell the person what came of it, briefly, in your own words.';
|
|
1212
|
+
return `<approval-result fn="${run.fn}" outcome="${outcome}">\n${settledReply(settled, reading)}\n</approval-result>\n${ask}`;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/** What an agent's message says when its run fails. */
|
|
1216
|
+
function failureText(error: FnError): string {
|
|
1217
|
+
return `I couldn't finish: ${error.message}`;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/** Whether an agent run stopped in a way Continue carries on: at its step limit, or cancelled. */
|
|
1221
|
+
export function continuable(run: Pick<Run, 'status' | 'outcome'>): boolean {
|
|
1222
|
+
return run.status === 'cancelled' || (run.status === 'failed' && run.outcome?.status === 'failed' && run.outcome.error.code === MAX_ITERATIONS);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/** An agent run's loop state. */
|
|
1226
|
+
export function stateOf(run: Run): AgentState {
|
|
1227
|
+
const parsed = AgentState.safeParse(run.resume);
|
|
1228
|
+
return parsed.success ? parsed.data : START;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/** The calls of one iteration before they are interpreted: their id, whether they came as a `<run>` block, and what the model wrote. */
|
|
1232
|
+
type ModelCalls = Array<{ readonly toolCallId: string; readonly block: boolean; readonly out: ModelCallOut }>;
|
|
1233
|
+
|
|
1234
|
+
/** What the model reads for input the hub refused: each problem, by where it was. */
|
|
1235
|
+
export function invalidReply(invalid: InvalidInput): string {
|
|
1236
|
+
const messages = invalid.problems.map((p) => p.message).join('\n');
|
|
1237
|
+
switch (invalid.source) {
|
|
1238
|
+
// the fn's input hook: not the model's mistake, so it isn't asked to fix anything
|
|
1239
|
+
case 'unavailable': return `Not available now: ${messages}`;
|
|
1240
|
+
// the fn's output hook refused the result; its message already asks for another try
|
|
1241
|
+
case 'result': return messages;
|
|
1242
|
+
case 'json': case 'schema': case 'validation': return `The input was not accepted; fix it and try again:\n${problemLines(invalid.problems)}`;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
/** The index of the last assistant message with tool calls. */
|
|
1247
|
+
function lastToolCallsIndex(messages: readonly LlmMessage[]): number {
|
|
1248
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1249
|
+
if (messages[i]?.role === 'assistant' && (messages[i]?.toolCalls?.length ?? 0) > 0) return i;
|
|
1250
|
+
}
|
|
1251
|
+
return -1;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/** The answers of agents whose returns aren't objects, asked for as `{ result }`, made once per signature. */
|
|
1255
|
+
const wrappedReturns = new WeakMap<FnSignature, Bundle<AgentOutput, HarnessGrammarArgs>>();
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* How an agent's answer is asked for and read back: text as text, objects as they are, anything else wrapped. Its
|
|
1259
|
+
* schema is the fn's returns bound with the prompt's names, so a fn-name field in the answer comes back qualified.
|
|
1260
|
+
*/
|
|
1261
|
+
function outputOf(signature: FnSignature, names: FnNameSpelling): { schema?: Bindable<AgentOutput>; result: (output: AgentOutput) => Json } {
|
|
1262
|
+
if (signature.returns.name === 'text') return { result: (output) => (typeof output === 'string' ? output : JSON.stringify(output)) };
|
|
1263
|
+
const returns = signature.returnsFor<AgentOutput>(names);
|
|
1264
|
+
if (isObjectBound(signature.returnsFor())) return { schema: bindable(returns), result: (output) => Json.parse(output) };
|
|
1265
|
+
let wrapped = wrappedReturns.get(signature);
|
|
1266
|
+
if (wrapped === undefined) wrappedReturns.set(signature, (wrapped = HarnessGrammar.result<AgentOutput>(a.object({ result: returns.root }))));
|
|
1267
|
+
return { schema: bindable(wrapped.bind(signature.returns.registry, names)), result: (output) => Json.parse(JsonObject.parse(output)['result'] ?? null) };
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/** A call core refused before it ran: which call, the tool the model called, what it was told, and its args as written. */
|
|
1271
|
+
interface RefusedCall {
|
|
1272
|
+
readonly toolCallId: string;
|
|
1273
|
+
readonly tool: string;
|
|
1274
|
+
readonly error: string;
|
|
1275
|
+
readonly rawArgs?: string;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/** A tool's name, from the tool an event names (absent for a tool the request didn't have) or the name the model called. */
|
|
1279
|
+
function toolNameOf(tool: { readonly name: string } | undefined, called: string): string {
|
|
1280
|
+
return tool?.name ?? called;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** A string's JSON, or undefined when it holds none. */
|
|
1284
|
+
function jsonOf(text: string | undefined): Json | undefined {
|
|
1285
|
+
if (text === undefined) return undefined;
|
|
1286
|
+
try {
|
|
1287
|
+
return Json.parse(JSON.parse(text));
|
|
1288
|
+
} catch {
|
|
1289
|
+
return undefined;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* The fn a refused call was for, and its args as the model wrote them: a fn's own tool (by the prompt's tools, or its
|
|
1295
|
+
* name read back), or the fn a static `run` names. A call through core's dispatcher (`run_tool`) carries `{ tool, args }`.
|
|
1296
|
+
*/
|
|
1297
|
+
function refusedFn(call: RefusedCall, names: ModelFnNames, fns: ReadonlyMap<string, QualifiedName>): { fn?: QualifiedName; args: Json } {
|
|
1298
|
+
const written = jsonOf(call.rawArgs);
|
|
1299
|
+
const object = JsonObject.safeParse(written).data;
|
|
1300
|
+
const args = object !== undefined && object['tool'] === call.tool && 'args' in object ? object['args'] ?? {} : written ?? {};
|
|
1301
|
+
if (call.tool !== 'run') {
|
|
1302
|
+
const fn = fns.get(call.tool) ?? names.fn(call.tool);
|
|
1303
|
+
return { ...(fn === undefined ? {} : { fn }), args };
|
|
1304
|
+
}
|
|
1305
|
+
const run = JsonObject.safeParse(args).data;
|
|
1306
|
+
const named = typeof run?.['fn'] === 'string' ? names.fn(run['fn']) : undefined;
|
|
1307
|
+
return { ...(named === undefined ? {} : { fn: named }), args: run?.['args'] ?? {} };
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* The repairs core made in a call it decoded (`toolArgRepairAttempt`: top-level fields sent as a string of their JSON),
|
|
1312
|
+
* as paths in the fn's args: a fn tool's field is that arg; static `run`'s `args` is the whole of the fn's args.
|
|
1313
|
+
*/
|
|
1314
|
+
function repairsOfFields(tool: string, fields: readonly string[]): ArgRepair[] {
|
|
1315
|
+
if (tool !== 'run') return fields.map((path) => ({ path, repair: 'json-string' }));
|
|
1316
|
+
return fields.includes('args') ? [{ path: '', repair: 'json-string' }] : [];
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* The streamer the agent's prompt calls, with every finished tool call's names learned before it is yielded: core
|
|
1321
|
+
* decodes a call as soon as it has it, and a cut model name (`ModelFnNames`) reads back only once learned.
|
|
1322
|
+
*/
|
|
1323
|
+
function learning(streamer: Streamer<HubCallContext, HubCallMetadata>, names: ModelFnNames): Streamer<HubCallContext, HubCallMetadata> {
|
|
1324
|
+
return async function* learned(request, context, metadata, signal) {
|
|
1325
|
+
const inner = streamer(request, context, metadata, signal);
|
|
1326
|
+
let finished = false;
|
|
1327
|
+
try {
|
|
1328
|
+
for (let next = await inner.next(); ; next = await inner.next()) {
|
|
1329
|
+
if (next.done === true) {
|
|
1330
|
+
finished = true;
|
|
1331
|
+
return next.value;
|
|
1332
|
+
}
|
|
1333
|
+
const call = next.value.toolCall;
|
|
1334
|
+
if (call !== undefined) await names.learn([jsonOf(call.arguments)]);
|
|
1335
|
+
yield next.value;
|
|
1336
|
+
}
|
|
1337
|
+
} finally {
|
|
1338
|
+
// the prompt stopped reading early (an abort, a suspend): the provider's stream is closed too; its value is unused
|
|
1339
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- a closed stream's return value is never read
|
|
1340
|
+
if (!finished) await inner.return(undefined as never);
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
/** Whether a call is held: it waits for earlier calls and has neither started nor been skipped. */
|
|
1346
|
+
function isHeld(call: PendingCall): call is PendingCall & { held: HeldCall } {
|
|
1347
|
+
return call.held !== undefined && call.run === undefined && call.skipped !== true;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/** The runs of the calls these held calls wait for. */
|
|
1351
|
+
function blockersOf(state: AgentState, held: ReadonlyArray<PendingCall & { held: HeldCall }>): RunId[] {
|
|
1352
|
+
const waitedFor = new Set(held.flatMap((call) => call.held.after));
|
|
1353
|
+
return state.pending.flatMap((call) => (call.run !== undefined && waitedFor.has(call.toolCallId) ? [call.run] : []));
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/** What the model reads for a held call that never started: it waited for an earlier call working on the same things. */
|
|
1357
|
+
export function heldReply(call: PendingCall & { held: HeldCall }, pending: readonly PendingCall[]): string {
|
|
1358
|
+
const earlier = [...new Set(call.held.after.flatMap((id) => pending.find((other) => other.toolCallId === id)?.fn ?? []))];
|
|
1359
|
+
return `Not run: it works on the same things as an earlier call (${earlier.join(', ')}), so it waited for that to finish, and it had not when `
|
|
1360
|
+
+ 'this reply was written. Call it again once that call is done, if it is still needed.';
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
/** What follows a refused call's key (`toolCallKey`) on its run, with the refusal's number in the job. */
|
|
1364
|
+
export const REFUSED_KEY = ':refused:';
|
|
1365
|
+
|
|
1366
|
+
/** The key of a tool call's run within its agent run. */
|
|
1367
|
+
export function toolCallKey(iteration: number, toolCallId: string): string {
|
|
1368
|
+
return `${iteration}:${toolCallId}`;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
function sleep(ms: number): Promise<void> {
|
|
1373
|
+
return new Promise((resolve) => setTimeout(resolve, ms).unref());
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
/** The `<shown>` reference for a done `hub/resource_send` run, read from its args (none when they don't name a resource). */
|
|
1377
|
+
function shownOf(args: Json): LlmMessage[] {
|
|
1378
|
+
if (typeof args !== 'object' || args === null || Array.isArray(args)) return [];
|
|
1379
|
+
const { uri, section } = args;
|
|
1380
|
+
return typeof uri === 'string' ? [shownMessage(uri, typeof section === 'string' ? section : undefined)] : [];
|
|
1381
|
+
}
|