patchwork-os 0.2.0-beta.9.canary.92 → 1.1.0-beta.1
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/README.bridge.md +15 -16
- package/README.md +46 -458
- package/dist/activationMetrics.js +2 -3
- package/dist/activationMetrics.js.map +1 -1
- package/dist/activityLog.d.ts +1 -0
- package/dist/activityLog.js +8 -3
- package/dist/activityLog.js.map +1 -1
- package/dist/adapters/gemini.js +2 -2
- package/dist/adapters/gemini.js.map +1 -1
- package/dist/adapters/grok.js +6 -1
- package/dist/adapters/grok.js.map +1 -1
- package/dist/adapters/openai.js +4 -0
- package/dist/adapters/openai.js.map +1 -1
- package/dist/approvalHttp.d.ts +9 -0
- package/dist/approvalHttp.js +210 -171
- package/dist/approvalHttp.js.map +1 -1
- package/dist/approvalKpi.d.ts +102 -0
- package/dist/approvalKpi.js +282 -0
- package/dist/approvalKpi.js.map +1 -0
- package/dist/approvalQueue.d.ts +1 -1
- package/dist/approvalQueue.js.map +1 -1
- package/dist/automation.d.ts +45 -4
- package/dist/automation.js +123 -15
- package/dist/automation.js.map +1 -1
- package/dist/bridge.d.ts +10 -0
- package/dist/bridge.js +225 -46
- package/dist/bridge.js.map +1 -1
- package/dist/bridgeLockDiscovery.d.ts +16 -1
- package/dist/bridgeLockDiscovery.js +38 -4
- package/dist/bridgeLockDiscovery.js.map +1 -1
- package/dist/bridgeToolsRules.js +3 -18
- package/dist/bridgeToolsRules.js.map +1 -1
- package/dist/claudeAuthHttp.d.ts +25 -0
- package/dist/claudeAuthHttp.js +219 -0
- package/dist/claudeAuthHttp.js.map +1 -0
- package/dist/claudeDriver.js +4 -1
- package/dist/claudeDriver.js.map +1 -1
- package/dist/claudeOrchestrator.d.ts +15 -0
- package/dist/claudeOrchestrator.js +44 -0
- package/dist/claudeOrchestrator.js.map +1 -1
- package/dist/commands/connect.d.ts +47 -0
- package/dist/commands/connect.js +419 -0
- package/dist/commands/connect.js.map +1 -0
- package/dist/commands/install.js +3 -10
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/launchd.d.ts +7 -0
- package/dist/commands/launchd.js +20 -2
- package/dist/commands/launchd.js.map +1 -1
- package/dist/commands/patchworkInit.d.ts +7 -0
- package/dist/commands/patchworkInit.js +26 -0
- package/dist/commands/patchworkInit.js.map +1 -1
- package/dist/commands/recipe.d.ts +59 -4
- package/dist/commands/recipe.js +206 -5
- package/dist/commands/recipe.js.map +1 -1
- package/dist/commands/recipeInstall.d.ts +9 -0
- package/dist/commands/recipeInstall.js +56 -3
- package/dist/commands/recipeInstall.js.map +1 -1
- package/dist/commands/task.d.ts +25 -0
- package/dist/commands/task.js +61 -41
- package/dist/commands/task.js.map +1 -1
- package/dist/commands/tokenEfficiency.d.ts +4 -0
- package/dist/commands/tokenEfficiency.js +23 -26
- package/dist/commands/tokenEfficiency.js.map +1 -1
- package/dist/commands/tracesExport.d.ts +15 -1
- package/dist/commands/tracesExport.js +39 -5
- package/dist/commands/tracesExport.js.map +1 -1
- package/dist/config.js +16 -0
- package/dist/config.js.map +1 -1
- package/dist/connectorRoutes.js +613 -62
- package/dist/connectorRoutes.js.map +1 -1
- package/dist/connectors/asana.js +9 -3
- package/dist/connectors/asana.js.map +1 -1
- package/dist/connectors/baseConnector.d.ts +16 -0
- package/dist/connectors/baseConnector.js +2 -0
- package/dist/connectors/baseConnector.js.map +1 -1
- package/dist/connectors/caldiy.js +34 -0
- package/dist/connectors/caldiy.js.map +1 -1
- package/dist/connectors/confluence.js +9 -2
- package/dist/connectors/confluence.js.map +1 -1
- package/dist/connectors/connectorActivity.d.ts +24 -0
- package/dist/connectors/connectorActivity.js +32 -0
- package/dist/connectors/connectorActivity.js.map +1 -0
- package/dist/connectors/connectorRedirectUri.js +22 -2
- package/dist/connectors/connectorRedirectUri.js.map +1 -1
- package/dist/connectors/connectorRegistry.d.ts +0 -3
- package/dist/connectors/connectorRegistry.js +8 -8
- package/dist/connectors/connectorRegistry.js.map +1 -1
- package/dist/connectors/datadog.js +8 -1
- package/dist/connectors/datadog.js.map +1 -1
- package/dist/connectors/discord.js +4 -3
- package/dist/connectors/discord.js.map +1 -1
- package/dist/connectors/elasticsearch.js +22 -0
- package/dist/connectors/elasticsearch.js.map +1 -1
- package/dist/connectors/github.d.ts +38 -0
- package/dist/connectors/github.js +91 -5
- package/dist/connectors/github.js.map +1 -1
- package/dist/connectors/gitlab.js +19 -16
- package/dist/connectors/gitlab.js.map +1 -1
- package/dist/connectors/gmail.d.ts +5 -0
- package/dist/connectors/gmail.js +53 -11
- package/dist/connectors/gmail.js.map +1 -1
- package/dist/connectors/googleCalendar.js +5 -4
- package/dist/connectors/googleCalendar.js.map +1 -1
- package/dist/connectors/googleDocs.js +7 -6
- package/dist/connectors/googleDocs.js.map +1 -1
- package/dist/connectors/googleDrive.js +15 -8
- package/dist/connectors/googleDrive.js.map +1 -1
- package/dist/connectors/grafana.js +39 -3
- package/dist/connectors/grafana.js.map +1 -1
- package/dist/connectors/jira.d.ts +1 -1
- package/dist/connectors/jira.js +19 -4
- package/dist/connectors/jira.js.map +1 -1
- package/dist/connectors/linear.js +2 -2
- package/dist/connectors/linear.js.map +1 -1
- package/dist/connectors/mcpClient.d.ts +29 -1
- package/dist/connectors/mcpClient.js +114 -44
- package/dist/connectors/mcpClient.js.map +1 -1
- package/dist/connectors/mcpOAuth.d.ts +1 -0
- package/dist/connectors/mcpOAuth.js +49 -4
- package/dist/connectors/mcpOAuth.js.map +1 -1
- package/dist/connectors/monday.js +5 -4
- package/dist/connectors/monday.js.map +1 -1
- package/dist/connectors/mongodb.js +32 -5
- package/dist/connectors/mongodb.js.map +1 -1
- package/dist/connectors/notion.d.ts +1 -1
- package/dist/connectors/notion.js +22 -6
- package/dist/connectors/notion.js.map +1 -1
- package/dist/connectors/oauthError.d.ts +17 -0
- package/dist/connectors/oauthError.js +50 -0
- package/dist/connectors/oauthError.js.map +1 -0
- package/dist/connectors/postgres.d.ts +7 -0
- package/dist/connectors/postgres.js +32 -2
- package/dist/connectors/postgres.js.map +1 -1
- package/dist/connectors/posthog.js +26 -0
- package/dist/connectors/posthog.js.map +1 -1
- package/dist/connectors/redis.d.ts +1 -0
- package/dist/connectors/redis.js +47 -20
- package/dist/connectors/redis.js.map +1 -1
- package/dist/connectors/salesforce.js +66 -5
- package/dist/connectors/salesforce.js.map +1 -1
- package/dist/connectors/sentry.js +2 -2
- package/dist/connectors/sentry.js.map +1 -1
- package/dist/connectors/slack.js +37 -14
- package/dist/connectors/slack.js.map +1 -1
- package/dist/connectors/snowflake.js +24 -0
- package/dist/connectors/snowflake.js.map +1 -1
- package/dist/connectors/stripe.js +9 -2
- package/dist/connectors/stripe.js.map +1 -1
- package/dist/connectors/supabase.js +34 -0
- package/dist/connectors/supabase.js.map +1 -1
- package/dist/connectors/tokenStorage.d.ts +20 -0
- package/dist/connectors/tokenStorage.js +196 -64
- package/dist/connectors/tokenStorage.js.map +1 -1
- package/dist/connectors/woocommerce.js +34 -0
- package/dist/connectors/woocommerce.js.map +1 -1
- package/dist/copilot/parseIntent.d.ts +58 -0
- package/dist/copilot/parseIntent.js +149 -0
- package/dist/copilot/parseIntent.js.map +1 -0
- package/dist/decisionReplay.d.ts +8 -6
- package/dist/decisionReplay.js +35 -11
- package/dist/decisionReplay.js.map +1 -1
- package/dist/decisionTraceLog.d.ts +9 -0
- package/dist/decisionTraceLog.js +6 -0
- package/dist/decisionTraceLog.js.map +1 -1
- package/dist/drivers/claude/api.js +49 -7
- package/dist/drivers/claude/api.js.map +1 -1
- package/dist/drivers/claude/envSanitizer.d.ts +9 -1
- package/dist/drivers/claude/envSanitizer.js +41 -3
- package/dist/drivers/claude/envSanitizer.js.map +1 -1
- package/dist/drivers/claude/streamParser.d.ts +13 -0
- package/dist/drivers/claude/streamParser.js.map +1 -1
- package/dist/drivers/claude/subprocess.js +131 -16
- package/dist/drivers/claude/subprocess.js.map +1 -1
- package/dist/drivers/claude/subprocessSettings.d.ts +1 -1
- package/dist/drivers/claude/subprocessSettings.js +18 -4
- package/dist/drivers/claude/subprocessSettings.js.map +1 -1
- package/dist/drivers/gemini/index.d.ts +13 -0
- package/dist/drivers/gemini/index.js +211 -67
- package/dist/drivers/gemini/index.js.map +1 -1
- package/dist/drivers/local/index.d.ts +2 -17
- package/dist/drivers/local/index.js +5 -92
- package/dist/drivers/local/index.js.map +1 -1
- package/dist/drivers/openai/index.js +69 -9
- package/dist/drivers/openai/index.js.map +1 -1
- package/dist/drivers/outputCap.d.ts +27 -0
- package/dist/drivers/outputCap.js +50 -0
- package/dist/drivers/outputCap.js.map +1 -0
- package/dist/embeddings/cosine.d.ts +23 -0
- package/dist/embeddings/cosine.js +59 -0
- package/dist/embeddings/cosine.js.map +1 -0
- package/dist/embeddings/index.d.ts +19 -0
- package/dist/embeddings/index.js +35 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/localEmbeddings.d.ts +29 -0
- package/dist/embeddings/localEmbeddings.js +103 -0
- package/dist/embeddings/localEmbeddings.js.map +1 -0
- package/dist/embeddings/localEndpoints.d.ts +24 -0
- package/dist/embeddings/localEndpoints.js +37 -0
- package/dist/embeddings/localEndpoints.js.map +1 -0
- package/dist/embeddings/types.d.ts +32 -0
- package/dist/embeddings/types.js +12 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/featureFlags.d.ts +18 -0
- package/dist/featureFlags.js +32 -0
- package/dist/featureFlags.js.map +1 -1
- package/dist/fp/automationInterpreter.js +118 -39
- package/dist/fp/automationInterpreter.js.map +1 -1
- package/dist/fp/automationProgram.d.ts +10 -0
- package/dist/fp/automationProgram.js.map +1 -1
- package/dist/fp/automationState.d.ts +6 -0
- package/dist/fp/automationState.js +38 -0
- package/dist/fp/automationState.js.map +1 -1
- package/dist/fp/commandDescription.d.ts +6 -0
- package/dist/fp/commandDescription.js +18 -5
- package/dist/fp/commandDescription.js.map +1 -1
- package/dist/fp/interpreterContext.d.ts +16 -5
- package/dist/fp/interpreterContext.js +59 -3
- package/dist/fp/interpreterContext.js.map +1 -1
- package/dist/fp/policyParser.js +18 -8
- package/dist/fp/policyParser.js.map +1 -1
- package/dist/haltPushDispatch.d.ts +4 -0
- package/dist/haltPushDispatch.js +7 -22
- package/dist/haltPushDispatch.js.map +1 -1
- package/dist/inboxRoutes.js +2 -2
- package/dist/inboxRoutes.js.map +1 -1
- package/dist/index.js +672 -135
- package/dist/index.js.map +1 -1
- package/dist/installGuard.js +6 -0
- package/dist/installGuard.js.map +1 -1
- package/dist/localEndpointGuard.d.ts +25 -0
- package/dist/localEndpointGuard.js +101 -0
- package/dist/localEndpointGuard.js.map +1 -0
- package/dist/mcpRoutes.js +1 -1
- package/dist/mcpRoutes.js.map +1 -1
- package/dist/oauth.d.ts +13 -0
- package/dist/oauth.js +53 -9
- package/dist/oauth.js.map +1 -1
- package/dist/orchestrator/childBridgeClient.d.ts +7 -0
- package/dist/orchestrator/childBridgeClient.js +42 -1
- package/dist/orchestrator/childBridgeClient.js.map +1 -1
- package/dist/orchestrator/orchestratorBridge.d.ts +33 -0
- package/dist/orchestrator/orchestratorBridge.js +75 -9
- package/dist/orchestrator/orchestratorBridge.js.map +1 -1
- package/dist/patchworkConfig.d.ts +4 -0
- package/dist/patchworkConfig.js +33 -4
- package/dist/patchworkConfig.js.map +1 -1
- package/dist/probe.js +39 -5
- package/dist/probe.js.map +1 -1
- package/dist/recipeOrchestration.d.ts +59 -0
- package/dist/recipeOrchestration.js +314 -60
- package/dist/recipeOrchestration.js.map +1 -1
- package/dist/recipeRoutes.d.ts +93 -0
- package/dist/recipeRoutes.js +664 -27
- package/dist/recipeRoutes.js.map +1 -1
- package/dist/recipes/RecipeOrchestrator.d.ts +14 -0
- package/dist/recipes/RecipeOrchestrator.js +42 -2
- package/dist/recipes/RecipeOrchestrator.js.map +1 -1
- package/dist/recipes/agentExecutor.d.ts +51 -2
- package/dist/recipes/agentExecutor.js +86 -13
- package/dist/recipes/agentExecutor.js.map +1 -1
- package/dist/recipes/chainedRunner.d.ts +111 -3
- package/dist/recipes/chainedRunner.js +440 -45
- package/dist/recipes/chainedRunner.js.map +1 -1
- package/dist/recipes/compiler.js +42 -29
- package/dist/recipes/compiler.js.map +1 -1
- package/dist/recipes/connectorPreflight.js +31 -0
- package/dist/recipes/connectorPreflight.js.map +1 -1
- package/dist/recipes/dependencyGraph.d.ts +16 -0
- package/dist/recipes/dependencyGraph.js +37 -2
- package/dist/recipes/dependencyGraph.js.map +1 -1
- package/dist/recipes/eventTriggerPrograms.d.ts +36 -0
- package/dist/recipes/eventTriggerPrograms.js +158 -0
- package/dist/recipes/eventTriggerPrograms.js.map +1 -0
- package/dist/recipes/githubInstallSource.d.ts +9 -2
- package/dist/recipes/githubInstallSource.js +36 -6
- package/dist/recipes/githubInstallSource.js.map +1 -1
- package/dist/recipes/haltCategory.d.ts +10 -0
- package/dist/recipes/haltCategory.js +11 -1
- package/dist/recipes/haltCategory.js.map +1 -1
- package/dist/recipes/idempotencyKey.d.ts +30 -3
- package/dist/recipes/idempotencyKey.js +89 -5
- package/dist/recipes/idempotencyKey.js.map +1 -1
- package/dist/recipes/installer.js +12 -35
- package/dist/recipes/installer.js.map +1 -1
- package/dist/recipes/judgeVerdict.d.ts +11 -1
- package/dist/recipes/judgeVerdict.js +47 -7
- package/dist/recipes/judgeVerdict.js.map +1 -1
- package/dist/recipes/names.d.ts +5 -0
- package/dist/recipes/names.js +10 -5
- package/dist/recipes/names.js.map +1 -1
- package/dist/recipes/parser.js +74 -10
- package/dist/recipes/parser.js.map +1 -1
- package/dist/recipes/pricing/costRouter.d.ts +43 -0
- package/dist/recipes/pricing/costRouter.js +44 -0
- package/dist/recipes/pricing/costRouter.js.map +1 -0
- package/dist/recipes/pricing/priceTable.d.ts +76 -0
- package/dist/recipes/pricing/priceTable.js +144 -0
- package/dist/recipes/pricing/priceTable.js.map +1 -0
- package/dist/recipes/replayRun.js +5 -2
- package/dist/recipes/replayRun.js.map +1 -1
- package/dist/recipes/resolveRecipePath.js +15 -1
- package/dist/recipes/resolveRecipePath.js.map +1 -1
- package/dist/recipes/runBudget.d.ts +93 -32
- package/dist/recipes/runBudget.js +213 -49
- package/dist/recipes/runBudget.js.map +1 -1
- package/dist/recipes/runRegistry.d.ts +32 -0
- package/dist/recipes/runRegistry.js +54 -0
- package/dist/recipes/runRegistry.js.map +1 -0
- package/dist/recipes/scheduler.js +6 -2
- package/dist/recipes/scheduler.js.map +1 -1
- package/dist/recipes/schema.d.ts +59 -6
- package/dist/recipes/schemaGenerator.d.ts +9 -0
- package/dist/recipes/schemaGenerator.js +446 -77
- package/dist/recipes/schemaGenerator.js.map +1 -1
- package/dist/recipes/simulation/aggregateRunRisk.d.ts +46 -0
- package/dist/recipes/simulation/aggregateRunRisk.js +120 -0
- package/dist/recipes/simulation/aggregateRunRisk.js.map +1 -0
- package/dist/recipes/simulation/costProjector.d.ts +32 -0
- package/dist/recipes/simulation/costProjector.js +194 -0
- package/dist/recipes/simulation/costProjector.js.map +1 -0
- package/dist/recipes/simulation/sideEffects.d.ts +32 -0
- package/dist/recipes/simulation/sideEffects.js +62 -0
- package/dist/recipes/simulation/sideEffects.js.map +1 -0
- package/dist/recipes/simulation/simulate.d.ts +36 -0
- package/dist/recipes/simulation/simulate.js +264 -0
- package/dist/recipes/simulation/simulate.js.map +1 -0
- package/dist/recipes/simulation/simulateMockedRun.d.ts +52 -0
- package/dist/recipes/simulation/simulateMockedRun.js +84 -0
- package/dist/recipes/simulation/simulateMockedRun.js.map +1 -0
- package/dist/recipes/simulation/synthesizeMockedOutputs.d.ts +31 -0
- package/dist/recipes/simulation/synthesizeMockedOutputs.js +50 -0
- package/dist/recipes/simulation/synthesizeMockedOutputs.js.map +1 -0
- package/dist/recipes/simulation/types.d.ts +198 -0
- package/dist/recipes/simulation/types.js +30 -0
- package/dist/recipes/simulation/types.js.map +1 -0
- package/dist/recipes/stepObservation.d.ts +12 -0
- package/dist/recipes/stepObservation.js +21 -1
- package/dist/recipes/stepObservation.js.map +1 -1
- package/dist/recipes/toolRegistry.js +61 -24
- package/dist/recipes/toolRegistry.js.map +1 -1
- package/dist/recipes/tools/airtable.d.ts +15 -0
- package/dist/recipes/tools/airtable.js +240 -0
- package/dist/recipes/tools/airtable.js.map +1 -0
- package/dist/recipes/tools/caldiy.d.ts +13 -0
- package/dist/recipes/tools/caldiy.js +215 -0
- package/dist/recipes/tools/caldiy.js.map +1 -0
- package/dist/recipes/tools/circleci.d.ts +10 -0
- package/dist/recipes/tools/circleci.js +204 -0
- package/dist/recipes/tools/circleci.js.map +1 -0
- package/dist/recipes/tools/cloudflare.d.ts +13 -0
- package/dist/recipes/tools/cloudflare.js +211 -0
- package/dist/recipes/tools/cloudflare.js.map +1 -0
- package/dist/recipes/tools/confluence.js +11 -10
- package/dist/recipes/tools/confluence.js.map +1 -1
- package/dist/recipes/tools/datadog.js +13 -12
- package/dist/recipes/tools/datadog.js.map +1 -1
- package/dist/recipes/tools/docs.d.ts +18 -0
- package/dist/recipes/tools/docs.js +95 -0
- package/dist/recipes/tools/docs.js.map +1 -0
- package/dist/recipes/tools/elasticsearch.d.ts +11 -0
- package/dist/recipes/tools/elasticsearch.js +157 -0
- package/dist/recipes/tools/elasticsearch.js.map +1 -0
- package/dist/recipes/tools/fanOut.js +4 -4
- package/dist/recipes/tools/fanOut.js.map +1 -1
- package/dist/recipes/tools/figma.d.ts +12 -0
- package/dist/recipes/tools/figma.js +195 -0
- package/dist/recipes/tools/figma.js.map +1 -0
- package/dist/recipes/tools/file.js +43 -22
- package/dist/recipes/tools/file.js.map +1 -1
- package/dist/recipes/tools/github.js +162 -5
- package/dist/recipes/tools/github.js.map +1 -1
- package/dist/recipes/tools/gmail.js +45 -33
- package/dist/recipes/tools/gmail.js.map +1 -1
- package/dist/recipes/tools/grafana.d.ts +11 -0
- package/dist/recipes/tools/grafana.js +216 -0
- package/dist/recipes/tools/grafana.js.map +1 -0
- package/dist/recipes/tools/http.d.ts +1 -1
- package/dist/recipes/tools/http.js +10 -28
- package/dist/recipes/tools/http.js.map +1 -1
- package/dist/recipes/tools/hubspot.js +13 -12
- package/dist/recipes/tools/hubspot.js.map +1 -1
- package/dist/recipes/tools/index.d.ts +28 -0
- package/dist/recipes/tools/index.js +28 -0
- package/dist/recipes/tools/index.js.map +1 -1
- package/dist/recipes/tools/intercom.js +11 -10
- package/dist/recipes/tools/intercom.js.map +1 -1
- package/dist/recipes/tools/jira.js +13 -0
- package/dist/recipes/tools/jira.js.map +1 -1
- package/dist/recipes/tools/meetingNotes.js +2 -2
- package/dist/recipes/tools/monday.d.ts +22 -0
- package/dist/recipes/tools/monday.js +242 -0
- package/dist/recipes/tools/monday.js.map +1 -0
- package/dist/recipes/tools/mongodb.d.ts +19 -0
- package/dist/recipes/tools/mongodb.js +194 -0
- package/dist/recipes/tools/mongodb.js.map +1 -0
- package/dist/recipes/tools/notion.js +11 -10
- package/dist/recipes/tools/notion.js.map +1 -1
- package/dist/recipes/tools/obsidian.d.ts +15 -0
- package/dist/recipes/tools/obsidian.js +173 -0
- package/dist/recipes/tools/obsidian.js.map +1 -0
- package/dist/recipes/tools/outcomes.d.ts +15 -0
- package/dist/recipes/tools/outcomes.js +111 -0
- package/dist/recipes/tools/outcomes.js.map +1 -0
- package/dist/recipes/tools/paystack.d.ts +11 -0
- package/dist/recipes/tools/paystack.js +212 -0
- package/dist/recipes/tools/paystack.js.map +1 -0
- package/dist/recipes/tools/pipedrive.d.ts +16 -0
- package/dist/recipes/tools/pipedrive.js +234 -0
- package/dist/recipes/tools/pipedrive.js.map +1 -0
- package/dist/recipes/tools/postgres.d.ts +15 -0
- package/dist/recipes/tools/postgres.js +186 -0
- package/dist/recipes/tools/postgres.js.map +1 -0
- package/dist/recipes/tools/posthog.d.ts +16 -0
- package/dist/recipes/tools/posthog.js +219 -0
- package/dist/recipes/tools/posthog.js.map +1 -0
- package/dist/recipes/tools/redis.d.ts +9 -0
- package/dist/recipes/tools/redis.js +141 -0
- package/dist/recipes/tools/redis.js.map +1 -0
- package/dist/recipes/tools/resend.d.ts +8 -0
- package/dist/recipes/tools/resend.js +153 -0
- package/dist/recipes/tools/resend.js.map +1 -0
- package/dist/recipes/tools/salesforce.d.ts +16 -0
- package/dist/recipes/tools/salesforce.js +184 -0
- package/dist/recipes/tools/salesforce.js.map +1 -0
- package/dist/recipes/tools/sendgrid.d.ts +9 -0
- package/dist/recipes/tools/sendgrid.js +175 -0
- package/dist/recipes/tools/sendgrid.js.map +1 -0
- package/dist/recipes/tools/shopify.d.ts +16 -0
- package/dist/recipes/tools/shopify.js +266 -0
- package/dist/recipes/tools/shopify.js.map +1 -0
- package/dist/recipes/tools/snowflake.d.ts +16 -0
- package/dist/recipes/tools/snowflake.js +173 -0
- package/dist/recipes/tools/snowflake.js.map +1 -0
- package/dist/recipes/tools/stripe.js +13 -12
- package/dist/recipes/tools/stripe.js.map +1 -1
- package/dist/recipes/tools/supabase.d.ts +9 -0
- package/dist/recipes/tools/supabase.js +133 -0
- package/dist/recipes/tools/supabase.js.map +1 -0
- package/dist/recipes/tools/todoist.d.ts +15 -0
- package/dist/recipes/tools/todoist.js +228 -0
- package/dist/recipes/tools/todoist.js.map +1 -0
- package/dist/recipes/tools/twilio.d.ts +11 -0
- package/dist/recipes/tools/twilio.js +180 -0
- package/dist/recipes/tools/twilio.js.map +1 -0
- package/dist/recipes/tools/vercel.d.ts +9 -0
- package/dist/recipes/tools/vercel.js +146 -0
- package/dist/recipes/tools/vercel.js.map +1 -0
- package/dist/recipes/tools/webflow.d.ts +11 -0
- package/dist/recipes/tools/webflow.js +244 -0
- package/dist/recipes/tools/webflow.js.map +1 -0
- package/dist/recipes/tools/woocommerce.d.ts +18 -0
- package/dist/recipes/tools/woocommerce.js +260 -0
- package/dist/recipes/tools/woocommerce.js.map +1 -0
- package/dist/recipes/tools/wrapConnectorExecute.d.ts +25 -0
- package/dist/recipes/tools/wrapConnectorExecute.js +37 -0
- package/dist/recipes/tools/wrapConnectorExecute.js.map +1 -0
- package/dist/recipes/tools/zendesk.js +11 -10
- package/dist/recipes/tools/zendesk.js.map +1 -1
- package/dist/recipes/triggerVars.d.ts +15 -0
- package/dist/recipes/triggerVars.js +57 -0
- package/dist/recipes/triggerVars.js.map +1 -0
- package/dist/recipes/validation.d.ts +1 -1
- package/dist/recipes/validation.js +536 -12
- package/dist/recipes/validation.js.map +1 -1
- package/dist/recipes/yamlPositions.d.ts +1 -1
- package/dist/recipes/yamlPositions.js +7 -2
- package/dist/recipes/yamlPositions.js.map +1 -1
- package/dist/recipes/yamlRunner.d.ts +216 -4
- package/dist/recipes/yamlRunner.js +1030 -96
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/recipesHttp.d.ts +5 -0
- package/dist/recipesHttp.js +68 -6
- package/dist/recipesHttp.js.map +1 -1
- package/dist/resources.js +14 -1
- package/dist/resources.js.map +1 -1
- package/dist/riskSignals.d.ts +42 -0
- package/dist/riskSignals.js +197 -0
- package/dist/riskSignals.js.map +1 -0
- package/dist/riskTier.d.ts +9 -0
- package/dist/riskTier.js +48 -0
- package/dist/riskTier.js.map +1 -1
- package/dist/runLog.d.ts +53 -0
- package/dist/runLog.js +75 -16
- package/dist/runLog.js.map +1 -1
- package/dist/schemas/recipe.v1.json +360 -16
- package/dist/server.d.ts +60 -0
- package/dist/server.js +192 -31
- package/dist/server.js.map +1 -1
- package/dist/sessionCheckpoint.js +4 -1
- package/dist/sessionCheckpoint.js.map +1 -1
- package/dist/sessionDetail.d.ts +43 -0
- package/dist/sessionDetail.js +59 -0
- package/dist/sessionDetail.js.map +1 -0
- package/dist/settingsEnv.d.ts +47 -0
- package/dist/settingsEnv.js +88 -0
- package/dist/settingsEnv.js.map +1 -0
- package/dist/streamableHttp.js +44 -10
- package/dist/streamableHttp.js.map +1 -1
- package/dist/ta/backtest/abnday.d.ts +53 -0
- package/dist/ta/backtest/abnday.js +123 -0
- package/dist/ta/backtest/abnday.js.map +1 -0
- package/dist/ta/backtest/directional.d.ts +48 -0
- package/dist/ta/backtest/directional.js +103 -0
- package/dist/ta/backtest/directional.js.map +1 -0
- package/dist/ta/backtest/fundx.d.ts +67 -0
- package/dist/ta/backtest/fundx.js +264 -0
- package/dist/ta/backtest/fundx.js.map +1 -0
- package/dist/ta/backtest/fvg.d.ts +62 -0
- package/dist/ta/backtest/fvg.js +236 -0
- package/dist/ta/backtest/fvg.js.map +1 -0
- package/dist/ta/backtest/ichimoku.d.ts +41 -0
- package/dist/ta/backtest/ichimoku.js +146 -0
- package/dist/ta/backtest/ichimoku.js.map +1 -0
- package/dist/ta/backtest/ingest.d.ts +20 -0
- package/dist/ta/backtest/ingest.js +104 -0
- package/dist/ta/backtest/ingest.js.map +1 -0
- package/dist/ta/backtest/msb.d.ts +49 -0
- package/dist/ta/backtest/msb.js +162 -0
- package/dist/ta/backtest/msb.js.map +1 -0
- package/dist/ta/backtest/scoring.d.ts +33 -0
- package/dist/ta/backtest/scoring.js +82 -0
- package/dist/ta/backtest/scoring.js.map +1 -0
- package/dist/ta/backtest/summary.d.ts +20 -0
- package/dist/ta/backtest/summary.js +42 -0
- package/dist/ta/backtest/summary.js.map +1 -0
- package/dist/ta/backtest/tsmom.d.ts +72 -0
- package/dist/ta/backtest/tsmom.js +202 -0
- package/dist/ta/backtest/tsmom.js.map +1 -0
- package/dist/ta/backtest/volsq.d.ts +34 -0
- package/dist/ta/backtest/volsq.js +154 -0
- package/dist/ta/backtest/volsq.js.map +1 -0
- package/dist/ta/backtest/walkForward.d.ts +45 -0
- package/dist/ta/backtest/walkForward.js +136 -0
- package/dist/ta/backtest/walkForward.js.map +1 -0
- package/dist/ta/cycles.d.ts +15 -0
- package/dist/ta/cycles.js +31 -0
- package/dist/ta/cycles.js.map +1 -0
- package/dist/ta/desk/accrualEmitter.d.ts +59 -0
- package/dist/ta/desk/accrualEmitter.js +136 -0
- package/dist/ta/desk/accrualEmitter.js.map +1 -0
- package/dist/ta/desk/cellBacktest.d.ts +179 -0
- package/dist/ta/desk/cellBacktest.js +514 -0
- package/dist/ta/desk/cellBacktest.js.map +1 -0
- package/dist/ta/desk/cells/wpMaRejection.d.ts +49 -0
- package/dist/ta/desk/cells/wpMaRejection.js +141 -0
- package/dist/ta/desk/cells/wpMaRejection.js.map +1 -0
- package/dist/ta/desk/cells/wpVolumeClimax.d.ts +57 -0
- package/dist/ta/desk/cells/wpVolumeClimax.js +193 -0
- package/dist/ta/desk/cells/wpVolumeClimax.js.map +1 -0
- package/dist/ta/desk/collectors.d.ts +18 -0
- package/dist/ta/desk/collectors.js +450 -0
- package/dist/ta/desk/collectors.js.map +1 -0
- package/dist/ta/desk/contract.d.ts +51 -0
- package/dist/ta/desk/contract.js +261 -0
- package/dist/ta/desk/contract.js.map +1 -0
- package/dist/ta/desk/deskLedger.d.ts +36 -0
- package/dist/ta/desk/deskLedger.js +239 -0
- package/dist/ta/desk/deskLedger.js.map +1 -0
- package/dist/ta/desk/liqTape.d.ts +37 -0
- package/dist/ta/desk/liqTape.js +99 -0
- package/dist/ta/desk/liqTape.js.map +1 -0
- package/dist/ta/desk/post.d.ts +20 -0
- package/dist/ta/desk/post.js +65 -0
- package/dist/ta/desk/post.js.map +1 -0
- package/dist/ta/desk/render.d.ts +25 -0
- package/dist/ta/desk/render.js +398 -0
- package/dist/ta/desk/render.js.map +1 -0
- package/dist/ta/desk/surfaces.d.ts +216 -0
- package/dist/ta/desk/surfaces.js +472 -0
- package/dist/ta/desk/surfaces.js.map +1 -0
- package/dist/ta/desk/types.d.ts +174 -0
- package/dist/ta/desk/types.js +104 -0
- package/dist/ta/desk/types.js.map +1 -0
- package/dist/ta/index.d.ts +23 -0
- package/dist/ta/index.js +54 -0
- package/dist/ta/index.js.map +1 -0
- package/dist/ta/ledger.d.ts +44 -0
- package/dist/ta/ledger.js +95 -0
- package/dist/ta/ledger.js.map +1 -0
- package/dist/ta/levels.d.ts +21 -0
- package/dist/ta/levels.js +41 -0
- package/dist/ta/levels.js.map +1 -0
- package/dist/ta/swings.d.ts +30 -0
- package/dist/ta/swings.js +83 -0
- package/dist/ta/swings.js.map +1 -0
- package/dist/ta/types.d.ts +81 -0
- package/dist/ta/types.js +20 -0
- package/dist/ta/types.js.map +1 -0
- package/dist/telemetry.js +20 -9
- package/dist/telemetry.js.map +1 -1
- package/dist/tokenUsageTracker.d.ts +2 -1
- package/dist/tokenUsageTracker.js +38 -20
- package/dist/tokenUsageTracker.js.map +1 -1
- package/dist/tools/contextBundle.js +13 -9
- package/dist/tools/contextBundle.js.map +1 -1
- package/dist/tools/ctxGetTaskContext.js +8 -3
- package/dist/tools/ctxGetTaskContext.js.map +1 -1
- package/dist/tools/ctxQueryTraces.d.ts +18 -1
- package/dist/tools/ctxQueryTraces.js +176 -27
- package/dist/tools/ctxQueryTraces.js.map +1 -1
- package/dist/tools/enrichCommit.js +5 -2
- package/dist/tools/enrichCommit.js.map +1 -1
- package/dist/tools/getDependencyTree.js +2 -2
- package/dist/tools/getDependencyTree.js.map +1 -1
- package/dist/tools/getDiagnostics.js +3 -0
- package/dist/tools/getDiagnostics.js.map +1 -1
- package/dist/tools/getDocumentSymbols.js +5 -1
- package/dist/tools/getDocumentSymbols.js.map +1 -1
- package/dist/tools/getGitHotspots.js +12 -1
- package/dist/tools/getGitHotspots.js.map +1 -1
- package/dist/tools/getGitLog.js +5 -2
- package/dist/tools/getGitLog.js.map +1 -1
- package/dist/tools/getGitStatus.js +6 -1
- package/dist/tools/getGitStatus.js.map +1 -1
- package/dist/tools/getProjectContext.js +3 -1
- package/dist/tools/getProjectContext.js.map +1 -1
- package/dist/tools/getToolCapabilities.js +39 -4
- package/dist/tools/getToolCapabilities.js.map +1 -1
- package/dist/tools/gitWrite.js +12 -3
- package/dist/tools/gitWrite.js.map +1 -1
- package/dist/tools/github/composite.d.ts +1 -1
- package/dist/tools/github/composite.js +7 -7
- package/dist/tools/github/composite.js.map +1 -1
- package/dist/tools/github/pr.d.ts +6 -6
- package/dist/tools/github/pr.js +18 -11
- package/dist/tools/github/pr.js.map +1 -1
- package/dist/tools/httpClient.js +55 -3
- package/dist/tools/httpClient.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +19 -12
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lsp.d.ts +6 -0
- package/dist/tools/lsp.js +81 -12
- package/dist/tools/lsp.js.map +1 -1
- package/dist/tools/previewEdit.js +16 -1
- package/dist/tools/previewEdit.js.map +1 -1
- package/dist/tools/resumeClaudeTask.js +17 -0
- package/dist/tools/resumeClaudeTask.js.map +1 -1
- package/dist/tools/searchAndReplace.js +9 -5
- package/dist/tools/searchAndReplace.js.map +1 -1
- package/dist/tools/searchTools.d.ts +26 -0
- package/dist/tools/searchTools.js +42 -2
- package/dist/tools/searchTools.js.map +1 -1
- package/dist/tools/terminal.js +23 -51
- package/dist/tools/terminal.js.map +1 -1
- package/dist/tools/transaction.d.ts +9 -1
- package/dist/tools/transaction.js +59 -4
- package/dist/tools/transaction.js.map +1 -1
- package/dist/tools/utils.d.ts +16 -0
- package/dist/tools/utils.js +77 -7
- package/dist/tools/utils.js.map +1 -1
- package/dist/transport.d.ts +31 -0
- package/dist/transport.js +117 -14
- package/dist/transport.js.map +1 -1
- package/dist/wireHaltPushDispatch.js +12 -0
- package/dist/wireHaltPushDispatch.js.map +1 -1
- package/dist/workerGateDecisionLog.d.ts +141 -0
- package/dist/workerGateDecisionLog.js +361 -0
- package/dist/workerGateDecisionLog.js.map +1 -0
- package/dist/workers/actionClass.d.ts +38 -0
- package/dist/workers/actionClass.js +155 -0
- package/dist/workers/actionClass.js.map +1 -0
- package/dist/workers/backtest.d.ts +68 -0
- package/dist/workers/backtest.js +113 -0
- package/dist/workers/backtest.js.map +1 -0
- package/dist/workers/contextRisk.d.ts +35 -0
- package/dist/workers/contextRisk.js +20 -0
- package/dist/workers/contextRisk.js.map +1 -0
- package/dist/workers/contextRiskScorer.d.ts +48 -0
- package/dist/workers/contextRiskScorer.js +94 -0
- package/dist/workers/contextRiskScorer.js.map +1 -0
- package/dist/workers/graduation.d.ts +61 -0
- package/dist/workers/graduation.js +112 -0
- package/dist/workers/graduation.js.map +1 -0
- package/dist/workers/outcomeStore.d.ts +98 -0
- package/dist/workers/outcomeStore.js +146 -0
- package/dist/workers/outcomeStore.js.map +1 -0
- package/dist/workers/outcomesCli.d.ts +34 -0
- package/dist/workers/outcomesCli.js +91 -0
- package/dist/workers/outcomesCli.js.map +1 -0
- package/dist/workers/runWorkerShadow.d.ts +90 -0
- package/dist/workers/runWorkerShadow.js +323 -0
- package/dist/workers/runWorkerShadow.js.map +1 -0
- package/dist/workers/shadowGate.d.ts +30 -0
- package/dist/workers/shadowGate.js +58 -0
- package/dist/workers/shadowGate.js.map +1 -0
- package/dist/workers/shadowObserver.d.ts +165 -0
- package/dist/workers/shadowObserver.js +203 -0
- package/dist/workers/shadowObserver.js.map +1 -0
- package/dist/workers/shadowReport.d.ts +16 -0
- package/dist/workers/shadowReport.js +61 -0
- package/dist/workers/shadowReport.js.map +1 -0
- package/dist/workers/shadowRun.d.ts +38 -0
- package/dist/workers/shadowRun.js +44 -0
- package/dist/workers/shadowRun.js.map +1 -0
- package/dist/workers/trustLevel.d.ts +82 -0
- package/dist/workers/trustLevel.js +100 -0
- package/dist/workers/trustLevel.js.map +1 -0
- package/dist/workers/worker.d.ts +49 -0
- package/dist/workers/worker.js +88 -0
- package/dist/workers/worker.js.map +1 -0
- package/dist/workers/workerGate.d.ts +101 -0
- package/dist/workers/workerGate.js +210 -0
- package/dist/workers/workerGate.js.map +1 -0
- package/dist/workers/workerLevelStore.d.ts +33 -0
- package/dist/workers/workerLevelStore.js +87 -0
- package/dist/workers/workerLevelStore.js.map +1 -0
- package/dist/workers/workerLoader.d.ts +7 -0
- package/dist/workers/workerLoader.js +31 -0
- package/dist/workers/workerLoader.js.map +1 -0
- package/dist/writeFileAtomic.js +40 -13
- package/dist/writeFileAtomic.js.map +1 -1
- package/package.json +14 -6
- package/scripts/mcp-stdio-shim.cjs +247 -87
- package/templates/CLAUDE.bridge.md +1 -1
- package/templates/recipes/dependency-bump.yaml +33 -0
- package/templates/recipes/incident-to-pr.yaml +187 -0
- package/templates/recipes/outcome-ingester.yaml +53 -0
- package/templates/recipes/release-notes.yaml +30 -0
- package/templates/recipes/triage-failing-tests-autofile.yaml +152 -0
- package/templates/recipes/triage-failing-tests.yaml +38 -0
- package/templates/workers/dependency-upkeep.worker.yaml +26 -0
- package/templates/workers/release-notes.worker.yaml +17 -0
- package/templates/workers/test-guardian.worker.yaml +24 -0
- package/deploy/README.md +0 -172
- package/deploy/bootstrap-new-vps.sh +0 -364
- package/deploy/bootstrap-vps.sh +0 -192
- package/deploy/claude-ide-bridge.service.template +0 -67
- package/deploy/claude-ide-bridge@.service +0 -31
- package/deploy/deploy-dashboard.sh +0 -198
- package/deploy/deploy-landing.sh +0 -136
- package/deploy/ecosystem.config.js.example +0 -36
- package/deploy/install-vps-service.sh +0 -240
- package/deploy/macos/README.md +0 -153
- package/deploy/macos/com.patchwork.bridge.plist.template +0 -54
- package/deploy/macos/com.patchwork.tunnel.plist.template +0 -76
- package/deploy/macos/install-mac-bridge.sh +0 -244
- package/deploy/macos/uninstall-mac-bridge.sh +0 -22
- package/deploy/nginx-claude-bridge.conf.template +0 -129
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DEFAULT_PRIOR, priorFromCompetence, } from "./trustLevel.js";
|
|
2
|
+
/**
|
|
3
|
+
* A worker manifest. Deliberately NOT a fork of the recipe schema — the recipe
|
|
4
|
+
* is the worker's *body* (triggers + steps); this manifest adds identity, the
|
|
5
|
+
* action-classes it owns, a trust prior, and the policy autonomy ceiling. It
|
|
6
|
+
* references a recipe by name rather than redefining execution. (worker-ramp-v0)
|
|
7
|
+
*/
|
|
8
|
+
const WORKER_ID_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
9
|
+
export class WorkerParseError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = "WorkerParseError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function reqString(o, key) {
|
|
16
|
+
const v = o[key];
|
|
17
|
+
if (typeof v !== "string" || !v)
|
|
18
|
+
throw new WorkerParseError(`worker.${key} must be a non-empty string`);
|
|
19
|
+
return v;
|
|
20
|
+
}
|
|
21
|
+
export function parseWorker(raw) {
|
|
22
|
+
if (typeof raw !== "object" || raw === null)
|
|
23
|
+
throw new WorkerParseError("worker must be an object");
|
|
24
|
+
const r = raw;
|
|
25
|
+
const id = reqString(r, "id");
|
|
26
|
+
if (!WORKER_ID_RE.test(id))
|
|
27
|
+
throw new WorkerParseError(`worker.id must be kebab-case (got ${JSON.stringify(id)})`);
|
|
28
|
+
const name = reqString(r, "name");
|
|
29
|
+
const owns = Array.isArray(r.owns)
|
|
30
|
+
? r.owns.filter((x) => typeof x === "string")
|
|
31
|
+
: [];
|
|
32
|
+
const responsibilities = Array.isArray(r.responsibilities)
|
|
33
|
+
? r.responsibilities.filter((x) => typeof x === "string")
|
|
34
|
+
: [];
|
|
35
|
+
// autonomyCeiling: 0–4, default 4 (uncapped).
|
|
36
|
+
let autonomyCeiling = 4;
|
|
37
|
+
if (r.autonomyCeiling !== undefined) {
|
|
38
|
+
const c = r.autonomyCeiling;
|
|
39
|
+
if (typeof c !== "number" || !Number.isInteger(c) || c < 0 || c > 4)
|
|
40
|
+
throw new WorkerParseError("worker.autonomyCeiling must be an integer 0–4");
|
|
41
|
+
autonomyCeiling = c;
|
|
42
|
+
}
|
|
43
|
+
let competence;
|
|
44
|
+
if (r.competence !== undefined) {
|
|
45
|
+
const c = r.competence;
|
|
46
|
+
if (typeof c !== "object" ||
|
|
47
|
+
c === null ||
|
|
48
|
+
typeof c.mean !== "number" ||
|
|
49
|
+
!Number.isFinite(c.mean) ||
|
|
50
|
+
typeof c.strength !== "number" ||
|
|
51
|
+
!Number.isFinite(c.strength))
|
|
52
|
+
throw new WorkerParseError("worker.competence must be { mean: number, strength: number } (finite values)");
|
|
53
|
+
if (c.mean < 0 || c.mean > 1)
|
|
54
|
+
throw new WorkerParseError("worker.competence.mean must be in [0,1]");
|
|
55
|
+
competence = { mean: c.mean, strength: c.strength };
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
id,
|
|
59
|
+
name,
|
|
60
|
+
responsibilities,
|
|
61
|
+
recipe: typeof r.recipe === "string" ? r.recipe : undefined,
|
|
62
|
+
owns,
|
|
63
|
+
autonomyCeiling,
|
|
64
|
+
competence,
|
|
65
|
+
sector: typeof r.sector === "string" ? r.sector : undefined,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The per-class trust prior for a worker (its shipped competence, or uniform). */
|
|
69
|
+
export function priorFor(worker) {
|
|
70
|
+
return worker.competence
|
|
71
|
+
? priorFromCompetence(worker.competence.mean, worker.competence.strength)
|
|
72
|
+
: DEFAULT_PRIOR;
|
|
73
|
+
}
|
|
74
|
+
/** Whether a worker is responsible for a given action-class. A pattern matches
|
|
75
|
+
* the class domain, an exact key, or a key prefix. Empty `owns` ⇒ owns nothing. */
|
|
76
|
+
export function ownsAction(worker, ac) {
|
|
77
|
+
return worker.owns.some((p) => p === ac.domain || p === ac.key || ac.key.startsWith(`${p}:`));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Ownership check against a raw class key (`domain:reversibility:blastTier`),
|
|
81
|
+
* for callers that have a board row's `classKey` but not a full ActionClass
|
|
82
|
+
* (e.g. the dial). Mirrors `ownsAction`: the domain is the key's first segment.
|
|
83
|
+
*/
|
|
84
|
+
export function ownsClassKey(worker, classKey) {
|
|
85
|
+
const domain = classKey.split(":")[0];
|
|
86
|
+
return worker.owns.some((p) => p === domain || p === classKey || classKey.startsWith(`${p}:`));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/workers/worker.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEb,mBAAmB,GAEpB,MAAM,iBAAiB,CAAC;AAEzB;;;;;GAKG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@@
|
|
|
1
|
+
import { type ActionClass } from "./actionClass.js";
|
|
2
|
+
import { type ContextRisk } from "./contextRisk.js";
|
|
3
|
+
import type { TrustLevel } from "./trustLevel.js";
|
|
4
|
+
import { type WorkerManifest } from "./worker.js";
|
|
5
|
+
import type { WorkerLevelStore } from "./workerLevelStore.js";
|
|
6
|
+
/**
|
|
7
|
+
* The LIVE worker-autonomy decision (worker-ramp-v0, phase 2). Unlike
|
|
8
|
+
* `shadowGate.recommend` — which reports queue/bypass purely for the dial — this
|
|
9
|
+
* is what the approval gate ACTS on when the `worker.autonomy` flag is enabled.
|
|
10
|
+
*
|
|
11
|
+
* The rule is reversibility-scoped, deliberately. Pure "gate everything the
|
|
12
|
+
* worker hasn't earned L4 on" is correct-but-unusable: a brand-new worker would
|
|
13
|
+
* halt on EVERY action for the weeks it takes to accumulate evidence (the
|
|
14
|
+
* evidence-latency reality). Reversibility is the ramp's primary axis, so it is
|
|
15
|
+
* the gate's too:
|
|
16
|
+
*
|
|
17
|
+
* - REVERSIBLE actions flow un-gated regardless of earned level. They are
|
|
18
|
+
* undoable (transactions + WriteEffectLedger, git reset/reflog, re-runnable
|
|
19
|
+
* CI) so the cost of being wrong is bounded — undo it. Blast tier still
|
|
20
|
+
* drives the FAILURE WEIGHT, so a big reversible mistake demotes the worker
|
|
21
|
+
* hard; it just isn't pre-gated. This is the routine work (read, local
|
|
22
|
+
* commit, ledgered file write) a new worker should simply do.
|
|
23
|
+
* - COMPENSABLE / IRREVERSIBLE actions (lossy or no undo — remote push, PR,
|
|
24
|
+
* merge, outbound message, http POST, shell, delete) are gated for human
|
|
25
|
+
* approval until the worker has EARNED (ceiling-capped) L4 trust on that
|
|
26
|
+
* exact action-class. This is the "stop and ask before the dangerous thing"
|
|
27
|
+
* behaviour of a trustworthy new employee.
|
|
28
|
+
*
|
|
29
|
+
* The decision NEVER widens access on its own: when the flag is off the gate
|
|
30
|
+
* path this feeds is not engaged at all, and even on, a "gate" result only ever
|
|
31
|
+
* routes an action to the EXISTING human-approval queue (fail-closed) — it never
|
|
32
|
+
* auto-approves anything that would otherwise have been queued by tier policy.
|
|
33
|
+
*/
|
|
34
|
+
export type WorkerGateAction = "allow" | "gate";
|
|
35
|
+
export interface WorkerGateDecision {
|
|
36
|
+
action: WorkerGateAction;
|
|
37
|
+
classKey: string;
|
|
38
|
+
domain: string;
|
|
39
|
+
owned: boolean;
|
|
40
|
+
blastTier: ActionClass["blastTier"];
|
|
41
|
+
reversibility: ActionClass["reversibility"];
|
|
42
|
+
/** Trust actually earned on this class (for logging / the dial). */
|
|
43
|
+
earnedLevel: TrustLevel;
|
|
44
|
+
autonomyCeiling: TrustLevel;
|
|
45
|
+
/** What the gate operates at: min(earned, ceiling, contextCeiling), 0 if not
|
|
46
|
+
* owned. */
|
|
47
|
+
effectiveLevel: TrustLevel;
|
|
48
|
+
/** The descending ceiling imposed by live context-risk (4 = no de-rate).
|
|
49
|
+
* Present only when a contextRisk was supplied. Diagnostic / audit. */
|
|
50
|
+
contextCeiling?: TrustLevel;
|
|
51
|
+
reason: string;
|
|
52
|
+
}
|
|
53
|
+
/** Optional, descending-only signals that fold into the autonomy decision
|
|
54
|
+
* alongside earned trust (the keystone seam — see
|
|
55
|
+
* docs/worker-autonomy-policy-gate.md). All absent ⇒ byte-identical to the
|
|
56
|
+
* earned-trust-only gate. New signals may only LOWER autonomy, never raise it. */
|
|
57
|
+
export interface AutonomyDecisionOpts {
|
|
58
|
+
/** Live situational risk for THIS action (fast, day-1, no cold-start). */
|
|
59
|
+
contextRisk?: ContextRisk;
|
|
60
|
+
}
|
|
61
|
+
/** The gate-policy version stamped on every persisted decision (the threshold
|
|
62
|
+
* constants + composition rule below). A decision can't be replayed/explained
|
|
63
|
+
* without knowing which policy produced it — bump when the thresholds or the
|
|
64
|
+
* reversibility→level mapping change. */
|
|
65
|
+
export declare const GATE_POLICY_VERSION = "worker-ramp-v0";
|
|
66
|
+
/**
|
|
67
|
+
* Undoable → flows un-gated even when unearned. Only reversible actions are
|
|
68
|
+
* exempt from the trust requirement; compensable ones graduate to autonomous
|
|
69
|
+
* at L2+; irreversible ones wait for earned L4.
|
|
70
|
+
*/
|
|
71
|
+
export declare function flowsUngated(ac: ActionClass): boolean;
|
|
72
|
+
export declare function decideWorkerAction(worker: WorkerManifest, toolName: string, params: Record<string, unknown> | undefined, store: WorkerLevelStore, opts?: AutonomyDecisionOpts): WorkerGateDecision;
|
|
73
|
+
/**
|
|
74
|
+
* Tools a worker's AGENT step must be barred from calling.
|
|
75
|
+
*
|
|
76
|
+
* An `agent` step spawns a Claude subprocess whose INTERNAL tool calls bypass
|
|
77
|
+
* the per-step worker gate (only recipe *steps* pass through `decideWorkerAction`
|
|
78
|
+
* — tools the subprocess invokes itself never do). Without this, a worker could
|
|
79
|
+
* do via its agent exactly the risky action (`gitPush`, `githubMergePR`,
|
|
80
|
+
* `slackPostMessage`, `runCommand`, …) the gate would otherwise have queued for
|
|
81
|
+
* approval. We re-apply the gate as a subprocess sandbox: every tool the worker
|
|
82
|
+
* cannot currently run autonomously (`decideWorkerAction → "gate"`) is added to
|
|
83
|
+
* the subprocess's `--disallowed-tools`.
|
|
84
|
+
*
|
|
85
|
+
* Honours the live trust state AND the autonomy ceiling (both fold into
|
|
86
|
+
* `decideWorkerAction`'s `effectiveLevel = min(earned, ceiling)`): reversible
|
|
87
|
+
* tools and risky tools the worker has EARNED stay callable; everything else is
|
|
88
|
+
* blocked. The universe is the canonical tool registry (TIER_MAP keys); params
|
|
89
|
+
* are unknown at sandbox-build time, so each tool is classified conservatively
|
|
90
|
+
* with empty params.
|
|
91
|
+
*/
|
|
92
|
+
export declare function disallowedToolsForAgentStep(worker: WorkerManifest, store: WorkerLevelStore): string[];
|
|
93
|
+
/**
|
|
94
|
+
* Union a step's own `disallowedTools` with the worker-ceiling-derived block
|
|
95
|
+
* list. Returns `undefined` when both are empty so callers preserve the "field
|
|
96
|
+
* absent" shape. When there is NO worker list (the non-worker case), the step's
|
|
97
|
+
* list is returned VERBATIM — same value, same order, same duplicates — so a
|
|
98
|
+
* non-worker agent step is byte-identical to pre-flip behaviour. Only an actual
|
|
99
|
+
* merge dedups + sorts (argv order/dupes are inert for a deny SET).
|
|
100
|
+
*/
|
|
101
|
+
export declare function mergeAgentDisallowedTools(stepList?: string[], workerList?: string[]): string[] | undefined;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { classifyTool, getRiskTierMap } from "../riskTier.js";
|
|
2
|
+
import { classifyActionClass, knownActionTools, } from "./actionClass.js";
|
|
3
|
+
import { contextRiskCeiling } from "./contextRisk.js";
|
|
4
|
+
import { ownsAction } from "./worker.js";
|
|
5
|
+
/**
|
|
6
|
+
* Compensable actions (git-remote, issue) unlock autonomous execution at L2.
|
|
7
|
+
* A compensating path exists (close the PR, delete the issue) so the cost of
|
|
8
|
+
* an error is bounded — a worker at L2 has demonstrated enough reliability
|
|
9
|
+
* that occasional human cleanup is acceptable. Irreversible actions (shell,
|
|
10
|
+
* messaging, http) still require L4; they skip L2/L3 in the reachable-levels
|
|
11
|
+
* set entirely, so this threshold never fires for them.
|
|
12
|
+
*/
|
|
13
|
+
const COMPENSABLE_AUTONOMY_LEVEL = 2;
|
|
14
|
+
/** Irreversible actions (and unowned/unearned anything) require full L4. */
|
|
15
|
+
const AUTONOMOUS_LEVEL = 4;
|
|
16
|
+
/** The gate-policy version stamped on every persisted decision (the threshold
|
|
17
|
+
* constants + composition rule below). A decision can't be replayed/explained
|
|
18
|
+
* without knowing which policy produced it — bump when the thresholds or the
|
|
19
|
+
* reversibility→level mapping change. */
|
|
20
|
+
export const GATE_POLICY_VERSION = "worker-ramp-v0";
|
|
21
|
+
/** How the Claude subprocess sees bridge MCP tools under `--disallowed-tools`:
|
|
22
|
+
* `mcp__<server>__<tool>`. The server name is fixed to `patchwork` by the
|
|
23
|
+
* subprocess driver's writeMcpConfigFile, so the agent-step sandbox must block
|
|
24
|
+
* this form (not just the bare tool name) to actually deny a bridge MCP call. */
|
|
25
|
+
const BRIDGE_MCP_TOOL_PREFIX = "mcp__patchwork__";
|
|
26
|
+
/**
|
|
27
|
+
* Undoable → flows un-gated even when unearned. Only reversible actions are
|
|
28
|
+
* exempt from the trust requirement; compensable ones graduate to autonomous
|
|
29
|
+
* at L2+; irreversible ones wait for earned L4.
|
|
30
|
+
*/
|
|
31
|
+
export function flowsUngated(ac) {
|
|
32
|
+
return ac.reversibility === "reversible";
|
|
33
|
+
}
|
|
34
|
+
export function decideWorkerAction(worker, toolName, params, store, opts) {
|
|
35
|
+
const ac = classifyActionClass(toolName, params);
|
|
36
|
+
const owned = ownsAction(worker, ac);
|
|
37
|
+
const earnedLevel = (store.getState(worker.id, ac.key)?.level ??
|
|
38
|
+
0);
|
|
39
|
+
let effectiveLevel = owned ? earnedLevel : 0;
|
|
40
|
+
if (effectiveLevel > worker.autonomyCeiling)
|
|
41
|
+
effectiveLevel = worker.autonomyCeiling;
|
|
42
|
+
// Descending context-risk clamp (keystone seam). A live, situational de-rater:
|
|
43
|
+
// it can only LOWER the effective level (never-widen). Absent ⇒ no-op, so the
|
|
44
|
+
// earned-trust-only path is byte-identical. A worker with a clean situation
|
|
45
|
+
// keeps its earned autonomy; a dangerous live context (red CI, huge diff,
|
|
46
|
+
// hotspot file) throttles it toward propose-only regardless of earned level.
|
|
47
|
+
const contextCeiling = opts?.contextRisk
|
|
48
|
+
? contextRiskCeiling(opts.contextRisk.score)
|
|
49
|
+
: undefined;
|
|
50
|
+
if (contextCeiling !== undefined && effectiveLevel > contextCeiling)
|
|
51
|
+
effectiveLevel = contextCeiling;
|
|
52
|
+
const base = {
|
|
53
|
+
classKey: ac.key,
|
|
54
|
+
domain: ac.domain,
|
|
55
|
+
owned,
|
|
56
|
+
blastTier: ac.blastTier,
|
|
57
|
+
reversibility: ac.reversibility,
|
|
58
|
+
earnedLevel,
|
|
59
|
+
autonomyCeiling: worker.autonomyCeiling,
|
|
60
|
+
effectiveLevel,
|
|
61
|
+
...(contextCeiling !== undefined && { contextCeiling }),
|
|
62
|
+
};
|
|
63
|
+
// Agent (reasoning) steps are not a durable side-effecting action-class: the
|
|
64
|
+
// claude subprocess produces an output var, and any tool calls it makes are
|
|
65
|
+
// gated on their OWN class. The step id classifies as `other:irreversible`
|
|
66
|
+
// (owned by no worker), so without this it would gate forever and stall every
|
|
67
|
+
// worker on its agent step while the real file.write flowed. Let it through;
|
|
68
|
+
// the downstream tool steps still gate. The tier gate (composed as a floor by
|
|
69
|
+
// the caller) still applies its own policy to the agent step.
|
|
70
|
+
if (toolName === "agent") {
|
|
71
|
+
return {
|
|
72
|
+
...base,
|
|
73
|
+
action: "allow",
|
|
74
|
+
reason: "agent reasoning step — not a gated action-class",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Reversible: flows freely. The routine work a new worker should just do.
|
|
78
|
+
if (flowsUngated(ac)) {
|
|
79
|
+
return {
|
|
80
|
+
...base,
|
|
81
|
+
action: "allow",
|
|
82
|
+
reason: `reversible (${ac.blastTier} blast) — undoable, flows un-gated`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Compensable: autonomous at L2+. A compensating action exists, so the cost
|
|
86
|
+
// of being wrong is bounded. Workers earning L2 on vcs-remote or issue can
|
|
87
|
+
// push and open issues without per-action approval.
|
|
88
|
+
if (ac.reversibility === "compensable" &&
|
|
89
|
+
effectiveLevel >= COMPENSABLE_AUTONOMY_LEVEL) {
|
|
90
|
+
return {
|
|
91
|
+
...base,
|
|
92
|
+
action: "allow",
|
|
93
|
+
reason: `earned autonomy (L${effectiveLevel}) on compensable class — auto-allowed at L${COMPENSABLE_AUTONOMY_LEVEL}+`,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Irreversible (and compensable still below L2): autonomous only at L4.
|
|
97
|
+
if (effectiveLevel >= AUTONOMOUS_LEVEL) {
|
|
98
|
+
return {
|
|
99
|
+
...base,
|
|
100
|
+
action: "allow",
|
|
101
|
+
reason: `earned autonomy (L4) on ${ac.reversibility} class`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const threshold = ac.reversibility === "compensable"
|
|
105
|
+
? COMPENSABLE_AUTONOMY_LEVEL
|
|
106
|
+
: AUTONOMOUS_LEVEL;
|
|
107
|
+
let reason;
|
|
108
|
+
// Context-risk is the BINDING constraint when it dropped the effective level
|
|
109
|
+
// below what earned trust + ceiling alone would have allowed. Attribute it so
|
|
110
|
+
// the audit trail shows the situation throttled the action, not stale trust.
|
|
111
|
+
const earnedCapped = Math.min(owned ? earnedLevel : 0, worker.autonomyCeiling);
|
|
112
|
+
if (contextCeiling !== undefined &&
|
|
113
|
+
contextCeiling < threshold &&
|
|
114
|
+
contextCeiling < earnedCapped) {
|
|
115
|
+
const why = opts?.contextRisk?.reasons?.length
|
|
116
|
+
? ` (${opts.contextRisk.reasons.join(", ")})`
|
|
117
|
+
: "";
|
|
118
|
+
reason = `${ac.reversibility} throttled by live context-risk (ceiling L${contextCeiling} < L${threshold})${why} — gated`;
|
|
119
|
+
}
|
|
120
|
+
else if (!owned) {
|
|
121
|
+
reason = `${ac.reversibility} action outside the worker's owned domain — gated`;
|
|
122
|
+
}
|
|
123
|
+
else if (worker.autonomyCeiling < threshold) {
|
|
124
|
+
reason = `${ac.reversibility} class capped by autonomy ceiling (L${worker.autonomyCeiling} < L${threshold}) — always gated`;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
reason = `${ac.reversibility} + unearned (effective L${effectiveLevel} < L${threshold}) — gated for approval`;
|
|
128
|
+
}
|
|
129
|
+
return { ...base, action: "gate", reason };
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Tools a worker's AGENT step must be barred from calling.
|
|
133
|
+
*
|
|
134
|
+
* An `agent` step spawns a Claude subprocess whose INTERNAL tool calls bypass
|
|
135
|
+
* the per-step worker gate (only recipe *steps* pass through `decideWorkerAction`
|
|
136
|
+
* — tools the subprocess invokes itself never do). Without this, a worker could
|
|
137
|
+
* do via its agent exactly the risky action (`gitPush`, `githubMergePR`,
|
|
138
|
+
* `slackPostMessage`, `runCommand`, …) the gate would otherwise have queued for
|
|
139
|
+
* approval. We re-apply the gate as a subprocess sandbox: every tool the worker
|
|
140
|
+
* cannot currently run autonomously (`decideWorkerAction → "gate"`) is added to
|
|
141
|
+
* the subprocess's `--disallowed-tools`.
|
|
142
|
+
*
|
|
143
|
+
* Honours the live trust state AND the autonomy ceiling (both fold into
|
|
144
|
+
* `decideWorkerAction`'s `effectiveLevel = min(earned, ceiling)`): reversible
|
|
145
|
+
* tools and risky tools the worker has EARNED stay callable; everything else is
|
|
146
|
+
* blocked. The universe is the canonical tool registry (TIER_MAP keys); params
|
|
147
|
+
* are unknown at sandbox-build time, so each tool is classified conservatively
|
|
148
|
+
* with empty params.
|
|
149
|
+
*/
|
|
150
|
+
export function disallowedToolsForAgentStep(worker, store) {
|
|
151
|
+
// Universe = the canonical risk-tier map (broad MCP coverage) ∪ the worker
|
|
152
|
+
// subsystem's own tool→domain map (adds messaging/http TIER_MAP omits).
|
|
153
|
+
// Neither alone is complete; the union is the best enumerable approximation of
|
|
154
|
+
// the risky tool surface.
|
|
155
|
+
const universe = new Set([
|
|
156
|
+
...Object.keys(getRiskTierMap()),
|
|
157
|
+
...knownActionTools(),
|
|
158
|
+
]);
|
|
159
|
+
const blocked = new Set();
|
|
160
|
+
for (const toolName of universe) {
|
|
161
|
+
// The agent step itself is always allowed (reasoning, not a durable side-
|
|
162
|
+
// effect — decideWorkerAction special-cases it); never self-block.
|
|
163
|
+
if (toolName === "agent")
|
|
164
|
+
continue;
|
|
165
|
+
// Recipe-DSL ids (`github.create_issue`, `file.write`) are internal to the
|
|
166
|
+
// recipe runner — the Claude subprocess never calls them by that name, so
|
|
167
|
+
// they would be dead weight in `--disallowed-tools`. The camelCase MCP twin
|
|
168
|
+
// (githubCreateIssue) is enumerated separately and IS emitted below.
|
|
169
|
+
if (toolName.includes("."))
|
|
170
|
+
continue;
|
|
171
|
+
if (decideWorkerAction(worker, toolName, undefined, store).action !== "gate")
|
|
172
|
+
continue;
|
|
173
|
+
// Don't over-block. An UNKNOWN tool (domain "other") defaults to
|
|
174
|
+
// irreversible in the trust model — conservative for EARNING, but blanket-
|
|
175
|
+
// denying every unknown here would strip the agent of the harmless reads and
|
|
176
|
+
// navigation it needs to do its job (getDiagnostics, searchWorkspace,
|
|
177
|
+
// goToDefinition, getHover, … all classify as other:irreversible:low). Only
|
|
178
|
+
// block an "other" tool when the registry rates it high-blast (e.g. Bash);
|
|
179
|
+
// tools with a KNOWN risky domain (shell, messaging, http, vcs-push/merge,
|
|
180
|
+
// issue) are always blocked. The recipe's explicit tool STEPS still gate on
|
|
181
|
+
// their own class — this list is defense-in-depth, not the only gate.
|
|
182
|
+
const ac = classifyActionClass(toolName);
|
|
183
|
+
if (ac.domain === "other" && classifyTool(toolName) !== "high")
|
|
184
|
+
continue;
|
|
185
|
+
// Emit BOTH naming forms the subprocess might use: the bare name (native CC
|
|
186
|
+
// tools like `Bash`, and any non-namespaced match) AND the bridge MCP form
|
|
187
|
+
// `mcp__patchwork__<tool>` (how claude -p sees bridge tools under
|
|
188
|
+
// --disallowed-tools; server name fixed by writeMcpConfigFile). A form that
|
|
189
|
+
// matches nothing is harmless; missing one would leave the bypass open.
|
|
190
|
+
blocked.add(toolName);
|
|
191
|
+
blocked.add(`${BRIDGE_MCP_TOOL_PREFIX}${toolName}`);
|
|
192
|
+
}
|
|
193
|
+
return Array.from(blocked).sort();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Union a step's own `disallowedTools` with the worker-ceiling-derived block
|
|
197
|
+
* list. Returns `undefined` when both are empty so callers preserve the "field
|
|
198
|
+
* absent" shape. When there is NO worker list (the non-worker case), the step's
|
|
199
|
+
* list is returned VERBATIM — same value, same order, same duplicates — so a
|
|
200
|
+
* non-worker agent step is byte-identical to pre-flip behaviour. Only an actual
|
|
201
|
+
* merge dedups + sorts (argv order/dupes are inert for a deny SET).
|
|
202
|
+
*/
|
|
203
|
+
export function mergeAgentDisallowedTools(stepList, workerList) {
|
|
204
|
+
if (!workerList?.length)
|
|
205
|
+
return stepList?.length ? stepList : undefined;
|
|
206
|
+
if (!stepList?.length)
|
|
207
|
+
return Array.from(new Set(workerList)).sort();
|
|
208
|
+
return Array.from(new Set([...stepList, ...workerList])).sort();
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=workerGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerGate.js","sourceRoot":"","sources":["../../src/workers/workerGate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAEL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAoB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AA8D9D;;;;;;;GAOG;AACH,MAAM,0BAA0B,GAAG,CAAU,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAEpC;;;0CAG0C;AAC1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAEpD;;;kFAGkF;AAClF,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,EAAe;IAC1C,OAAO,EAAE,CAAC,aAAa,KAAK,YAAY,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,MAAsB,EACtB,QAAgB,EAChB,MAA2C,EAC3C,KAAuB,EACvB,IAA2B;IAE3B,MAAM,EAAE,GAAG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC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2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,sEAAsE;QACtE,MAAM,EAAE,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,EAAE,CAAC,MAAM,KAAK,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,MAAM;YAAE,SAAS;QACzE,4EAA4E;QAC5E,2EAA2E;QAC3E,kEAAkE;QAClE,4EAA4E;QAC5E,wEAAwE;QACxE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,GAAG,sBAAsB,GAAG,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAmB,EACnB,UAAqB;IAErB,IAAI,CAAC,UAAU,EAAE,MAAM;QAAE,OAAO,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ClassTrustState, type GraduationConfig, type GraduationEvent, type Outcome } from "./graduation.js";
|
|
2
|
+
import { type Posterior } from "./trustLevel.js";
|
|
3
|
+
export type AuditEvent = GraduationEvent & {
|
|
4
|
+
workerId: string;
|
|
5
|
+
};
|
|
6
|
+
export interface AppliedOutcome {
|
|
7
|
+
classKey: string;
|
|
8
|
+
state: ClassTrustState;
|
|
9
|
+
event?: AuditEvent;
|
|
10
|
+
}
|
|
11
|
+
export interface BoardRow {
|
|
12
|
+
classKey: string;
|
|
13
|
+
level: number;
|
|
14
|
+
observations: number;
|
|
15
|
+
mean: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class WorkerLevelStore {
|
|
18
|
+
private states;
|
|
19
|
+
private log;
|
|
20
|
+
/** Fold one outcome for a worker; derives the action-class from the tool. */
|
|
21
|
+
apply(workerId: string, outcome: Outcome, opts?: {
|
|
22
|
+
prior?: Posterior;
|
|
23
|
+
cfg?: GraduationConfig;
|
|
24
|
+
}): AppliedOutcome;
|
|
25
|
+
getState(workerId: string, classKey: string): ClassTrustState | undefined;
|
|
26
|
+
/** Dial snapshot for one worker: every action-class it has touched, sorted. */
|
|
27
|
+
board(workerId: string): BoardRow[];
|
|
28
|
+
/** The audit log (optionally filtered to one worker). */
|
|
29
|
+
events(workerId?: string): AuditEvent[];
|
|
30
|
+
/** Serialize states + events to JSONL (one record per line). */
|
|
31
|
+
toJSONL(): string;
|
|
32
|
+
static fromJSONL(text: string): WorkerLevelStore;
|
|
33
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { classifyActionClass } from "./actionClass.js";
|
|
2
|
+
import { DEFAULT_GRADUATION_CONFIG, graduate, initialState, } from "./graduation.js";
|
|
3
|
+
import { DEFAULT_PRIOR, posteriorMean } from "./trustLevel.js";
|
|
4
|
+
/**
|
|
5
|
+
* Holds the per-(worker × action-class) trust state and the promotion/demotion
|
|
6
|
+
* event log. The state map is the dial; the event log is the compliance/audit
|
|
7
|
+
* artifact ("prove this worker never acted beyond its authority"). In-memory
|
|
8
|
+
* with a JSONL round-trip; wiring it to a live append-only JSONL file with the
|
|
9
|
+
* tail-on-read concurrency pattern (ADR-0007, as the existing trace stores do)
|
|
10
|
+
* is the productionization step — kept out of v0 to stay pure + testable.
|
|
11
|
+
*/
|
|
12
|
+
function compositeKey(workerId, classKey) {
|
|
13
|
+
return `${workerId}::${classKey}`;
|
|
14
|
+
}
|
|
15
|
+
export class WorkerLevelStore {
|
|
16
|
+
states = new Map();
|
|
17
|
+
log = [];
|
|
18
|
+
/** Fold one outcome for a worker; derives the action-class from the tool. */
|
|
19
|
+
apply(workerId, outcome, opts = {}) {
|
|
20
|
+
const ac = classifyActionClass(outcome.toolName, outcome.params);
|
|
21
|
+
const k = compositeKey(workerId, ac.key);
|
|
22
|
+
const prior = opts.prior ?? DEFAULT_PRIOR;
|
|
23
|
+
const current = this.states.get(k) ?? initialState(ac.key, prior, outcome.at);
|
|
24
|
+
const { state, event } = graduate(current, outcome, opts.cfg ?? DEFAULT_GRADUATION_CONFIG);
|
|
25
|
+
this.states.set(k, state);
|
|
26
|
+
const audit = event ? { ...event, workerId } : undefined;
|
|
27
|
+
if (audit)
|
|
28
|
+
this.log.push(audit);
|
|
29
|
+
return { classKey: ac.key, state, event: audit };
|
|
30
|
+
}
|
|
31
|
+
getState(workerId, classKey) {
|
|
32
|
+
return this.states.get(compositeKey(workerId, classKey));
|
|
33
|
+
}
|
|
34
|
+
/** Dial snapshot for one worker: every action-class it has touched, sorted. */
|
|
35
|
+
board(workerId) {
|
|
36
|
+
const prefix = `${workerId}::`;
|
|
37
|
+
const rows = [];
|
|
38
|
+
for (const [k, s] of this.states) {
|
|
39
|
+
if (!k.startsWith(prefix))
|
|
40
|
+
continue;
|
|
41
|
+
rows.push({
|
|
42
|
+
classKey: s.classKey,
|
|
43
|
+
level: s.level,
|
|
44
|
+
observations: s.observations,
|
|
45
|
+
mean: posteriorMean(s.posterior),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return rows.sort((a, b) => a.classKey.localeCompare(b.classKey));
|
|
49
|
+
}
|
|
50
|
+
/** The audit log (optionally filtered to one worker). */
|
|
51
|
+
events(workerId) {
|
|
52
|
+
return workerId
|
|
53
|
+
? this.log.filter((e) => e.workerId === workerId)
|
|
54
|
+
: this.log;
|
|
55
|
+
}
|
|
56
|
+
/** Serialize states + events to JSONL (one record per line). */
|
|
57
|
+
toJSONL() {
|
|
58
|
+
const lines = [];
|
|
59
|
+
for (const [k, s] of this.states) {
|
|
60
|
+
const workerId = k.slice(0, k.indexOf("::"));
|
|
61
|
+
lines.push(JSON.stringify({ rec: "state", workerId, state: s }));
|
|
62
|
+
}
|
|
63
|
+
for (const e of this.log)
|
|
64
|
+
lines.push(JSON.stringify({ rec: "event", ...e }));
|
|
65
|
+
return lines.join("\n");
|
|
66
|
+
}
|
|
67
|
+
static fromJSONL(text) {
|
|
68
|
+
const store = new WorkerLevelStore();
|
|
69
|
+
for (const line of text.split("\n")) {
|
|
70
|
+
const t = line.trim();
|
|
71
|
+
if (!t)
|
|
72
|
+
continue;
|
|
73
|
+
const obj = JSON.parse(t);
|
|
74
|
+
if (obj.rec === "state") {
|
|
75
|
+
const workerId = obj.workerId;
|
|
76
|
+
const state = obj.state;
|
|
77
|
+
store.states.set(compositeKey(workerId, state.classKey), state);
|
|
78
|
+
}
|
|
79
|
+
else if (obj.rec === "event") {
|
|
80
|
+
const { rec: _rec, ...event } = obj;
|
|
81
|
+
store.log.push(event);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return store;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=workerLevelStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerLevelStore.js","sourceRoot":"","sources":["../../src/workers/workerLevelStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAEL,yBAAyB,EAGzB,QAAQ,EACR,YAAY,GAEb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAkB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;;;GAOG;AAEH,SAAS,YAAY,CAAC,QAAgB,EAAE,QAAgB;IACtD,OAAO,GAAG,QAAQ,KAAK,QAAQ,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
|
+
import { type WorkerManifest } from "./worker.js";
|
|
2
|
+
/**
|
|
3
|
+
* Load worker manifests from a directory of `*.worker.yaml` files. Fail-soft:
|
|
4
|
+
* a malformed worker file is skipped (logged by the caller if a logger is
|
|
5
|
+
* passed), never fatal — one bad manifest must not blind the whole dial.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadWorkersFromDir(dir: string, log?: (msg: string) => void): WorkerManifest[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import { parseWorker } from "./worker.js";
|
|
5
|
+
/**
|
|
6
|
+
* Load worker manifests from a directory of `*.worker.yaml` files. Fail-soft:
|
|
7
|
+
* a malformed worker file is skipped (logged by the caller if a logger is
|
|
8
|
+
* passed), never fatal — one bad manifest must not blind the whole dial.
|
|
9
|
+
*/
|
|
10
|
+
export function loadWorkersFromDir(dir, log) {
|
|
11
|
+
let entries;
|
|
12
|
+
try {
|
|
13
|
+
entries = readdirSync(dir);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const workers = [];
|
|
19
|
+
for (const f of entries) {
|
|
20
|
+
if (!/\.worker\.ya?ml$/i.test(f))
|
|
21
|
+
continue;
|
|
22
|
+
try {
|
|
23
|
+
workers.push(parseWorker(parseYaml(readFileSync(path.join(dir, f), "utf-8"))));
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
log?.(`[workers] skipped ${f} — ${err instanceof Error ? err.message : String(err)}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return workers.sort((a, b) => a.id.localeCompare(b.id));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=workerLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerLoader.js","sourceRoot":"","sources":["../../src/workers/workerLoader.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