agency-lang 0.1.3 → 0.3.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 +21 -0
- package/README.md +1 -1
- package/dist/lib/agents/agency-agent/agent.agency +3 -2
- package/dist/lib/agents/judge.js +75 -71
- package/dist/lib/agents/policy/agent.agency +164 -56
- package/dist/lib/agents/policy/prompts/system.md +7 -0
- package/dist/lib/agents/review/agent.agency +2 -1
- package/dist/lib/agents/review/agent.js +402 -447
- package/dist/lib/backends/agencyGenerator.d.ts +55 -2
- package/dist/lib/backends/agencyGenerator.js +317 -73
- package/dist/lib/backends/agencyGenerator.test.js +133 -76
- package/dist/lib/backends/docstringInterpolationRuntime.test.js +59 -0
- package/dist/lib/backends/typescriptBuilder/assignmentEmitter.d.ts +64 -0
- package/dist/lib/backends/typescriptBuilder/assignmentEmitter.js +104 -0
- package/dist/lib/backends/typescriptBuilder/nameClassifier.d.ts +51 -0
- package/dist/lib/backends/typescriptBuilder/nameClassifier.js +130 -0
- package/dist/lib/backends/typescriptBuilder/namedArgsResolver.d.ts +28 -0
- package/dist/lib/backends/typescriptBuilder/namedArgsResolver.js +92 -0
- package/dist/lib/backends/typescriptBuilder/namedArgsResolver.test.d.ts +1 -0
- package/dist/lib/backends/typescriptBuilder/namedArgsResolver.test.js +75 -0
- package/dist/lib/backends/typescriptBuilder/pipeChainEmitter.d.ts +94 -0
- package/dist/lib/backends/typescriptBuilder/pipeChainEmitter.js +227 -0
- package/dist/lib/backends/typescriptBuilder/pipeReceiverCodegen.test.d.ts +1 -0
- package/dist/lib/backends/typescriptBuilder/pipeReceiverCodegen.test.js +58 -0
- package/dist/lib/backends/typescriptBuilder/scopeManager.d.ts +62 -0
- package/dist/lib/backends/typescriptBuilder/scopeManager.js +131 -0
- package/dist/lib/backends/typescriptBuilder/sectionAssembler.d.ts +108 -0
- package/dist/lib/backends/typescriptBuilder/sectionAssembler.js +249 -0
- package/dist/lib/backends/typescriptBuilder/stepPathTracker.d.ts +45 -0
- package/dist/lib/backends/typescriptBuilder/stepPathTracker.js +76 -0
- package/dist/lib/backends/typescriptBuilder.d.ts +55 -104
- package/dist/lib/backends/typescriptBuilder.integration.test.js +5 -72
- package/dist/lib/backends/typescriptBuilder.js +720 -944
- package/dist/lib/backends/typescriptGenerator/jsonSchemaAnnotation.test.d.ts +1 -0
- package/dist/lib/backends/typescriptGenerator/jsonSchemaAnnotation.test.js +104 -0
- package/dist/lib/backends/typescriptGenerator/tagArgToTs.d.ts +19 -0
- package/dist/lib/backends/typescriptGenerator/tagArgToTs.js +171 -0
- package/dist/lib/backends/typescriptGenerator/tagArgToTs.test.d.ts +1 -0
- package/dist/lib/backends/typescriptGenerator/tagArgToTs.test.js +44 -0
- package/dist/lib/backends/typescriptGenerator/typeToString.js +96 -1
- package/dist/lib/backends/typescriptGenerator/typeToString.test.d.ts +1 -0
- package/dist/lib/backends/typescriptGenerator/typeToString.test.js +52 -0
- package/dist/lib/backends/typescriptGenerator/typeToZodSchema.d.ts +12 -3
- package/dist/lib/backends/typescriptGenerator/typeToZodSchema.js +105 -9
- package/dist/lib/backends/typescriptGenerator/typeToZodSchema.test.js +122 -1
- package/dist/lib/backends/typescriptGenerator/validationDescriptor.d.ts +31 -0
- package/dist/lib/backends/typescriptGenerator/validationDescriptor.js +257 -0
- package/dist/lib/backends/typescriptGenerator.integration.test.js +6 -52
- package/dist/lib/cli/commands.d.ts +6 -1
- package/dist/lib/cli/commands.js +85 -11
- package/dist/lib/cli/debug.js +2 -0
- package/dist/lib/cli/doc.js +74 -3
- package/dist/lib/cli/doc.test.js +39 -0
- package/dist/lib/cli/evaluate.js +3 -3
- package/dist/lib/cli/installLocation.d.ts +3 -0
- package/dist/lib/cli/installLocation.js +40 -0
- package/dist/lib/cli/installLocation.test.d.ts +1 -0
- package/dist/lib/cli/installLocation.test.js +32 -0
- package/dist/lib/cli/logsView.d.ts +3 -0
- package/dist/lib/cli/logsView.js +96 -0
- package/dist/lib/cli/optimize.js +23 -2
- package/dist/lib/cli/optimize.test.js +6 -1
- package/dist/lib/cli/pack.d.ts +10 -0
- package/dist/lib/cli/pack.js +205 -0
- package/dist/lib/cli/pack.test.d.ts +1 -0
- package/dist/lib/cli/pack.test.js +131 -0
- package/dist/lib/cli/policy.js +31 -7
- package/dist/lib/cli/run.spawn.test.d.ts +1 -0
- package/dist/lib/cli/run.spawn.test.js +53 -0
- package/dist/lib/cli/runBundledAgent.js +10 -4
- package/dist/lib/cli/runShim/register.mjs +5 -0
- package/dist/lib/cli/runShim/resolver.mjs +59 -0
- package/dist/lib/cli/runShim/resolver.test.d.ts +1 -0
- package/dist/lib/cli/runShim/resolver.test.js +69 -0
- package/dist/lib/cli/schedule/backends/github.js +3 -0
- package/dist/lib/cli/schedule/index.js +1 -0
- package/dist/lib/cli/serve.js +1 -0
- package/dist/lib/cli/test.js +27 -6
- package/dist/lib/cli/util.d.ts +2 -1
- package/dist/lib/cli/util.js +14 -6
- package/dist/lib/compilationUnit.d.ts +14 -7
- package/dist/lib/compilationUnit.js +49 -16
- package/dist/lib/compilationUnit.test.js +3 -35
- package/dist/lib/compiler/compile.d.ts +9 -6
- package/dist/lib/compiler/compile.js +37 -43
- package/dist/lib/compiler/compile.test.js +72 -22
- package/dist/lib/compiler/typecheck.d.ts +18 -0
- package/dist/lib/compiler/typecheck.js +79 -0
- package/dist/lib/config.d.ts +158 -14
- package/dist/lib/config.js +52 -4
- package/dist/lib/config.test.js +67 -0
- package/dist/lib/constants.d.ts +20 -0
- package/dist/lib/constants.js +20 -0
- package/dist/lib/debugger/debuggerState.js +0 -3
- package/dist/lib/debugger/driver.js +24 -18
- package/dist/lib/debugger/driver.test.js +31 -13
- package/dist/lib/debugger/testHelpers.js +1 -0
- package/dist/lib/debugger/thread.test.js +3 -3
- package/dist/lib/debugger/trace.test.js +24 -38
- package/dist/lib/debugger/uiState.js +1 -0
- package/dist/lib/formatter.js +3 -1
- package/dist/lib/formatter.test.js +8 -0
- package/dist/lib/importPaths.d.ts +40 -1
- package/dist/lib/importPaths.js +80 -12
- package/dist/lib/importPaths.test.js +70 -0
- package/dist/lib/ir/builders.d.ts +115 -15
- package/dist/lib/ir/builders.js +166 -54
- package/dist/lib/ir/prettyPrint.js +43 -5
- package/dist/lib/ir/prettyPrint.test.js +35 -1
- package/dist/lib/ir/tsIR.d.ts +25 -1
- package/dist/lib/logsViewer/clipboard.d.ts +6 -0
- package/dist/lib/logsViewer/clipboard.js +61 -0
- package/dist/lib/logsViewer/clipboard.test.d.ts +1 -0
- package/dist/lib/logsViewer/clipboard.test.js +60 -0
- package/dist/lib/logsViewer/conversation.d.ts +20 -0
- package/dist/lib/logsViewer/conversation.js +91 -0
- package/dist/lib/logsViewer/conversation.test.d.ts +1 -0
- package/dist/lib/logsViewer/conversation.test.js +59 -0
- package/dist/lib/logsViewer/follow.d.ts +9 -0
- package/dist/lib/logsViewer/follow.js +53 -0
- package/dist/lib/logsViewer/follow.test.d.ts +1 -0
- package/dist/lib/logsViewer/follow.test.js +70 -0
- package/dist/lib/logsViewer/help.d.ts +9 -0
- package/dist/lib/logsViewer/help.js +60 -0
- package/dist/lib/logsViewer/input.d.ts +15 -0
- package/dist/lib/logsViewer/input.js +187 -0
- package/dist/lib/logsViewer/input.test.d.ts +1 -0
- package/dist/lib/logsViewer/input.test.js +163 -0
- package/dist/lib/logsViewer/jsonView/build.d.ts +3 -0
- package/dist/lib/logsViewer/jsonView/build.js +70 -0
- package/dist/lib/logsViewer/jsonView/build.test.d.ts +1 -0
- package/dist/lib/logsViewer/jsonView/build.test.js +113 -0
- package/dist/lib/logsViewer/jsonView/input.d.ts +12 -0
- package/dist/lib/logsViewer/jsonView/input.js +111 -0
- package/dist/lib/logsViewer/jsonView/input.test.d.ts +1 -0
- package/dist/lib/logsViewer/jsonView/input.test.js +76 -0
- package/dist/lib/logsViewer/jsonView/render.d.ts +18 -0
- package/dist/lib/logsViewer/jsonView/render.js +221 -0
- package/dist/lib/logsViewer/jsonView/render.test.d.ts +1 -0
- package/dist/lib/logsViewer/jsonView/render.test.js +93 -0
- package/dist/lib/logsViewer/jsonView/types.d.ts +22 -0
- package/dist/lib/logsViewer/jsonView/types.js +3 -0
- package/dist/lib/logsViewer/parse.d.ts +11 -0
- package/dist/lib/logsViewer/parse.js +61 -0
- package/dist/lib/logsViewer/parse.test.d.ts +1 -0
- package/dist/lib/logsViewer/parse.test.js +67 -0
- package/dist/lib/logsViewer/render.d.ts +21 -0
- package/dist/lib/logsViewer/render.js +287 -0
- package/dist/lib/logsViewer/render.test.d.ts +1 -0
- package/dist/lib/logsViewer/render.test.js +246 -0
- package/dist/lib/logsViewer/run.d.ts +16 -0
- package/dist/lib/logsViewer/run.js +297 -0
- package/dist/lib/logsViewer/run.test.d.ts +1 -0
- package/dist/lib/logsViewer/run.test.js +158 -0
- package/dist/lib/logsViewer/search.d.ts +8 -0
- package/dist/lib/logsViewer/search.js +123 -0
- package/dist/lib/logsViewer/search.test.d.ts +1 -0
- package/dist/lib/logsViewer/search.test.js +180 -0
- package/dist/lib/logsViewer/summary.d.ts +7 -0
- package/dist/lib/logsViewer/summary.js +153 -0
- package/dist/lib/logsViewer/summary.test.d.ts +1 -0
- package/dist/lib/logsViewer/summary.test.js +155 -0
- package/dist/lib/logsViewer/thresholds.d.ts +9 -0
- package/dist/lib/logsViewer/thresholds.js +22 -0
- package/dist/lib/logsViewer/thresholds.test.d.ts +1 -0
- package/dist/lib/logsViewer/thresholds.test.js +26 -0
- package/dist/lib/logsViewer/tree.d.ts +2 -0
- package/dist/lib/logsViewer/tree.js +247 -0
- package/dist/lib/logsViewer/tree.test.d.ts +1 -0
- package/dist/lib/logsViewer/tree.test.js +277 -0
- package/dist/lib/logsViewer/types.d.ts +41 -0
- package/dist/lib/logsViewer/types.js +1 -0
- package/dist/lib/lowering/patternLowering.d.ts +18 -0
- package/dist/lib/lowering/patternLowering.js +657 -0
- package/dist/lib/lowering/patternLowering.test.d.ts +8 -0
- package/dist/lib/lowering/patternLowering.test.js +548 -0
- package/dist/lib/lsp/builtinHover.d.ts +24 -0
- package/dist/lib/lsp/builtinHover.js +124 -0
- package/dist/lib/lsp/completion.js +10 -6
- package/dist/lib/lsp/diagnostics.js +53 -0
- package/dist/lib/lsp/diagnostics.test.js +34 -0
- package/dist/lib/lsp/documentSymbol.js +0 -8
- package/dist/lib/lsp/foldingRange.js +0 -1
- package/dist/lib/lsp/hover.js +41 -0
- package/dist/lib/lsp/hover.test.js +43 -0
- package/dist/lib/lsp/semantics.js +1 -14
- package/dist/lib/lsp/server.js +1 -0
- package/dist/lib/lsp/workspaceSymbol.js +0 -1
- package/dist/lib/parser.d.ts +1 -1
- package/dist/lib/parser.js +29 -4
- package/dist/lib/parsers/function.test.js +175 -140
- package/dist/lib/parsers/objectTypeTags.test.d.ts +1 -0
- package/dist/lib/parsers/objectTypeTags.test.js +69 -0
- package/dist/lib/parsers/parsers.d.ts +58 -6
- package/dist/lib/parsers/parsers.js +440 -122
- package/dist/lib/parsers/pattern.test.d.ts +1 -0
- package/dist/lib/parsers/pattern.test.js +818 -0
- package/dist/lib/parsers/tag.test.js +141 -13
- package/dist/lib/parsers/tagIntegration.test.js +11 -8
- package/dist/lib/parsers/typeHints.test.js +330 -1
- package/dist/lib/preprocessors/importResolver.js +10 -2
- package/dist/lib/preprocessors/injectSchemaArgs.d.ts +36 -0
- package/dist/lib/preprocessors/injectSchemaArgs.js +209 -0
- package/dist/lib/preprocessors/injectSchemaArgs.test.d.ts +1 -0
- package/dist/lib/preprocessors/injectSchemaArgs.test.js +383 -0
- package/dist/lib/preprocessors/liftCallbacks.d.ts +2 -0
- package/dist/lib/preprocessors/liftCallbacks.js +242 -0
- package/dist/lib/preprocessors/liftCallbacks.test.d.ts +1 -0
- package/dist/lib/preprocessors/liftCallbacks.test.js +146 -0
- package/dist/lib/preprocessors/parallelDesugar.js +4 -5
- package/dist/lib/preprocessors/resolveReExports.js +1 -3
- package/dist/lib/preprocessors/typeAliasTags.test.d.ts +1 -0
- package/dist/lib/preprocessors/typeAliasTags.test.js +57 -0
- package/dist/lib/preprocessors/typescriptPreprocessor.core.test.js +3 -554
- package/dist/lib/preprocessors/typescriptPreprocessor.d.ts +9 -9
- package/dist/lib/preprocessors/typescriptPreprocessor.integration.test.js +6 -50
- package/dist/lib/preprocessors/typescriptPreprocessor.js +66 -222
- package/dist/lib/runtime/__tests__/node.test.js +8 -3
- package/dist/lib/runtime/__tests__/testHelpers.js +31 -0
- package/dist/lib/runtime/agency.d.ts +49 -0
- package/dist/lib/runtime/agency.js +204 -0
- package/dist/lib/runtime/agency.test.d.ts +1 -0
- package/dist/lib/runtime/agency.test.js +277 -0
- package/dist/lib/runtime/agencyFunction.d.ts +15 -3
- package/dist/lib/runtime/agencyFunction.js +37 -24
- package/dist/lib/runtime/agencyFunction.test.js +76 -12
- package/dist/lib/runtime/agencyInterrupt.d.ts +18 -0
- package/dist/lib/runtime/agencyInterrupt.js +159 -0
- package/dist/lib/runtime/agencyInterrupt.test.d.ts +1 -0
- package/dist/lib/runtime/agencyInterrupt.test.js +231 -0
- package/dist/lib/runtime/agencyLlm.checkpointInfo.test.d.ts +1 -0
- package/dist/lib/runtime/agencyLlm.checkpointInfo.test.js +63 -0
- package/dist/lib/runtime/agencyLlm.d.ts +59 -0
- package/dist/lib/runtime/agencyLlm.js +20 -0
- package/dist/lib/runtime/agencyLlm.test.d.ts +1 -0
- package/dist/lib/runtime/agencyLlm.test.js +199 -0
- package/dist/lib/runtime/asyncContext.d.ts +208 -0
- package/dist/lib/runtime/asyncContext.js +196 -0
- package/dist/lib/runtime/asyncContext.test.d.ts +1 -0
- package/dist/lib/runtime/asyncContext.test.js +221 -0
- package/dist/lib/runtime/call.d.ts +15 -2
- package/dist/lib/runtime/call.js +17 -4
- package/dist/lib/runtime/call.test.js +20 -7
- package/dist/lib/runtime/checkpoint.d.ts +11 -4
- package/dist/lib/runtime/checkpoint.js +19 -11
- package/dist/lib/runtime/checkpoint.test.js +54 -39
- package/dist/lib/runtime/debugger.d.ts +1 -2
- package/dist/lib/runtime/debugger.js +1 -1
- package/dist/lib/runtime/debugger.test.js +13 -16
- package/dist/lib/runtime/deterministicClient.d.ts +11 -2
- package/dist/lib/runtime/deterministicClient.js +31 -5
- package/dist/lib/runtime/deterministicClient.test.js +10 -2
- package/dist/lib/runtime/guard.d.ts +243 -0
- package/dist/lib/runtime/guard.js +314 -0
- package/dist/lib/runtime/guard.test.d.ts +1 -0
- package/dist/lib/runtime/guard.test.js +289 -0
- package/dist/lib/runtime/haltSignal.d.ts +21 -0
- package/dist/lib/runtime/haltSignal.js +24 -0
- package/dist/lib/runtime/hooks.d.ts +49 -4
- package/dist/lib/runtime/hooks.js +148 -35
- package/dist/lib/runtime/hooks.test.d.ts +1 -0
- package/dist/lib/runtime/hooks.test.js +143 -0
- package/dist/lib/runtime/index.d.ts +18 -1
- package/dist/lib/runtime/index.js +12 -0
- package/dist/lib/runtime/interrupts.d.ts +3 -1
- package/dist/lib/runtime/interrupts.js +209 -78
- package/dist/lib/runtime/ipc.d.ts +1 -2
- package/dist/lib/runtime/ipc.js +6 -3
- package/dist/lib/runtime/llmClient.d.ts +19 -0
- package/dist/lib/runtime/llmClient.js +9 -0
- package/dist/lib/runtime/memory/cacheEntry.d.ts +113 -0
- package/dist/lib/runtime/memory/cacheEntry.js +153 -0
- package/dist/lib/runtime/memory/cacheEntry.test.d.ts +1 -0
- package/dist/lib/runtime/memory/cacheEntry.test.js +136 -0
- package/dist/lib/runtime/memory/compaction.d.ts +21 -0
- package/dist/lib/runtime/memory/compaction.js +46 -0
- package/dist/lib/runtime/memory/compaction.test.d.ts +1 -0
- package/dist/lib/runtime/memory/compaction.test.js +87 -0
- package/dist/lib/runtime/memory/embeddings.d.ts +18 -0
- package/dist/lib/runtime/memory/embeddings.js +59 -0
- package/dist/lib/runtime/memory/embeddings.test.d.ts +1 -0
- package/dist/lib/runtime/memory/embeddings.test.js +65 -0
- package/dist/lib/runtime/memory/extraction.d.ts +43 -0
- package/dist/lib/runtime/memory/extraction.js +88 -0
- package/dist/lib/runtime/memory/extraction.test.d.ts +1 -0
- package/dist/lib/runtime/memory/extraction.test.js +85 -0
- package/dist/lib/runtime/memory/graph.d.ts +24 -0
- package/dist/lib/runtime/memory/graph.js +126 -0
- package/dist/lib/runtime/memory/graph.test.d.ts +1 -0
- package/dist/lib/runtime/memory/graph.test.js +106 -0
- package/dist/lib/runtime/memory/index.d.ts +9 -0
- package/dist/lib/runtime/memory/index.js +6 -0
- package/dist/lib/runtime/memory/manager.d.ts +217 -0
- package/dist/lib/runtime/memory/manager.js +1063 -0
- package/dist/lib/runtime/memory/manager.test.d.ts +1 -0
- package/dist/lib/runtime/memory/manager.test.js +619 -0
- package/dist/lib/runtime/memory/retrieval.d.ts +8 -0
- package/dist/lib/runtime/memory/retrieval.js +106 -0
- package/dist/lib/runtime/memory/retrieval.test.d.ts +1 -0
- package/dist/lib/runtime/memory/retrieval.test.js +118 -0
- package/dist/lib/runtime/memory/store.d.ts +21 -0
- package/dist/lib/runtime/memory/store.js +105 -0
- package/dist/lib/runtime/memory/store.test.d.ts +1 -0
- package/dist/lib/runtime/memory/store.test.js +111 -0
- package/dist/lib/runtime/memory/types.d.ts +129 -0
- package/dist/lib/runtime/memory/types.js +69 -0
- package/dist/lib/runtime/node.d.ts +5 -5
- package/dist/lib/runtime/node.js +160 -39
- package/dist/lib/runtime/policy.d.ts +19 -5
- package/dist/lib/runtime/policy.js +9 -12
- package/dist/lib/runtime/prompt.d.ts +8 -5
- package/dist/lib/runtime/prompt.js +506 -245
- package/dist/lib/runtime/promptRunner.d.ts +128 -0
- package/dist/lib/runtime/promptRunner.js +222 -0
- package/dist/lib/runtime/promptRunner.test.d.ts +1 -0
- package/dist/lib/runtime/promptRunner.test.js +398 -0
- package/dist/lib/runtime/result.js +36 -0
- package/dist/lib/runtime/resumableScope.d.ts +45 -0
- package/dist/lib/runtime/resumableScope.js +124 -0
- package/dist/lib/runtime/resumableScope.test.d.ts +1 -0
- package/dist/lib/runtime/resumableScope.test.js +239 -0
- package/dist/lib/runtime/rewind.d.ts +2 -0
- package/dist/lib/runtime/rewind.js +30 -4
- package/dist/lib/runtime/runBatch.d.ts +93 -0
- package/dist/lib/runtime/runBatch.js +443 -0
- package/dist/lib/runtime/runBatch.test.d.ts +1 -0
- package/dist/lib/runtime/runBatch.test.js +574 -0
- package/dist/lib/runtime/runner.d.ts +106 -10
- package/dist/lib/runtime/runner.js +400 -199
- package/dist/lib/runtime/runner.test.js +120 -5
- package/dist/lib/runtime/schema.d.ts +8 -0
- package/dist/lib/runtime/schema.js +11 -0
- package/dist/lib/runtime/simpleOpenAIClient.d.ts +2 -1
- package/dist/lib/runtime/simpleOpenAIClient.js +32 -0
- package/dist/lib/runtime/state/bootstrapThreadStore.d.ts +38 -0
- package/dist/lib/runtime/state/bootstrapThreadStore.js +72 -0
- package/dist/lib/runtime/state/bootstrapThreadStore.test.d.ts +1 -0
- package/dist/lib/runtime/state/bootstrapThreadStore.test.js +34 -0
- package/dist/lib/runtime/state/context.d.ts +28 -10
- package/dist/lib/runtime/state/context.js +79 -36
- package/dist/lib/runtime/state/stateStack.d.ts +93 -0
- package/dist/lib/runtime/state/stateStack.js +219 -0
- package/dist/lib/runtime/state/stateStack.test.js +386 -0
- package/dist/lib/runtime/state/threadStore.d.ts +4 -1
- package/dist/lib/runtime/state/threadStore.js +22 -1
- package/dist/lib/runtime/subprocess-bootstrap.js +8 -0
- package/dist/lib/runtime/trace/contentAddressableStore.d.ts +10 -0
- package/dist/lib/runtime/trace/contentAddressableStore.js +13 -0
- package/dist/lib/runtime/trace/contentAddressableStore.test.js +19 -0
- package/dist/lib/runtime/trace/sinks.js +13 -1
- package/dist/lib/runtime/trace/traceWriter.d.ts +41 -1
- package/dist/lib/runtime/trace/traceWriter.js +96 -11
- package/dist/lib/runtime/trace/traceWriter.test.js +145 -1
- package/dist/lib/runtime/trace/types.d.ts +22 -0
- package/dist/lib/runtime/types.d.ts +1 -9
- package/dist/lib/runtime/validateChain.d.ts +71 -0
- package/dist/lib/runtime/validateChain.js +138 -0
- package/dist/lib/runtime/validateChain.test.d.ts +1 -0
- package/dist/lib/runtime/validateChain.test.js +131 -0
- package/dist/lib/simplemachine/graph.d.ts +2 -0
- package/dist/lib/simplemachine/graph.js +29 -20
- package/dist/lib/simplemachine/types.d.ts +2 -0
- package/dist/lib/simplemachine/util.d.ts +1 -1
- package/dist/lib/statelogClient.d.ts +224 -2
- package/dist/lib/statelogClient.js +390 -10
- package/dist/lib/statelogClient.test.d.ts +1 -0
- package/dist/lib/statelogClient.test.js +697 -0
- package/dist/lib/stdlib/abortable.d.ts +58 -0
- package/dist/lib/stdlib/abortable.js +175 -0
- package/dist/lib/stdlib/agency.d.ts +44 -0
- package/dist/lib/stdlib/agency.js +219 -13
- package/dist/lib/stdlib/assertContained.d.ts +24 -0
- package/dist/lib/stdlib/assertContained.js +110 -0
- package/dist/lib/stdlib/browserUse.d.ts +7 -0
- package/dist/lib/stdlib/browserUse.js +58 -27
- package/dist/lib/stdlib/builtins.d.ts +17 -2
- package/dist/lib/stdlib/builtins.js +78 -8
- package/dist/lib/stdlib/fs.d.ts +2 -2
- package/dist/lib/stdlib/fs.js +14 -26
- package/dist/lib/stdlib/http.d.ts +32 -1
- package/dist/lib/stdlib/http.js +105 -23
- package/dist/lib/stdlib/memory.d.ts +38 -0
- package/dist/lib/stdlib/memory.js +114 -0
- package/dist/lib/stdlib/oauth.d.ts +37 -0
- package/dist/lib/stdlib/oauth.js +113 -34
- package/dist/lib/stdlib/policy.d.ts +2 -1
- package/dist/lib/stdlib/policy.js +7 -2
- package/dist/lib/stdlib/resolvePath.d.ts +11 -0
- package/dist/lib/stdlib/resolvePath.js +13 -2
- package/dist/lib/stdlib/shell.d.ts +47 -16
- package/dist/lib/stdlib/shell.js +62 -58
- package/dist/lib/stdlib/skills.d.ts +9 -0
- package/dist/lib/stdlib/skills.js +16 -0
- package/dist/lib/stdlib/speech.d.ts +18 -3
- package/dist/lib/stdlib/speech.js +102 -22
- package/dist/lib/stdlib/system.d.ts +19 -5
- package/dist/lib/stdlib/system.js +51 -12
- package/dist/lib/stdlib/thread.d.ts +45 -0
- package/dist/lib/stdlib/thread.js +120 -0
- package/dist/lib/stdlib/ui.d.ts +7 -0
- package/dist/lib/stdlib/ui.js +45 -6
- package/dist/lib/stdlib/validators.d.ts +12 -0
- package/dist/lib/stdlib/validators.js +77 -0
- package/dist/lib/symbolTable.d.ts +24 -8
- package/dist/lib/symbolTable.js +43 -25
- package/dist/lib/symbolTable.test.js +53 -0
- package/dist/lib/templates/backends/agency/template.d.ts +1 -1
- package/dist/lib/templates/backends/agency/template.js +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/blockSetup.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/blockSetup.js +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/system.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/builtinFunctions/system.js +4 -2
- package/dist/lib/templates/backends/typescriptGenerator/debugger.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/debugger.js +2 -2
- package/dist/lib/templates/backends/typescriptGenerator/forkBlockSetup.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/forkBlockSetup.js +10 -2
- package/dist/lib/templates/backends/typescriptGenerator/functionCatchFailure.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/functionCatchFailure.js +9 -1
- package/dist/lib/templates/backends/typescriptGenerator/imports.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/imports.js +16 -14
- package/dist/lib/templates/backends/typescriptGenerator/interruptAssignment.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/interruptAssignment.js +9 -9
- package/dist/lib/templates/backends/typescriptGenerator/interruptReturn.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/interruptReturn.js +9 -9
- package/dist/lib/templates/backends/typescriptGenerator/resultCheckpointSetup.d.ts +1 -1
- package/dist/lib/templates/backends/typescriptGenerator/resultCheckpointSetup.js +1 -1
- package/dist/lib/templates/cli/schedule/githubWorkflow.d.ts +2 -1
- package/dist/lib/templates/cli/schedule/githubWorkflow.js +1 -1
- package/dist/lib/templates/prompts/memory/compaction.d.ts +6 -0
- package/dist/lib/templates/prompts/memory/compaction.js +15 -0
- package/dist/lib/templates/prompts/memory/extraction.d.ts +7 -0
- package/dist/lib/templates/prompts/memory/extraction.js +20 -0
- package/dist/lib/templates/prompts/memory/forget.d.ts +7 -0
- package/dist/lib/templates/prompts/memory/forget.js +21 -0
- package/dist/lib/templates/prompts/memory/mergeSummary.d.ts +7 -0
- package/dist/lib/templates/prompts/memory/mergeSummary.js +18 -0
- package/dist/lib/templates/prompts/memory/retrieval.d.ts +7 -0
- package/dist/lib/templates/prompts/memory/retrieval.js +25 -0
- package/dist/lib/tui/builders.d.ts +3 -1
- package/dist/lib/tui/builders.js +14 -0
- package/dist/lib/tui/builders.test.d.ts +1 -0
- package/dist/lib/tui/builders.test.js +38 -0
- package/dist/lib/tui/colors.d.ts +7 -0
- package/dist/lib/tui/colors.js +11 -0
- package/dist/lib/tui/elements.d.ts +12 -4
- package/dist/lib/tui/index.d.ts +3 -0
- package/dist/lib/tui/index.js +3 -0
- package/dist/lib/tui/input/format.d.ts +3 -0
- package/dist/lib/tui/input/format.js +37 -0
- package/dist/lib/tui/input/format.test.d.ts +1 -0
- package/dist/lib/tui/input/format.test.js +26 -0
- package/dist/lib/tui/input/scripted.d.ts +5 -0
- package/dist/lib/tui/input/scripted.js +11 -0
- package/dist/lib/tui/input/terminal.d.ts +5 -0
- package/dist/lib/tui/input/terminal.js +51 -0
- package/dist/lib/tui/output/recorder.d.ts +2 -0
- package/dist/lib/tui/output/recorder.js +12 -0
- package/dist/lib/tui/render/renderer.js +16 -3
- package/dist/lib/tui/screen.d.ts +7 -0
- package/dist/lib/tui/screen.js +10 -0
- package/dist/lib/tui/scroll.d.ts +2 -0
- package/dist/lib/tui/scroll.js +26 -0
- package/dist/lib/tui/scroll.test.d.ts +1 -0
- package/dist/lib/tui/scroll.test.js +30 -0
- package/dist/lib/tui/scrollList.d.ts +28 -0
- package/dist/lib/tui/scrollList.js +29 -0
- package/dist/lib/tui/scrollList.test.d.ts +1 -0
- package/dist/lib/tui/scrollList.test.js +78 -0
- package/dist/lib/tui/styleParser.js +1 -0
- package/dist/lib/typeChecker/assignability.d.ts +46 -3
- package/dist/lib/typeChecker/assignability.js +325 -8
- package/dist/lib/typeChecker/blockBody.test.js +3 -1
- package/dist/lib/typeChecker/builtinSignatures.test.d.ts +1 -0
- package/dist/lib/typeChecker/builtinSignatures.test.js +51 -0
- package/dist/lib/typeChecker/builtins.d.ts +8 -5
- package/dist/lib/typeChecker/builtins.js +98 -31
- package/dist/lib/typeChecker/callbackBodyInterrupts.test.d.ts +1 -0
- package/dist/lib/typeChecker/callbackBodyInterrupts.test.js +168 -0
- package/dist/lib/typeChecker/checker.js +116 -50
- package/dist/lib/typeChecker/constReassignment.test.d.ts +1 -0
- package/dist/lib/typeChecker/constReassignment.test.js +88 -0
- package/dist/lib/typeChecker/docstringParamInterpolation.test.d.ts +1 -0
- package/dist/lib/typeChecker/docstringParamInterpolation.test.js +70 -0
- package/dist/lib/typeChecker/fixtureTypeCheck.integration.test.d.ts +1 -0
- package/dist/lib/typeChecker/fixtureTypeCheck.integration.test.js +72 -0
- package/dist/lib/typeChecker/genericAliasDeclaration.test.d.ts +1 -0
- package/dist/lib/typeChecker/genericAliasDeclaration.test.js +71 -0
- package/dist/lib/typeChecker/genericValidation.test.d.ts +1 -0
- package/dist/lib/typeChecker/genericValidation.test.js +212 -0
- package/dist/lib/typeChecker/index.d.ts +1 -0
- package/dist/lib/typeChecker/index.js +88 -26
- package/dist/lib/typeChecker/interruptAnalysis.d.ts +14 -0
- package/dist/lib/typeChecker/interruptAnalysis.js +74 -0
- package/dist/lib/typeChecker/jsGlobalsSig.test.d.ts +1 -0
- package/dist/lib/typeChecker/jsGlobalsSig.test.js +96 -0
- package/dist/lib/typeChecker/jsonSchemaArgValidator.d.ts +60 -0
- package/dist/lib/typeChecker/jsonSchemaArgValidator.js +266 -0
- package/dist/lib/typeChecker/jsonSchemaArgValidator.test.d.ts +1 -0
- package/dist/lib/typeChecker/jsonSchemaArgValidator.test.js +179 -0
- package/dist/lib/typeChecker/mergeTags.d.ts +28 -0
- package/dist/lib/typeChecker/mergeTags.js +182 -0
- package/dist/lib/typeChecker/mergeTags.test.d.ts +1 -0
- package/dist/lib/typeChecker/mergeTags.test.js +144 -0
- package/dist/lib/typeChecker/namedArgStructure.test.d.ts +1 -0
- package/dist/lib/typeChecker/namedArgStructure.test.js +66 -0
- package/dist/lib/typeChecker/primitiveMembers.d.ts +80 -0
- package/dist/lib/typeChecker/primitiveMembers.js +183 -0
- package/dist/lib/typeChecker/primitiveMembers.test.d.ts +1 -0
- package/dist/lib/typeChecker/primitiveMembers.test.js +56 -0
- package/dist/lib/typeChecker/primitiveMembersIntegration.test.d.ts +1 -0
- package/dist/lib/typeChecker/primitiveMembersIntegration.test.js +171 -0
- package/dist/lib/typeChecker/recordAssignability.test.d.ts +1 -0
- package/dist/lib/typeChecker/recordAssignability.test.js +72 -0
- package/dist/lib/typeChecker/recordSynth.test.d.ts +1 -0
- package/dist/lib/typeChecker/recordSynth.test.js +80 -0
- package/dist/lib/typeChecker/reservedNameDeclaration.test.d.ts +1 -0
- package/dist/lib/typeChecker/reservedNameDeclaration.test.js +72 -0
- package/dist/lib/typeChecker/resolveCall.d.ts +159 -0
- package/dist/lib/typeChecker/resolveCall.js +296 -0
- package/dist/lib/typeChecker/resolveCall.test.d.ts +1 -0
- package/dist/lib/typeChecker/resolveCall.test.js +115 -0
- package/dist/lib/typeChecker/resolveType.test.d.ts +1 -0
- package/dist/lib/typeChecker/resolveType.test.js +478 -0
- package/dist/lib/typeChecker/resolveTypeTags.test.d.ts +1 -0
- package/dist/lib/typeChecker/resolveTypeTags.test.js +154 -0
- package/dist/lib/typeChecker/resolveVariable.d.ts +67 -0
- package/dist/lib/typeChecker/resolveVariable.js +33 -0
- package/dist/lib/typeChecker/schemaType.test.d.ts +1 -0
- package/dist/lib/typeChecker/schemaType.test.js +79 -0
- package/dist/lib/typeChecker/scope.d.ts +14 -1
- package/dist/lib/typeChecker/scope.js +28 -2
- package/dist/lib/typeChecker/scope.test.js +16 -0
- package/dist/lib/typeChecker/scopes.js +174 -5
- package/dist/lib/typeChecker/shadowing.d.ts +10 -0
- package/dist/lib/typeChecker/shadowing.js +15 -0
- package/dist/lib/typeChecker/substitute.d.ts +25 -0
- package/dist/lib/typeChecker/substitute.js +33 -0
- package/dist/lib/typeChecker/substitute.test.d.ts +1 -0
- package/dist/lib/typeChecker/substitute.test.js +165 -0
- package/dist/lib/typeChecker/suppression.test.js +3 -1
- package/dist/lib/typeChecker/synthesizer.js +297 -5
- package/dist/lib/typeChecker/typeWalker.d.ts +14 -0
- package/dist/lib/typeChecker/typeWalker.js +64 -0
- package/dist/lib/typeChecker/typeWalker.test.d.ts +1 -0
- package/dist/lib/typeChecker/typeWalker.test.js +212 -0
- package/dist/lib/typeChecker/types.d.ts +9 -2
- package/dist/lib/typeChecker/undefinedFunctionDiagnostic.d.ts +15 -0
- package/dist/lib/typeChecker/undefinedFunctionDiagnostic.js +135 -0
- package/dist/lib/typeChecker/undefinedFunctionDiagnostic.test.d.ts +1 -0
- package/dist/lib/typeChecker/undefinedFunctionDiagnostic.test.js +273 -0
- package/dist/lib/typeChecker/undefinedVariableDiagnostic.d.ts +29 -0
- package/dist/lib/typeChecker/undefinedVariableDiagnostic.js +128 -0
- package/dist/lib/typeChecker/undefinedVariableDiagnostic.test.d.ts +1 -0
- package/dist/lib/typeChecker/undefinedVariableDiagnostic.test.js +107 -0
- package/dist/lib/typeChecker/utils.js +4 -2
- package/dist/lib/typeChecker/validate.d.ts +2 -2
- package/dist/lib/typeChecker/validate.js +123 -5
- package/dist/lib/typeChecker/valueParamSubstitution.d.ts +92 -0
- package/dist/lib/typeChecker/valueParamSubstitution.js +645 -0
- package/dist/lib/typeChecker/valueParamSubstitution.test.d.ts +1 -0
- package/dist/lib/typeChecker/valueParamSubstitution.test.js +214 -0
- package/dist/lib/typeChecker.test.js +38 -63
- package/dist/lib/types/dataStructures.d.ts +6 -0
- package/dist/lib/types/forLoop.d.ts +2 -1
- package/dist/lib/types/function.d.ts +2 -6
- package/dist/lib/types/graphNode.d.ts +3 -3
- package/dist/lib/types/literals.d.ts +1 -1
- package/dist/lib/types/matchBlock.d.ts +4 -2
- package/dist/lib/types/newExpression.d.ts +14 -0
- package/dist/lib/types/newExpression.js +1 -0
- package/dist/lib/types/pattern.d.ts +40 -0
- package/dist/lib/types/pattern.js +1 -0
- package/dist/lib/types/tag.d.ts +2 -1
- package/dist/lib/types/typeHints.d.ts +119 -1
- package/dist/lib/types.d.ts +7 -4
- package/dist/lib/types.js +2 -1
- package/dist/lib/utils/docStringText.d.ts +22 -0
- package/dist/lib/utils/docStringText.js +47 -0
- package/dist/lib/utils/formatType.js +4 -0
- package/dist/lib/utils/mapBodies.d.ts +20 -0
- package/dist/lib/utils/mapBodies.js +48 -0
- package/dist/lib/utils/node.js +19 -14
- package/dist/lib/utils/schemaParam.d.ts +34 -0
- package/dist/lib/utils/schemaParam.js +48 -0
- package/dist/lib/utils/schemaParam.test.d.ts +1 -0
- package/dist/lib/utils/schemaParam.test.js +69 -0
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.js +97 -0
- package/dist/lib/utils.test.d.ts +1 -0
- package/dist/lib/utils.test.js +101 -0
- package/dist/scripts/agency.js +57 -3
- package/dist/tests/fixtureDiscovery.d.ts +25 -0
- package/dist/tests/fixtureDiscovery.js +60 -0
- package/package.json +4 -4
- package/stdlib/agency.agency +217 -3
- package/stdlib/agency.js +1872 -223
- package/stdlib/agent.js +155 -147
- package/stdlib/array.js +745 -785
- package/stdlib/browser.agency +2 -2
- package/stdlib/browser.js +100 -104
- package/stdlib/calendar.js +433 -437
- package/stdlib/clipboard.js +140 -144
- package/stdlib/date.js +588 -592
- package/stdlib/email.js +297 -301
- package/stdlib/fs.agency +12 -6
- package/stdlib/fs.js +533 -509
- package/stdlib/http.agency +61 -4
- package/stdlib/http.js +459 -99
- package/stdlib/imessage.js +92 -96
- package/stdlib/index.agency +73 -40
- package/stdlib/index.js +1004 -1063
- package/stdlib/keyring.js +260 -264
- package/stdlib/math.js +175 -163
- package/stdlib/memory.agency +100 -0
- package/stdlib/memory.js +741 -0
- package/stdlib/oauth.agency +4 -1
- package/stdlib/oauth.js +278 -278
- package/stdlib/object.js +284 -308
- package/stdlib/path.js +281 -285
- package/stdlib/policy.agency +30 -6
- package/stdlib/policy.js +168 -142
- package/stdlib/schemas.agency +37 -0
- package/stdlib/schemas.js +202 -0
- package/stdlib/shell.agency +39 -22
- package/stdlib/shell.js +605 -519
- package/stdlib/skills.agency +18 -0
- package/stdlib/skills.js +276 -0
- package/stdlib/sms.js +98 -102
- package/stdlib/speech.agency +31 -9
- package/stdlib/speech.js +264 -224
- package/stdlib/strategy.js +344 -370
- package/stdlib/syntax.agency +20 -0
- package/stdlib/syntax.js +296 -0
- package/stdlib/system.agency +27 -4
- package/stdlib/system.js +520 -399
- package/stdlib/thread.agency +148 -0
- package/stdlib/thread.js +937 -0
- package/stdlib/types.agency +58 -0
- package/stdlib/types.js +180 -0
- package/stdlib/ui.agency +3 -1
- package/stdlib/ui.js +549 -559
- package/stdlib/validators.agency +150 -0
- package/stdlib/validators.js +1471 -0
- package/stdlib/weather.js +135 -131
- package/stdlib/wikipedia.js +132 -136
- package/dist/lib/agents/policy/agent.js +0 -736
- package/dist/lib/preprocessors/typescriptPreprocessor.test.js +0 -283
- package/dist/lib/runtime/classReviver.d.ts +0 -15
- package/dist/lib/runtime/classReviver.js +0 -32
- package/dist/lib/templates/backends/typescriptGenerator/classDefinition.d.ts +0 -19
- package/dist/lib/templates/backends/typescriptGenerator/classDefinition.js +0 -48
- package/dist/lib/templates/backends/typescriptGenerator/classMethod.d.ts +0 -14
- package/dist/lib/templates/backends/typescriptGenerator/classMethod.js +0 -37
- package/dist/lib/types/classDefinition.d.ts +0 -30
- package/dist/lib/types/classDefinition.js +0 -4
- package/stdlib/lib/allowBlockList.js +0 -37
- package/stdlib/lib/browserUse.js +0 -75
- package/stdlib/lib/builtins.js +0 -117
- package/stdlib/lib/calendar.js +0 -145
- package/stdlib/lib/clipboard.js +0 -41
- package/stdlib/lib/date.js +0 -196
- package/stdlib/lib/email.js +0 -145
- package/stdlib/lib/fs.js +0 -285
- package/stdlib/lib/http.js +0 -132
- package/stdlib/lib/imessage.js +0 -49
- package/stdlib/lib/keyring.js +0 -159
- package/stdlib/lib/messaging.js +0 -1
- package/stdlib/lib/oauth.js +0 -288
- package/stdlib/lib/oauthEncryption.js +0 -69
- package/stdlib/lib/path.js +0 -22
- package/stdlib/lib/policy.js +0 -1
- package/stdlib/lib/resolvePath.js +0 -43
- package/stdlib/lib/shell.js +0 -298
- package/stdlib/lib/sms.js +0 -47
- package/stdlib/lib/speech.js +0 -129
- package/stdlib/lib/syntax.js +0 -75
- package/stdlib/lib/system.js +0 -67
- package/stdlib/lib/ui.js +0 -393
- package/stdlib/lib/utils.js +0 -51
- package/stdlib/lib/weather.js +0 -94
- package/stdlib/lib/wikipedia.js +0 -47
- /package/dist/lib/{preprocessors/typescriptPreprocessor.test.d.ts → backends/docstringInterpolationRuntime.test.d.ts} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aditya Bhargava
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -32,4 +32,4 @@ Now read [the docs](https://agency-lang.com) to learn more about the language an
|
|
|
32
32
|
Weather data in the standard library (`std::weather`) is provided by [Open-Meteo](https://open-meteo.com/). Data is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). The free API is for non-commercial use only; commercial use requires a [paid subscription](https://open-meteo.com/en/pricing).
|
|
33
33
|
|
|
34
34
|
## License
|
|
35
|
-
[
|
|
35
|
+
MIT. See [LICENSE](./LICENSE).
|
|
@@ -2,6 +2,7 @@ import { addTask, listTasks, markTaskDone } from "./subagents/task.agency"
|
|
|
2
2
|
import { writeToPlan, readPlan } from "./subagents/plan.agency"
|
|
3
3
|
import { writeCode, appendCode, readCode } from "./subagents/code.agency"
|
|
4
4
|
import { syntaxHighlight } from "../../utils/agentUtils.js"
|
|
5
|
+
import { systemMessage } from "std::thread"
|
|
5
6
|
// todo allow this
|
|
6
7
|
// import { Plan } from "./subagents/plan.agency"
|
|
7
8
|
|
|
@@ -124,7 +125,7 @@ node plan(mode, existingCode, existingFilename: string | null) {
|
|
|
124
125
|
"""
|
|
125
126
|
}
|
|
126
127
|
thread {
|
|
127
|
-
|
|
128
|
+
systemMessage("${systemPrompt}\n\n${planPrompt}${modeContext}")
|
|
128
129
|
userMsg = input("What would you like to accomplish today? ")
|
|
129
130
|
nextAction: NextAction = {
|
|
130
131
|
type: "start"
|
|
@@ -176,7 +177,7 @@ node design(plan, mode, existingCode, existingFilename: string | null) {
|
|
|
176
177
|
"""
|
|
177
178
|
}
|
|
178
179
|
thread {
|
|
179
|
-
|
|
180
|
+
systemMessage(designPrompt)
|
|
180
181
|
userMsg = prompt
|
|
181
182
|
nextAction: DesignAction = {
|
|
182
183
|
type: "start"
|
package/dist/lib/agents/judge.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { print, printJSON, input, sleep, round,
|
|
1
|
+
import { print, printJSON, parseJSON, input, sleep, round, read, write, readImage, notify, range, mostCommon, keys, values, entries, emit, callback } from "agency-lang/stdlib/index.js";
|
|
2
2
|
import { fileURLToPath } from "url";
|
|
3
3
|
import __process from "process";
|
|
4
4
|
import { z } from "agency-lang/zod";
|
|
@@ -22,11 +22,12 @@ import {
|
|
|
22
22
|
respondToInterrupts as _respondToInterrupts,
|
|
23
23
|
rewindFrom as _rewindFrom,
|
|
24
24
|
RestoreSignal,
|
|
25
|
+
GuardExceededError,
|
|
25
26
|
failure,
|
|
26
|
-
readSkill as _readSkillRaw,
|
|
27
|
-
readSkillTool as __readSkillTool,
|
|
28
|
-
readSkillToolParams as __readSkillToolParams,
|
|
29
27
|
AgencyFunction as __AgencyFunction,
|
|
28
|
+
__threads,
|
|
29
|
+
getRuntimeContext,
|
|
30
|
+
agencyStore,
|
|
30
31
|
functionRefReviver as __functionRefReviver,
|
|
31
32
|
DeterministicClient as __DeterministicClient
|
|
32
33
|
} from "agency-lang/runtime";
|
|
@@ -39,7 +40,9 @@ const __globalCtx = new RuntimeContext({
|
|
|
39
40
|
host: "https://statelog.adit.io",
|
|
40
41
|
apiKey: __process.env["STATELOG_API_KEY"] || "",
|
|
41
42
|
projectId: "agency-lang",
|
|
42
|
-
debugMode: false
|
|
43
|
+
debugMode: false,
|
|
44
|
+
observability: true,
|
|
45
|
+
logFile: "statelog.log"
|
|
43
46
|
},
|
|
44
47
|
smoltalkDefaults: {
|
|
45
48
|
openAiApiKey: __process.env["OPENAI_API_KEY"] || "",
|
|
@@ -54,15 +57,13 @@ const __globalCtx = new RuntimeContext({
|
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
59
|
dirname: __dirname,
|
|
60
|
+
logLevel: "info",
|
|
57
61
|
traceConfig: {
|
|
58
62
|
program: "dist/lib/agents/judge.agency",
|
|
59
63
|
traceDir: "traces"
|
|
60
64
|
}
|
|
61
65
|
});
|
|
62
66
|
const graph = __globalCtx.graph;
|
|
63
|
-
function readSkill({ filepath }) {
|
|
64
|
-
return _readSkillRaw({ filepath, dirname: __dirname });
|
|
65
|
-
}
|
|
66
67
|
function approve(value) {
|
|
67
68
|
return { type: "approve", value };
|
|
68
69
|
}
|
|
@@ -72,13 +73,13 @@ function reject(value) {
|
|
|
72
73
|
function propagate() {
|
|
73
74
|
return { type: "propagate" };
|
|
74
75
|
}
|
|
75
|
-
const respondToInterrupts = (interrupts, responses, opts) => _respondToInterrupts({ ctx: __globalCtx, interrupts, responses, overrides: opts?.overrides, metadata: opts?.metadata });
|
|
76
|
-
const rewindFrom = (checkpoint2, overrides, opts) => _rewindFrom({ ctx: __globalCtx, checkpoint: checkpoint2, overrides, metadata: opts?.metadata });
|
|
76
|
+
const respondToInterrupts = (interrupts, responses, opts) => _respondToInterrupts({ ctx: __globalCtx, interrupts, responses, overrides: opts?.overrides, metadata: opts?.metadata, registerTopLevelCallbacks: __registerTopLevelCallbacks, moduleDir: __dirname });
|
|
77
|
+
const rewindFrom = (checkpoint2, overrides, opts) => _rewindFrom({ ctx: __globalCtx, checkpoint: checkpoint2, overrides, metadata: opts?.metadata, registerTopLevelCallbacks: __registerTopLevelCallbacks, moduleDir: __dirname });
|
|
77
78
|
const __setDebugger = (dbg) => {
|
|
78
79
|
__globalCtx.debuggerState = dbg;
|
|
79
80
|
};
|
|
80
|
-
const
|
|
81
|
-
__globalCtx.
|
|
81
|
+
const __setTraceFile = (filePath) => {
|
|
82
|
+
__globalCtx.traceConfig.traceFile = filePath;
|
|
82
83
|
};
|
|
83
84
|
const __setLLMClient = (client) => {
|
|
84
85
|
__globalCtx.setLLMClient(client);
|
|
@@ -111,11 +112,10 @@ function registerTools(tools) {
|
|
|
111
112
|
}
|
|
112
113
|
__registerTool(print);
|
|
113
114
|
__registerTool(printJSON);
|
|
115
|
+
__registerTool(parseJSON);
|
|
114
116
|
__registerTool(input);
|
|
115
117
|
__registerTool(sleep);
|
|
116
118
|
__registerTool(round);
|
|
117
|
-
__registerTool(fetch);
|
|
118
|
-
__registerTool(fetchJSON);
|
|
119
119
|
__registerTool(read);
|
|
120
120
|
__registerTool(write);
|
|
121
121
|
__registerTool(readImage);
|
|
@@ -126,51 +126,50 @@ __registerTool(keys);
|
|
|
126
126
|
__registerTool(values);
|
|
127
127
|
__registerTool(entries);
|
|
128
128
|
__registerTool(emit);
|
|
129
|
+
__registerTool(callback);
|
|
129
130
|
async function __initializeGlobals(__ctx) {
|
|
130
131
|
__ctx.globals.markInitialized("dist/lib/agents/judge.agency");
|
|
131
132
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
fn: readSkill,
|
|
136
|
-
params: __readSkillToolParams.map((p) => ({ name: p, hasDefault: false, defaultValue: void 0, variadic: false })),
|
|
137
|
-
toolDefinition: __readSkillTool
|
|
138
|
-
}, __toolRegistry);
|
|
133
|
+
async function __registerTopLevelCallbacks(__ctx) {
|
|
134
|
+
__ctx.topLevelCallbacks = [];
|
|
135
|
+
}
|
|
139
136
|
__functionRefReviver.registry = __toolRegistry;
|
|
140
137
|
const JudgeResult = z.object({ "score": z.number().describe("a score from 0 to 100 where 100 means perfect match"), "reasoning": z.string().describe("brief explanation for the score") });
|
|
141
138
|
graph.node("judge", async (__state) => {
|
|
142
139
|
const __setupData = setupNode({
|
|
143
140
|
state: __state
|
|
144
141
|
});
|
|
145
|
-
const __stateStack = __state.ctx.stateStack;
|
|
146
142
|
const __stack = __setupData.stack;
|
|
147
143
|
const __step = __setupData.step;
|
|
148
144
|
const __self = __setupData.self;
|
|
149
|
-
const
|
|
150
|
-
const __ctx = __state.ctx;
|
|
151
|
-
const statelogClient = __ctx.statelogClient;
|
|
152
|
-
const __graph = __ctx.graph;
|
|
145
|
+
const __ctx = getRuntimeContext().ctx;
|
|
153
146
|
let __forked;
|
|
154
147
|
let __functionCompleted = false;
|
|
155
|
-
|
|
156
|
-
callbacks: __ctx.callbacks,
|
|
157
|
-
name: "onNodeStart",
|
|
158
|
-
data: {
|
|
159
|
-
nodeName: "judge"
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
const runner = new Runner(__ctx, __stack, { nodeContext: true, state: __stack, moduleId: "dist/lib/agents/judge.agency", scopeName: "judge" });
|
|
148
|
+
const runner = new Runner(__ctx, __stack, { nodeContext: true, state: __stack, moduleId: "dist/lib/agents/judge.agency", scopeName: "judge", threads: __setupData.threads });
|
|
163
149
|
if (!__state.isResume) {
|
|
164
150
|
__stack.args["actualOutput"] = __state.data.actualOutput;
|
|
165
151
|
__stack.args["expectedOutput"] = __state.data.expectedOutput;
|
|
166
152
|
__stack.args["judgePrompt"] = __state.data.judgePrompt;
|
|
167
153
|
}
|
|
168
154
|
try {
|
|
169
|
-
await
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
155
|
+
await agencyStore.run({
|
|
156
|
+
...getRuntimeContext(),
|
|
157
|
+
ctx: __ctx,
|
|
158
|
+
stack: __ctx.stateStack,
|
|
159
|
+
threads: __setupData.threads
|
|
160
|
+
}, async () => {
|
|
161
|
+
await runner.hook(0, async () => {
|
|
162
|
+
await callHook({
|
|
163
|
+
name: "onNodeStart",
|
|
164
|
+
data: {
|
|
165
|
+
nodeName: "judge"
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
await runner.step(1, async (runner2) => {
|
|
170
|
+
__self.__removedTools = __self.__removedTools || [];
|
|
171
|
+
__stack.locals.result = await runPrompt({
|
|
172
|
+
prompt: `You are an evaluation judge. Score how well the actual output matches what was expected.
|
|
174
173
|
|
|
175
174
|
Judge prompt (evaluation criteria): ${__stack.args.judgePrompt}
|
|
176
175
|
|
|
@@ -179,54 +178,58 @@ Expected output: ${__stack.args.expectedOutput}
|
|
|
179
178
|
Actual output: ${__stack.args.actualOutput}
|
|
180
179
|
|
|
181
180
|
Provide a score from 0 to 100 where 100 means perfect match and 0 means completely wrong. Also provide brief reasoning.`,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
181
|
+
messages: __threads().getOrCreateActive(),
|
|
182
|
+
responseFormat: z.object({
|
|
183
|
+
response: JudgeResult
|
|
184
|
+
}),
|
|
185
|
+
clientConfig: {},
|
|
186
|
+
maxToolCallRounds: 10,
|
|
187
|
+
removedTools: __self.__removedTools,
|
|
188
|
+
checkpointInfo: runner2.getCheckpointInfo()
|
|
189
|
+
});
|
|
190
|
+
if (hasInterrupts(__stack.locals.result)) {
|
|
191
|
+
await getRuntimeContext().ctx.pendingPromises.awaitAll();
|
|
192
|
+
runner2.halt({
|
|
193
|
+
messages: __threads(),
|
|
194
|
+
data: __stack.locals.result
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
191
198
|
});
|
|
192
|
-
|
|
193
|
-
await __ctx.pendingPromises.awaitAll();
|
|
199
|
+
await runner.step(2, async (runner2) => {
|
|
194
200
|
runner2.halt({
|
|
195
|
-
messages: __threads,
|
|
201
|
+
messages: __threads(),
|
|
196
202
|
data: __stack.locals.result
|
|
197
203
|
});
|
|
198
204
|
return;
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
await runner.step(1, async (runner2) => {
|
|
202
|
-
runner2.halt({
|
|
203
|
-
messages: __threads,
|
|
204
|
-
data: __stack.locals.result
|
|
205
205
|
});
|
|
206
|
-
return;
|
|
207
206
|
});
|
|
208
207
|
if (runner.halted) return runner.haltResult;
|
|
209
|
-
await
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
await runner.hook(3, async () => {
|
|
209
|
+
await callHook({
|
|
210
|
+
name: "onNodeEnd",
|
|
211
|
+
data: {
|
|
212
|
+
nodeName: "judge",
|
|
213
|
+
data: void 0
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
216
|
});
|
|
217
217
|
return {
|
|
218
|
-
messages: __threads,
|
|
218
|
+
messages: __threads(),
|
|
219
219
|
data: void 0
|
|
220
220
|
};
|
|
221
221
|
} catch (__error) {
|
|
222
222
|
if (__error instanceof RestoreSignal) {
|
|
223
223
|
throw __error;
|
|
224
224
|
}
|
|
225
|
+
if (__error instanceof GuardExceededError) {
|
|
226
|
+
throw __error;
|
|
227
|
+
}
|
|
225
228
|
console.error(`
|
|
226
229
|
Agent crashed: ${__error.message}`);
|
|
227
230
|
console.error(__error.stack);
|
|
228
231
|
return {
|
|
229
|
-
messages: __threads,
|
|
232
|
+
messages: __threads(),
|
|
230
233
|
data: failure(__error instanceof Error ? __error.message : String(__error), { functionName: "judge" })
|
|
231
234
|
};
|
|
232
235
|
}
|
|
@@ -242,18 +245,20 @@ async function judge(actualOutput, expectedOutput, judgePrompt, { messages, call
|
|
|
242
245
|
},
|
|
243
246
|
messages,
|
|
244
247
|
callbacks,
|
|
245
|
-
initializeGlobals: __initializeGlobals
|
|
248
|
+
initializeGlobals: __initializeGlobals,
|
|
249
|
+
registerTopLevelCallbacks: __registerTopLevelCallbacks,
|
|
250
|
+
moduleDir: __dirname
|
|
246
251
|
});
|
|
247
252
|
}
|
|
248
253
|
const __judgeNodeParams = ["actualOutput", "expectedOutput", "judgePrompt"];
|
|
249
254
|
var stdin_default = graph;
|
|
250
|
-
const __sourceMap = { "dist/lib/agents/judge.agency:judge": { "
|
|
255
|
+
const __sourceMap = { "dist/lib/agents/judge.agency:judge": { "1": { "line": 6, "col": 2 }, "2": { "line": 16, "col": 2 } } };
|
|
251
256
|
export {
|
|
252
257
|
__getCheckpoints,
|
|
253
258
|
__judgeNodeParams,
|
|
254
259
|
__setDebugger,
|
|
255
260
|
__setLLMClient,
|
|
256
|
-
|
|
261
|
+
__setTraceFile,
|
|
257
262
|
__sourceMap,
|
|
258
263
|
__toolRegistry,
|
|
259
264
|
approve,
|
|
@@ -263,7 +268,6 @@ export {
|
|
|
263
268
|
isDebugger,
|
|
264
269
|
isInterrupt,
|
|
265
270
|
judge,
|
|
266
|
-
readSkill,
|
|
267
271
|
reject,
|
|
268
272
|
respondToInterrupts,
|
|
269
273
|
rewindFrom
|
|
@@ -1,77 +1,185 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { map } from "std::array"
|
|
2
|
+
import {
|
|
3
|
+
writePolicyFile,
|
|
4
|
+
Policy,
|
|
5
|
+
InterruptKind,
|
|
6
|
+
InterruptDataKey,
|
|
7
|
+
InterruptDataVal,
|
|
8
|
+
} from "std::policy"
|
|
9
|
+
import { highlight } from "std::syntax"
|
|
2
10
|
import { args } from "std::system"
|
|
11
|
+
import { systemMessage, userMessage, assistantMessage } from "std::thread"
|
|
3
12
|
|
|
4
|
-
|
|
13
|
+
callback("onToolCallStart") as data {
|
|
14
|
+
print("Calling ${data.toolName}...")
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
callback("onToolCallEnd") as data {
|
|
18
|
+
print("Finished calling ${data.toolName}.")
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
systemPrompt = read("system.md", "./prompts") with approve
|
|
22
|
+
|
|
23
|
+
type Question = {
|
|
24
|
+
type: "askQuestion";
|
|
25
|
+
question: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type Done = {
|
|
29
|
+
type: "done"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type Action = Question | Done
|
|
33
|
+
|
|
34
|
+
type PolicyAction = "approve" | "reject" | "propagate"
|
|
35
|
+
|
|
36
|
+
let currentPolicy: Policy = {}
|
|
37
|
+
|
|
38
|
+
def addToPolicy(
|
|
39
|
+
interruptKind: InterruptKind,
|
|
40
|
+
matchArgName: InterruptDataKey,
|
|
41
|
+
matchArgValue: InterruptDataVal,
|
|
42
|
+
action: PolicyAction!,
|
|
43
|
+
): Result<Policy> {
|
|
44
|
+
"""
|
|
45
|
+
Add a rule to the current policy for the given interrupt kind, matching on the specified argument and value, with the specified action.
|
|
46
|
+
Use only "approve", "reject", or "propagate" as the action. DO NOT use "allow" or "deny".
|
|
47
|
+
Returns the current policy after adding the rule.
|
|
48
|
+
"""
|
|
49
|
+
const match = {
|
|
50
|
+
[matchArgName]: matchArgValue
|
|
51
|
+
}
|
|
52
|
+
if (!currentPolicy[interruptKind]) {
|
|
53
|
+
currentPolicy[interruptKind] = []
|
|
54
|
+
}
|
|
55
|
+
currentPolicy[interruptKind].push({
|
|
56
|
+
match: match,
|
|
57
|
+
action: action
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return success(currentPolicy)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
def getPolicy(): Policy {
|
|
64
|
+
"""
|
|
65
|
+
Get the current policy object.
|
|
66
|
+
"""
|
|
67
|
+
return currentPolicy
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
def setPolicy(newPolicy: Policy): Policy {
|
|
71
|
+
"""
|
|
72
|
+
Replace the current policy with a new policy object. Returns the new policy.
|
|
73
|
+
|
|
74
|
+
@param newPolicy - The new policy object to set as the current policy.
|
|
75
|
+
"""
|
|
76
|
+
currentPolicy = newPolicy
|
|
77
|
+
return currentPolicy
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
def deleteFromPolicy(interruptKind: InterruptKind, index: number): boolean {
|
|
81
|
+
"""
|
|
82
|
+
Delete the rule at the specified index for the given interrupt kind from the current policy.
|
|
83
|
+
Returns true if the rule was successfully deleted, or false if the index was out of bounds.
|
|
84
|
+
"""
|
|
85
|
+
if (currentPolicy[interruptKind] && index < currentPolicy[interruptKind].length) {
|
|
86
|
+
currentPolicy[interruptKind].splice(index, 1)
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
return false
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
def savePolicy(path: string) {
|
|
93
|
+
"""
|
|
94
|
+
Validate and save the current policy to a JSON file.
|
|
95
|
+
|
|
96
|
+
@param path - The file path where the policy should be saved.
|
|
97
|
+
"""
|
|
98
|
+
return writePolicyFile(path, currentPolicy)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
def get(array: any[], index: number) {
|
|
102
|
+
if (index < array.length) {
|
|
103
|
+
return success(array[index])
|
|
104
|
+
}
|
|
105
|
+
return failure("Index out of bounds: ${index} >= ${array.length}")
|
|
106
|
+
}
|
|
5
107
|
|
|
6
|
-
|
|
108
|
+
def highlightJSON(obj: Record<string, any>): string {
|
|
109
|
+
return highlight(JSON.stringify(obj, null, 2), "json")
|
|
110
|
+
}
|
|
7
111
|
|
|
8
112
|
node main() {
|
|
9
|
-
|
|
113
|
+
const cliArgs = args()
|
|
10
114
|
if (cliArgs.length < 2) {
|
|
11
115
|
print("Usage: agency policy gen <file>")
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
let interruptKindsJson = cliArgs[0]
|
|
15
|
-
let outputPath = cliArgs[1]
|
|
16
|
-
let existingPolicyJson = ""
|
|
17
|
-
if (cliArgs.length >= 3) {
|
|
18
|
-
existingPolicyJson = cliArgs[2]
|
|
116
|
+
return
|
|
19
117
|
}
|
|
20
118
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
existingPolicy = parseJSON(existingPolicyJson)
|
|
25
|
-
}
|
|
119
|
+
const interruptKinds = cliArgs[0] |> parseJSON
|
|
120
|
+
const outputPath = cliArgs[1]
|
|
121
|
+
const existingPolicy = get(cliArgs, 2) |> parseJSON
|
|
26
122
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
123
|
+
if (interruptKinds is failure(error)) {
|
|
124
|
+
print("Failed to parse interrupt kinds: ${error}")
|
|
125
|
+
return
|
|
30
126
|
}
|
|
31
127
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
128
|
+
let contextMessage = "This agent can produce the following interrupts:\n${map(interruptKinds.value, \kind -> "- ${kind}\n").join("")}"
|
|
129
|
+
|
|
130
|
+
if (existingPolicy is success(thePolicy)) {
|
|
131
|
+
currentPolicy = thePolicy
|
|
132
|
+
contextMessage = """
|
|
133
|
+
${contextMessage}
|
|
134
|
+
|
|
135
|
+
Current policy:
|
|
136
|
+
```json
|
|
137
|
+
${highlightJSON(currentPolicy)}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
What would you like to change?
|
|
35
141
|
"""
|
|
36
142
|
} else {
|
|
37
|
-
contextMessage =
|
|
143
|
+
contextMessage = """
|
|
144
|
+
${contextMessage}
|
|
145
|
+
|
|
146
|
+
What actions would you like to allow?
|
|
147
|
+
"""
|
|
38
148
|
}
|
|
39
149
|
|
|
40
150
|
print(contextMessage)
|
|
41
151
|
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
conversationHistory = conversationHistory + "\nUser: ${userInput}"
|
|
48
|
-
|
|
49
|
-
thread {
|
|
50
|
-
system(systemPrompt)
|
|
51
|
-
let step: NextStep = llm("""
|
|
52
|
-
${conversationHistory}\n\nCurrent policy: ${printJSON(policy)}\n\nDecide the next step. If the user is describing what they want, build or update the policy and use showPolicy. If the user approves the shown policy, use writePolicy. If you need clarification, use askQuestion.
|
|
53
|
-
""")
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (step.type == "showPolicy") {
|
|
57
|
-
policy = step.policy
|
|
58
|
-
let policyStr = printJSON(policy)
|
|
59
|
-
print("\nProposed policy:\n```json\n${policyStr}\n```\n")
|
|
60
|
-
print("Does this look right? (say 'yes' to save, or describe changes)")
|
|
61
|
-
conversationHistory = conversationHistory + "\nAssistant: Here is the proposed policy:\n${policyStr}\nDoes this look right?"
|
|
62
|
-
} else if (step.type == "writePolicy") {
|
|
63
|
-
policy = step.policy
|
|
64
|
-
writePolicyFile(outputPath, policy)
|
|
65
|
-
print("\nPolicy written to ${outputPath}")
|
|
66
|
-
done = true
|
|
67
|
-
} else if (step.type == "askQuestion") {
|
|
68
|
-
print(step.question)
|
|
69
|
-
conversationHistory = conversationHistory + "\nAssistant: ${step.question}"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return end()
|
|
73
|
-
}
|
|
152
|
+
let userInput = input("> ")
|
|
153
|
+
// didn't catch `policy` var is undefined??
|
|
154
|
+
// doesn't typecheck in string segments??
|
|
155
|
+
const prompt = """
|
|
156
|
+
Current policy: ${JSON.stringify(currentPolicy, null, 2)}
|
|
74
157
|
|
|
75
|
-
|
|
158
|
+
Decide the next step. If the user is describing what they want, build or update the policy and use addToPolicy, setPolicy, or deleteFromPolicy. Show the user the policy and get confirmation that it looks good. When you are done, return { type: "done" }. Otherwise, ask the user a question to clarify what they want, and return { type: "askQuestion", question: "..." }.
|
|
159
|
+
"""
|
|
76
160
|
|
|
161
|
+
systemMessage(systemPrompt)
|
|
162
|
+
assistantMessage(contextMessage)
|
|
163
|
+
userMessage(userInput)
|
|
164
|
+
|
|
165
|
+
const tools = [addToPolicy, getPolicy, setPolicy, deleteFromPolicy]
|
|
166
|
+
|
|
167
|
+
let action: Action = llm(prompt, {
|
|
168
|
+
tools: tools
|
|
169
|
+
})
|
|
170
|
+
while (action.type != "done") {
|
|
171
|
+
print(action.question)
|
|
172
|
+
let userInput = input("> ")
|
|
173
|
+
action: Action = llm(userInput, {
|
|
174
|
+
tools: tools
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
print("Done. Final policy:")
|
|
178
|
+
printJSON(currentPolicy)
|
|
179
|
+
const result = savePolicy(outputPath)
|
|
180
|
+
if (result is failure(error)) {
|
|
181
|
+
print("Failed to save policy: ${error}")
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
print("Saved policy to ${outputPath}.")
|
|
77
185
|
}
|
|
@@ -37,3 +37,10 @@ Each rule has:
|
|
|
37
37
|
7. If the user wants changes, refine and show again
|
|
38
38
|
|
|
39
39
|
Be concise. Don't over-explain the policy format unless the user asks. Focus on understanding what they want to allow or deny, then build the policy for them.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## Tools you can use
|
|
43
|
+
- addToPolicy: adds a new rule to the policy for a given interrupt kind
|
|
44
|
+
- getPolicy: retrieves the current policy
|
|
45
|
+
- setPolicy: replaces the entire policy with a new JSON object
|
|
46
|
+
- deleteFromPolicy: deletes rules from the policy for a given interrupt kind
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { exec } from "std::shell"
|
|
2
2
|
import { args } from "std::system"
|
|
3
|
+
import { systemMessage } from "std::thread"
|
|
3
4
|
systemPrompt = read("./prompts/system.md")
|
|
4
5
|
|
|
5
6
|
type Severity = "critical" | "warning" | "suggestion"
|
|
@@ -38,7 +39,7 @@ node main() {
|
|
|
38
39
|
}
|
|
39
40
|
// Have the LLM review the code
|
|
40
41
|
thread {
|
|
41
|
-
|
|
42
|
+
systemMessage(systemPrompt)
|
|
42
43
|
let typeErrorMessage = "The type checker found no errors."
|
|
43
44
|
if (typeErrors != "") {
|
|
44
45
|
typeErrorMessage = "The type checker reported the following errors:\n${typeErrors}"
|