pinecall 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +134 -0
- package/dist/agent/accepts.d.ts +32 -0
- package/dist/agent/accepts.d.ts.map +1 -0
- package/dist/agent/accepts.js +28 -0
- package/dist/agent/accepts.js.map +1 -0
- package/dist/agent/agent.d.ts +189 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +262 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/authors.d.ts +12 -0
- package/dist/agent/authors.d.ts.map +1 -0
- package/dist/agent/authors.js +28 -0
- package/dist/agent/authors.js.map +1 -0
- package/dist/agent/decorators.d.ts +22 -0
- package/dist/agent/decorators.d.ts.map +1 -0
- package/dist/agent/decorators.js +49 -0
- package/dist/agent/decorators.js.map +1 -0
- package/dist/agent/docstrings.d.ts +43 -0
- package/dist/agent/docstrings.d.ts.map +1 -0
- package/dist/agent/docstrings.js +311 -0
- package/dist/agent/docstrings.js.map +1 -0
- package/dist/agent/lifecycle.d.ts +29 -0
- package/dist/agent/lifecycle.d.ts.map +1 -0
- package/dist/agent/lifecycle.js +11 -0
- package/dist/agent/lifecycle.js.map +1 -0
- package/dist/agent/stages.d.ts +28 -0
- package/dist/agent/stages.d.ts.map +1 -0
- package/dist/agent/stages.js +32 -0
- package/dist/agent/stages.js.map +1 -0
- package/dist/agent/state.d.ts +43 -0
- package/dist/agent/state.d.ts.map +1 -0
- package/dist/agent/state.js +104 -0
- package/dist/agent/state.js.map +1 -0
- package/dist/agent/tools.d.ts +66 -0
- package/dist/agent/tools.d.ts.map +1 -0
- package/dist/agent/tools.js +148 -0
- package/dist/agent/tools.js.map +1 -0
- package/dist/agent/visibility.d.ts +40 -0
- package/dist/agent/visibility.d.ts.map +1 -0
- package/dist/agent/visibility.js +89 -0
- package/dist/agent/visibility.js.map +1 -0
- package/dist/call/call.d.ts +55 -0
- package/dist/call/call.d.ts.map +1 -0
- package/dist/call/call.js +108 -0
- package/dist/call/call.js.map +1 -0
- package/dist/call/history.d.ts +34 -0
- package/dist/call/history.d.ts.map +1 -0
- package/dist/call/history.js +38 -0
- package/dist/call/history.js.map +1 -0
- package/dist/call/room.d.ts +58 -0
- package/dist/call/room.d.ts.map +1 -0
- package/dist/call/room.js +68 -0
- package/dist/call/room.js.map +1 -0
- package/dist/cli/browser.d.ts +8 -0
- package/dist/cli/browser.d.ts.map +1 -0
- package/dist/cli/browser.js +27 -0
- package/dist/cli/browser.js.map +1 -0
- package/dist/cli/callbacks.d.ts +26 -0
- package/dist/cli/callbacks.d.ts.map +1 -0
- package/dist/cli/callbacks.js +68 -0
- package/dist/cli/callbacks.js.map +1 -0
- package/dist/cli/chat.d.ts +21 -0
- package/dist/cli/chat.d.ts.map +1 -0
- package/dist/cli/chat.js +214 -0
- package/dist/cli/chat.js.map +1 -0
- package/dist/cli/config.d.ts +16 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +94 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/connected.d.ts +30 -0
- package/dist/cli/connected.d.ts.map +1 -0
- package/dist/cli/connected.js +32 -0
- package/dist/cli/connected.js.map +1 -0
- package/dist/cli/credentials.d.ts +41 -0
- package/dist/cli/credentials.d.ts.map +1 -0
- package/dist/cli/credentials.js +98 -0
- package/dist/cli/credentials.js.map +1 -0
- package/dist/cli/ear.d.ts +3 -0
- package/dist/cli/ear.d.ts.map +1 -0
- package/dist/cli/ear.js +59 -0
- package/dist/cli/ear.js.map +1 -0
- package/dist/cli/env.d.ts +40 -0
- package/dist/cli/env.d.ts.map +1 -0
- package/dist/cli/env.js +45 -0
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/eval.d.ts +37 -0
- package/dist/cli/eval.d.ts.map +1 -0
- package/dist/cli/eval.js +83 -0
- package/dist/cli/eval.js.map +1 -0
- package/dist/cli/groups.d.ts +17 -0
- package/dist/cli/groups.d.ts.map +1 -0
- package/dist/cli/groups.js +38 -0
- package/dist/cli/groups.js.map +1 -0
- package/dist/cli/index.d.ts +16 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +169 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/keys.d.ts +28 -0
- package/dist/cli/keys.d.ts.map +1 -0
- package/dist/cli/keys.js +137 -0
- package/dist/cli/keys.js.map +1 -0
- package/dist/cli/knowledge.d.ts +35 -0
- package/dist/cli/knowledge.d.ts.map +1 -0
- package/dist/cli/knowledge.js +174 -0
- package/dist/cli/knowledge.js.map +1 -0
- package/dist/cli/line.d.ts +33 -0
- package/dist/cli/line.d.ts.map +1 -0
- package/dist/cli/line.js +134 -0
- package/dist/cli/line.js.map +1 -0
- package/dist/cli/listening.d.ts +38 -0
- package/dist/cli/listening.d.ts.map +1 -0
- package/dist/cli/listening.js +124 -0
- package/dist/cli/listening.js.map +1 -0
- package/dist/cli/load.d.ts +38 -0
- package/dist/cli/load.d.ts.map +1 -0
- package/dist/cli/load.js +99 -0
- package/dist/cli/load.js.map +1 -0
- package/dist/cli/login.d.ts +30 -0
- package/dist/cli/login.d.ts.map +1 -0
- package/dist/cli/login.js +158 -0
- package/dist/cli/login.js.map +1 -0
- package/dist/cli/machine.d.ts +8 -0
- package/dist/cli/machine.d.ts.map +1 -0
- package/dist/cli/machine.js +41 -0
- package/dist/cli/machine.js.map +1 -0
- package/dist/cli/memory.d.ts +26 -0
- package/dist/cli/memory.d.ts.map +1 -0
- package/dist/cli/memory.js +148 -0
- package/dist/cli/memory.js.map +1 -0
- package/dist/cli/numbers.d.ts +25 -0
- package/dist/cli/numbers.d.ts.map +1 -0
- package/dist/cli/numbers.js +132 -0
- package/dist/cli/numbers.js.map +1 -0
- package/dist/cli/personas.d.ts +5 -0
- package/dist/cli/personas.d.ts.map +1 -0
- package/dist/cli/personas.js +94 -0
- package/dist/cli/personas.js.map +1 -0
- package/dist/cli/pipeline.d.ts +52 -0
- package/dist/cli/pipeline.d.ts.map +1 -0
- package/dist/cli/pipeline.js +184 -0
- package/dist/cli/pipeline.js.map +1 -0
- package/dist/cli/profiles.d.ts +70 -0
- package/dist/cli/profiles.d.ts.map +1 -0
- package/dist/cli/profiles.js +210 -0
- package/dist/cli/profiles.js.map +1 -0
- package/dist/cli/prompt.d.ts +20 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +58 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/providers.d.ts +14 -0
- package/dist/cli/providers.d.ts.map +1 -0
- package/dist/cli/providers.js +116 -0
- package/dist/cli/providers.js.map +1 -0
- package/dist/cli/remember.d.ts +29 -0
- package/dist/cli/remember.d.ts.map +1 -0
- package/dist/cli/remember.js +112 -0
- package/dist/cli/remember.js.map +1 -0
- package/dist/cli/run.d.ts +20 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +347 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/runs/candidate.d.ts +51 -0
- package/dist/cli/runs/candidate.d.ts.map +1 -0
- package/dist/cli/runs/candidate.js +127 -0
- package/dist/cli/runs/candidate.js.map +1 -0
- package/dist/cli/runs/drift.d.ts +75 -0
- package/dist/cli/runs/drift.d.ts.map +1 -0
- package/dist/cli/runs/drift.js +151 -0
- package/dist/cli/runs/drift.js.map +1 -0
- package/dist/cli/runs/index.d.ts +5 -0
- package/dist/cli/runs/index.d.ts.map +1 -0
- package/dist/cli/runs/index.js +99 -0
- package/dist/cli/runs/index.js.map +1 -0
- package/dist/cli/runs/suites.d.ts +16 -0
- package/dist/cli/runs/suites.d.ts.map +1 -0
- package/dist/cli/runs/suites.js +63 -0
- package/dist/cli/runs/suites.js.map +1 -0
- package/dist/cli/secret.d.ts +18 -0
- package/dist/cli/secret.d.ts.map +1 -0
- package/dist/cli/secret.js +41 -0
- package/dist/cli/secret.js.map +1 -0
- package/dist/cli/sessions.d.ts +21 -0
- package/dist/cli/sessions.d.ts.map +1 -0
- package/dist/cli/sessions.js +174 -0
- package/dist/cli/sessions.js.map +1 -0
- package/dist/cli/signup.d.ts +25 -0
- package/dist/cli/signup.d.ts.map +1 -0
- package/dist/cli/signup.js +122 -0
- package/dist/cli/signup.js.map +1 -0
- package/dist/cli/simulate.d.ts +45 -0
- package/dist/cli/simulate.d.ts.map +1 -0
- package/dist/cli/simulate.js +320 -0
- package/dist/cli/simulate.js.map +1 -0
- package/dist/cli/supervise.d.ts +18 -0
- package/dist/cli/supervise.d.ts.map +1 -0
- package/dist/cli/supervise.js +134 -0
- package/dist/cli/supervise.js.map +1 -0
- package/dist/cli/test.d.ts +12 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +128 -0
- package/dist/cli/test.js.map +1 -0
- package/dist/cli/testing/caller.d.ts +28 -0
- package/dist/cli/testing/caller.d.ts.map +1 -0
- package/dist/cli/testing/caller.js +30 -0
- package/dist/cli/testing/caller.js.map +1 -0
- package/dist/cli/testing/gateway.d.ts +172 -0
- package/dist/cli/testing/gateway.d.ts.map +1 -0
- package/dist/cli/testing/gateway.js +96 -0
- package/dist/cli/testing/gateway.js.map +1 -0
- package/dist/cli/testing/goldens.d.ts +61 -0
- package/dist/cli/testing/goldens.d.ts.map +1 -0
- package/dist/cli/testing/goldens.js +54 -0
- package/dist/cli/testing/goldens.js.map +1 -0
- package/dist/cli/testing/latency.d.ts +15 -0
- package/dist/cli/testing/latency.d.ts.map +1 -0
- package/dist/cli/testing/latency.js +44 -0
- package/dist/cli/testing/latency.js.map +1 -0
- package/dist/cli/testing/matrix.d.ts +12 -0
- package/dist/cli/testing/matrix.d.ts.map +1 -0
- package/dist/cli/testing/matrix.js +103 -0
- package/dist/cli/testing/matrix.js.map +1 -0
- package/dist/cli/testing/progress.d.ts +26 -0
- package/dist/cli/testing/progress.d.ts.map +1 -0
- package/dist/cli/testing/progress.js +185 -0
- package/dist/cli/testing/progress.js.map +1 -0
- package/dist/cli/testing/reproduction.d.ts +19 -0
- package/dist/cli/testing/reproduction.d.ts.map +1 -0
- package/dist/cli/testing/reproduction.js +65 -0
- package/dist/cli/testing/reproduction.js.map +1 -0
- package/dist/cli/testing/score.d.ts +11 -0
- package/dist/cli/testing/score.d.ts.map +1 -0
- package/dist/cli/testing/score.js +54 -0
- package/dist/cli/testing/score.js.map +1 -0
- package/dist/cli/testing/seeding.d.ts +32 -0
- package/dist/cli/testing/seeding.d.ts.map +1 -0
- package/dist/cli/testing/seeding.js +44 -0
- package/dist/cli/testing/seeding.js.map +1 -0
- package/dist/cli/testing/suite.d.ts +40 -0
- package/dist/cli/testing/suite.d.ts.map +1 -0
- package/dist/cli/testing/suite.js +103 -0
- package/dist/cli/testing/suite.js.map +1 -0
- package/dist/cli/testing/voice.d.ts +37 -0
- package/dist/cli/testing/voice.d.ts.map +1 -0
- package/dist/cli/testing/voice.js +53 -0
- package/dist/cli/testing/voice.js.map +1 -0
- package/dist/cli/ui/admin/assets/index-C3WMXdfL.css +1 -0
- package/dist/cli/ui/admin/assets/index-DR1mxoAh.js +58 -0
- package/dist/cli/ui/admin/index.html +20 -0
- package/dist/cli/ui/asked.d.ts +16 -0
- package/dist/cli/ui/asked.d.ts.map +1 -0
- package/dist/cli/ui/asked.js +53 -0
- package/dist/cli/ui/asked.js.map +1 -0
- package/dist/cli/ui/browser.d.ts +10 -0
- package/dist/cli/ui/browser.d.ts.map +1 -0
- package/dist/cli/ui/browser.js +30 -0
- package/dist/cli/ui/browser.js.map +1 -0
- package/dist/cli/ui/chatting.d.ts +62 -0
- package/dist/cli/ui/chatting.d.ts.map +1 -0
- package/dist/cli/ui/chatting.js +171 -0
- package/dist/cli/ui/chatting.js.map +1 -0
- package/dist/cli/ui/console/assets/index-DCTnou52.css +1 -0
- package/dist/cli/ui/console/assets/index-dOcE4usU.js +99 -0
- package/dist/cli/ui/console/index.html +20 -0
- package/dist/cli/ui/console/logo-mark.png +0 -0
- package/dist/cli/ui/doors.d.ts +37 -0
- package/dist/cli/ui/doors.d.ts.map +1 -0
- package/dist/cli/ui/doors.js +70 -0
- package/dist/cli/ui/doors.js.map +1 -0
- package/dist/cli/ui/drifting.d.ts +23 -0
- package/dist/cli/ui/drifting.d.ts.map +1 -0
- package/dist/cli/ui/drifting.js +33 -0
- package/dist/cli/ui/drifting.js.map +1 -0
- package/dist/cli/ui/index.d.ts +15 -0
- package/dist/cli/ui/index.d.ts.map +1 -0
- package/dist/cli/ui/index.js +117 -0
- package/dist/cli/ui/index.js.map +1 -0
- package/dist/cli/ui/knowing.d.ts +36 -0
- package/dist/cli/ui/knowing.d.ts.map +1 -0
- package/dist/cli/ui/knowing.js +86 -0
- package/dist/cli/ui/knowing.js.map +1 -0
- package/dist/cli/ui/promoting.d.ts +26 -0
- package/dist/cli/ui/promoting.d.ts.map +1 -0
- package/dist/cli/ui/promoting.js +44 -0
- package/dist/cli/ui/promoting.js.map +1 -0
- package/dist/cli/ui/refusal.d.ts +18 -0
- package/dist/cli/ui/refusal.d.ts.map +1 -0
- package/dist/cli/ui/refusal.js +26 -0
- package/dist/cli/ui/refusal.js.map +1 -0
- package/dist/cli/ui/refused.d.ts +8 -0
- package/dist/cli/ui/refused.d.ts.map +1 -0
- package/dist/cli/ui/refused.js +11 -0
- package/dist/cli/ui/refused.js.map +1 -0
- package/dist/cli/ui/remembering.d.ts +38 -0
- package/dist/cli/ui/remembering.d.ts.map +1 -0
- package/dist/cli/ui/remembering.js +87 -0
- package/dist/cli/ui/remembering.js.map +1 -0
- package/dist/cli/ui/reproducing.d.ts +23 -0
- package/dist/cli/ui/reproducing.d.ts.map +1 -0
- package/dist/cli/ui/reproducing.js +52 -0
- package/dist/cli/ui/reproducing.js.map +1 -0
- package/dist/cli/ui/server.d.ts +22 -0
- package/dist/cli/ui/server.d.ts.map +1 -0
- package/dist/cli/ui/server.js +211 -0
- package/dist/cli/ui/server.js.map +1 -0
- package/dist/cli/ui/simulating.d.ts +47 -0
- package/dist/cli/ui/simulating.d.ts.map +1 -0
- package/dist/cli/ui/simulating.js +86 -0
- package/dist/cli/ui/simulating.js.map +1 -0
- package/dist/cli/ui/testing.d.ts +49 -0
- package/dist/cli/ui/testing.d.ts.map +1 -0
- package/dist/cli/ui/testing.js +104 -0
- package/dist/cli/ui/testing.js.map +1 -0
- package/dist/cli/view.d.ts +43 -0
- package/dist/cli/view.d.ts.map +1 -0
- package/dist/cli/view.js +137 -0
- package/dist/cli/view.js.map +1 -0
- package/dist/cli/whoami.d.ts +37 -0
- package/dist/cli/whoami.d.ts.map +1 -0
- package/dist/cli/whoami.js +78 -0
- package/dist/cli/whoami.js.map +1 -0
- package/dist/cli/world.d.ts +33 -0
- package/dist/cli/world.d.ts.map +1 -0
- package/dist/cli/world.js +48 -0
- package/dist/cli/world.js.map +1 -0
- package/dist/client/agent.d.ts +87 -0
- package/dist/client/agent.d.ts.map +1 -0
- package/dist/client/agent.js +209 -0
- package/dist/client/agent.js.map +1 -0
- package/dist/client/calls.d.ts +77 -0
- package/dist/client/calls.d.ts.map +1 -0
- package/dist/client/calls.js +153 -0
- package/dist/client/calls.js.map +1 -0
- package/dist/client/client.d.ts +58 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +146 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/connection.d.ts +47 -0
- package/dist/client/connection.d.ts.map +1 -0
- package/dist/client/connection.js +141 -0
- package/dist/client/connection.js.map +1 -0
- package/dist/client/endpoints.d.ts +7 -0
- package/dist/client/endpoints.d.ts.map +1 -0
- package/dist/client/endpoints.js +21 -0
- package/dist/client/endpoints.js.map +1 -0
- package/dist/client/frames.d.ts +24 -0
- package/dist/client/frames.d.ts.map +1 -0
- package/dist/client/frames.js +49 -0
- package/dist/client/frames.js.map +1 -0
- package/dist/client/index.d.ts +15 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +14 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/listeners.d.ts +36 -0
- package/dist/client/listeners.d.ts.map +1 -0
- package/dist/client/listeners.js +61 -0
- package/dist/client/listeners.js.map +1 -0
- package/dist/client/observe.d.ts +44 -0
- package/dist/client/observe.d.ts.map +1 -0
- package/dist/client/observe.js +122 -0
- package/dist/client/observe.js.map +1 -0
- package/dist/client/testing/gateway.d.ts +39 -0
- package/dist/client/testing/gateway.d.ts.map +1 -0
- package/dist/client/testing/gateway.js +129 -0
- package/dist/client/testing/gateway.js.map +1 -0
- package/dist/client/testing/index.d.ts +4 -0
- package/dist/client/testing/index.d.ts.map +1 -0
- package/dist/client/testing/index.js +4 -0
- package/dist/client/testing/index.js.map +1 -0
- package/dist/client/testing/log.d.ts +26 -0
- package/dist/client/testing/log.d.ts.map +1 -0
- package/dist/client/testing/log.js +111 -0
- package/dist/client/testing/log.js.map +1 -0
- package/dist/client/testing/loopback.d.ts +3 -0
- package/dist/client/testing/loopback.d.ts.map +1 -0
- package/dist/client/testing/loopback.js +3 -0
- package/dist/client/testing/loopback.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/channels.d.ts +16 -0
- package/dist/runtime/channels.d.ts.map +1 -0
- package/dist/runtime/channels.js +30 -0
- package/dist/runtime/channels.js.map +1 -0
- package/dist/runtime/connect.d.ts +51 -0
- package/dist/runtime/connect.d.ts.map +1 -0
- package/dist/runtime/connect.js +284 -0
- package/dist/runtime/connect.js.map +1 -0
- package/dist/runtime/dispatch.d.ts +37 -0
- package/dist/runtime/dispatch.d.ts.map +1 -0
- package/dist/runtime/dispatch.js +52 -0
- package/dist/runtime/dispatch.js.map +1 -0
- package/dist/runtime/grounding.d.ts +15 -0
- package/dist/runtime/grounding.d.ts.map +1 -0
- package/dist/runtime/grounding.js +72 -0
- package/dist/runtime/grounding.js.map +1 -0
- package/dist/runtime/recall.d.ts +10 -0
- package/dist/runtime/recall.d.ts.map +1 -0
- package/dist/runtime/recall.js +13 -0
- package/dist/runtime/recall.js.map +1 -0
- package/dist/runtime/run-tool.d.ts +26 -0
- package/dist/runtime/run-tool.d.ts.map +1 -0
- package/dist/runtime/run-tool.js +82 -0
- package/dist/runtime/run-tool.js.map +1 -0
- package/dist/views/components.d.ts +17 -0
- package/dist/views/components.d.ts.map +1 -0
- package/dist/views/components.js +33 -0
- package/dist/views/components.js.map +1 -0
- package/dist/views/jsx-dev-runtime.d.ts +3 -0
- package/dist/views/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/views/jsx-dev-runtime.js +5 -0
- package/dist/views/jsx-dev-runtime.js.map +1 -0
- package/dist/views/jsx-runtime.d.ts +49 -0
- package/dist/views/jsx-runtime.d.ts.map +1 -0
- package/dist/views/jsx-runtime.js +67 -0
- package/dist/views/jsx-runtime.js.map +1 -0
- package/dist/views/lang.d.ts +17 -0
- package/dist/views/lang.d.ts.map +1 -0
- package/dist/views/lang.js +46 -0
- package/dist/views/lang.js.map +1 -0
- package/dist/views/layout.d.ts +19 -0
- package/dist/views/layout.d.ts.map +1 -0
- package/dist/views/layout.js +62 -0
- package/dist/views/layout.js.map +1 -0
- package/dist/views/render.d.ts +19 -0
- package/dist/views/render.d.ts.map +1 -0
- package/dist/views/render.js +26 -0
- package/dist/views/render.js.map +1 -0
- package/package.json +76 -0
- package/tsconfig.tenant.json +24 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** `knowledge` / `docs` / `memory` fields → what the declaration carries: the file read, the base named, the policy. */
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
// A string with a `*` or a `/` in it is the glob `docs` used to be — a path the app expanded
|
|
5
|
+
// itself. The base is pushed by name now, and the sentence says which verb does the pushing.
|
|
6
|
+
const A_GLOB = /[*/]/;
|
|
7
|
+
/**
|
|
8
|
+
* What the class says it knows, reads and remembers, read off one probe instance. `file` is the
|
|
9
|
+
* agent's own path, so a knowledge file is found beside the class and not beside whoever ran the
|
|
10
|
+
* process; without one it is read from the working directory.
|
|
11
|
+
*/
|
|
12
|
+
export function groundingOf(probe, file) {
|
|
13
|
+
const declared = probe;
|
|
14
|
+
const grounding = {};
|
|
15
|
+
const knowledge = knowledgeOf(declared.knowledge, file);
|
|
16
|
+
if (knowledge)
|
|
17
|
+
grounding.knowledge = knowledge;
|
|
18
|
+
const docs = baseOf(declared.docs);
|
|
19
|
+
if (docs)
|
|
20
|
+
grounding.docs = docs;
|
|
21
|
+
const memory = memoryOf(declared.memory);
|
|
22
|
+
if (memory)
|
|
23
|
+
grounding.memory = memory;
|
|
24
|
+
return grounding;
|
|
25
|
+
}
|
|
26
|
+
// The file is sent whole: the runtime puts its text where the knowledge marker is, in the static
|
|
27
|
+
// block, once per call. Its path travels as the class wrote it, because that is the name the
|
|
28
|
+
// marker carries. A file that is not there is refused here, with the path that was looked at.
|
|
29
|
+
function knowledgeOf(value, file) {
|
|
30
|
+
if (typeof value !== "string" || value === "")
|
|
31
|
+
return undefined;
|
|
32
|
+
const path = resolve(file === undefined ? process.cwd() : dirname(file), value);
|
|
33
|
+
if (!existsSync(path)) {
|
|
34
|
+
throw new Error(`knowledge ${value}: no such file at ${path}`);
|
|
35
|
+
}
|
|
36
|
+
return { path: value, text: readFileSync(path, "utf8") };
|
|
37
|
+
}
|
|
38
|
+
/** `docs = "clinica-norte"` or `docs = { base, mode?, k?, minScore? }`: the base, as the wire names it. */
|
|
39
|
+
function baseOf(value) {
|
|
40
|
+
if (typeof value === "string") {
|
|
41
|
+
if (value === "")
|
|
42
|
+
return undefined;
|
|
43
|
+
if (A_GLOB.test(value)) {
|
|
44
|
+
throw new Error("docs name the base they were pushed to: run `pinecall knowledge push ./knowledge/docs --base <slug>`");
|
|
45
|
+
}
|
|
46
|
+
return { base: value };
|
|
47
|
+
}
|
|
48
|
+
if (typeof value !== "object" || value === null)
|
|
49
|
+
return undefined;
|
|
50
|
+
const declared = value;
|
|
51
|
+
const docs = { base: declared.base };
|
|
52
|
+
if (declared.mode !== undefined)
|
|
53
|
+
docs.mode = declared.mode;
|
|
54
|
+
if (declared.k !== undefined)
|
|
55
|
+
docs.k = declared.k;
|
|
56
|
+
if (declared.minScore !== undefined)
|
|
57
|
+
docs.minScore = declared.minScore;
|
|
58
|
+
return docs;
|
|
59
|
+
}
|
|
60
|
+
/** `memory = { remember: [...], forget: [...] }`, in the tenant's words, as declared. */
|
|
61
|
+
function memoryOf(value) {
|
|
62
|
+
if (typeof value !== "object" || value === null)
|
|
63
|
+
return undefined;
|
|
64
|
+
const declared = value;
|
|
65
|
+
const memory = {};
|
|
66
|
+
if (Array.isArray(declared.remember))
|
|
67
|
+
memory.remember = declared.remember;
|
|
68
|
+
if (Array.isArray(declared.forget))
|
|
69
|
+
memory.forget = declared.forget;
|
|
70
|
+
return memory;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=grounding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grounding.js","sourceRoot":"","sources":["../../src/runtime/grounding.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAExH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAa7C,6FAA6F;AAC7F,6FAA6F;AAC7F,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,IAAa;IACtD,MAAM,QAAQ,GAAG,KAAkE,CAAC;IACpF,MAAM,SAAS,GAAc,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACxD,IAAI,SAAS;QAAE,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IAAI;QAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;IAChC,MAAM,MAAM,GAAG,QAA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,CAAC,IAAI,EAAE,CAAC;IACxD,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3D,IAAI,QAAQ,CAAC,CAAC,KAAK,SAAS;QAAE,IAAI,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAClD,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS;QAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,yFAAyF;AACzF,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IAClE,MAAM,QAAQ,GAAG,KAA0B,CAAC;IAC5C,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAC1E,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What memory recalled about this caller, as the words a class's `render()` may ask about. */
|
|
2
|
+
import type { Camel, MemoryOps } from "@pinecall/protocol";
|
|
3
|
+
/**
|
|
4
|
+
* Every word one `memory.ops` entry puts in front of the model: each fact's own sentence, and the
|
|
5
|
+
* word the class remembered it by. Only a `recall` counts — a `remember` at hang-up is what this
|
|
6
|
+
* call taught memory, not what memory told this call — so `remembers()` never answers with a fact
|
|
7
|
+
* the caller has not been told back.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wordsRecalled(entry: Camel<MemoryOps>): string[];
|
|
10
|
+
//# sourceMappingURL=recall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../src/runtime/recall.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAE/F,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,MAAM,EAAE,CAI/D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What memory recalled about this caller, as the words a class's `render()` may ask about. */
|
|
2
|
+
/**
|
|
3
|
+
* Every word one `memory.ops` entry puts in front of the model: each fact's own sentence, and the
|
|
4
|
+
* word the class remembered it by. Only a `recall` counts — a `remember` at hang-up is what this
|
|
5
|
+
* call taught memory, not what memory told this call — so `remembers()` never answers with a fact
|
|
6
|
+
* the caller has not been told back.
|
|
7
|
+
*/
|
|
8
|
+
export function wordsRecalled(entry) {
|
|
9
|
+
return entry.ops
|
|
10
|
+
.filter((op) => op.op === "recall")
|
|
11
|
+
.flatMap((op) => op.facts.flatMap((fact) => [fact.text, fact.category ?? ""]));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=recall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.js","sourceRoot":"","sources":["../../src/runtime/recall.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAI/F;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAuB;IACnD,OAAO,KAAK,CAAC,GAAG;SACb,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC;SAClC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Running one tool call: the args are checked, the method runs, and the result is cut to a preview. */
|
|
2
|
+
import type { ToolDeclaration } from "../agent/tools.js";
|
|
3
|
+
/**
|
|
4
|
+
* A tool that did not run, or ran and failed, said in words a model may read. The SDK turns a
|
|
5
|
+
* rejection into a tool.result carrying `error`, which is the only way the model hears about it.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ToolFailed extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/** What the model sent, checked against the tool's own schema; empty means it may run. */
|
|
11
|
+
export declare function validate(declaration: ToolDeclaration, args: Record<string, unknown>): string[];
|
|
12
|
+
/** The model's object as the method's argument list, in the signature's own order. */
|
|
13
|
+
export declare function argumentsFor(declaration: ToolDeclaration, args: Record<string, unknown>): unknown[];
|
|
14
|
+
/**
|
|
15
|
+
* What the model sees of a result. `preview: 2` means the model reads two rows and the state field
|
|
16
|
+
* keeps every one of them, so the agent can offer a third without asking the agenda again.
|
|
17
|
+
*/
|
|
18
|
+
export declare function preview(declaration: ToolDeclaration, result: unknown): unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Run one tool call against a live agent: check, call, cut.
|
|
21
|
+
*
|
|
22
|
+
* The method is reached through the instance and not through `declaration.method`, because the
|
|
23
|
+
* decorator's wrapper is what gives every `this.slot = …` inside it the tool's name as its author.
|
|
24
|
+
*/
|
|
25
|
+
export declare function runTool(agent: object, declaration: ToolDeclaration, args: Record<string, unknown>): Promise<unknown>;
|
|
26
|
+
//# sourceMappingURL=run-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-tool.d.ts","sourceRoot":"","sources":["../../src/runtime/run-tool.ts"],"names":[],"mappings":"AAAA,wGAAwG;AAExG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAwCD,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAE9F;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAC1B,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,EAAE,CAEX;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAI9E;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,OAAO,CAAC,CAclB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** Running one tool call: the args are checked, the method runs, and the result is cut to a preview. */
|
|
2
|
+
/**
|
|
3
|
+
* A tool that did not run, or ran and failed, said in words a model may read. The SDK turns a
|
|
4
|
+
* rejection into a tool.result carrying `error`, which is the only way the model hears about it.
|
|
5
|
+
*/
|
|
6
|
+
export class ToolFailed extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ToolFailed";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
// The model fills a JSON object; the method takes positional arguments. The schema's property
|
|
13
|
+
// order is the signature's order — parametersOf writes it from the parsed parameter list — so the
|
|
14
|
+
// object becomes the argument list by walking the same keys.
|
|
15
|
+
function orderOf(parameters) {
|
|
16
|
+
return Object.keys(parameters.properties ?? {});
|
|
17
|
+
}
|
|
18
|
+
function typeOf(value) {
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return "array";
|
|
21
|
+
if (value === null)
|
|
22
|
+
return "null";
|
|
23
|
+
return typeof value;
|
|
24
|
+
}
|
|
25
|
+
// Only the shapes the schema can actually state are checked: a required name that is missing, and
|
|
26
|
+
// a value whose JSON type is not the declared one. Anything deeper — a Slot's own fields — is the
|
|
27
|
+
// app's to check, because the framework never saw the type behind the alias.
|
|
28
|
+
function complaintsAbout(parameters, args) {
|
|
29
|
+
const properties = parameters.properties ?? {};
|
|
30
|
+
const complaints = [];
|
|
31
|
+
for (const name of parameters.required ?? []) {
|
|
32
|
+
if (args[name] === undefined)
|
|
33
|
+
complaints.push(`${name} is required`);
|
|
34
|
+
}
|
|
35
|
+
for (const [name, schema] of Object.entries(properties)) {
|
|
36
|
+
const value = args[name];
|
|
37
|
+
const wanted = schema.type;
|
|
38
|
+
if (value === undefined || wanted === undefined)
|
|
39
|
+
continue;
|
|
40
|
+
if (typeOf(value) !== wanted) {
|
|
41
|
+
complaints.push(`${name} must be a ${wanted}, not a ${typeOf(value)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return complaints;
|
|
45
|
+
}
|
|
46
|
+
/** What the model sent, checked against the tool's own schema; empty means it may run. */
|
|
47
|
+
export function validate(declaration, args) {
|
|
48
|
+
return complaintsAbout(declaration.spec.parameters, args ?? {});
|
|
49
|
+
}
|
|
50
|
+
/** The model's object as the method's argument list, in the signature's own order. */
|
|
51
|
+
export function argumentsFor(declaration, args) {
|
|
52
|
+
return orderOf(declaration.spec.parameters).map((name) => args?.[name]);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* What the model sees of a result. `preview: 2` means the model reads two rows and the state field
|
|
56
|
+
* keeps every one of them, so the agent can offer a third without asking the agenda again.
|
|
57
|
+
*/
|
|
58
|
+
export function preview(declaration, result) {
|
|
59
|
+
const rows = declaration.options.preview;
|
|
60
|
+
if (rows === undefined || !Array.isArray(result) || result.length <= rows)
|
|
61
|
+
return result;
|
|
62
|
+
return result.slice(0, rows);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Run one tool call against a live agent: check, call, cut.
|
|
66
|
+
*
|
|
67
|
+
* The method is reached through the instance and not through `declaration.method`, because the
|
|
68
|
+
* decorator's wrapper is what gives every `this.slot = …` inside it the tool's name as its author.
|
|
69
|
+
*/
|
|
70
|
+
export async function runTool(agent, declaration, args) {
|
|
71
|
+
const complaints = validate(declaration, args);
|
|
72
|
+
if (complaints.length > 0) {
|
|
73
|
+
throw new ToolFailed(`${declaration.name}: ${complaints.join("; ")}`);
|
|
74
|
+
}
|
|
75
|
+
const method = agent[declaration.name];
|
|
76
|
+
if (typeof method !== "function") {
|
|
77
|
+
throw new ToolFailed(`${declaration.name}: this agent has no such method any more`);
|
|
78
|
+
}
|
|
79
|
+
const result = await method.apply(agent, argumentsFor(declaration, args));
|
|
80
|
+
return preview(declaration, result);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=run-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-tool.js","sourceRoot":"","sources":["../../src/runtime/run-tool.ts"],"names":[],"mappings":"AAAA,wGAAwG;AAIxG;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAOD,8FAA8F;AAC9F,kGAAkG;AAClG,6DAA6D;AAC7D,SAAS,OAAO,CAAC,UAAsB;IACrC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,OAAO,OAAO,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,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACxF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,WAA4B,EAAE,MAAe;IACnE,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;IACzC,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI;QAAE,OAAO,MAAM,CAAC;IACzF,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,KAAa,EACb,WAA4B,EAC5B,IAA6B;IAE7B,MAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC/C,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,GAAG,WAAW,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,MAAM,GAAI,KAAiC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACpE,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;QACjC,MAAM,IAAI,UAAU,CAAC,GAAG,WAAW,CAAC,IAAI,0CAA0C,CAAC,CAAC;IACtF,CAAC;IACD,MAAM,MAAM,GAAY,MAAO,MAA0C,CAAC,KAAK,CAC7E,KAAK,EACL,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,CAChC,CAAC;IACF,OAAO,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The tags a view is written in: prose blocks and standing rules, rendered to text and to nothing else. */
|
|
2
|
+
import { type Component } from "./jsx-runtime.js";
|
|
3
|
+
/** One standing rule, on its own line, as a bullet. */
|
|
4
|
+
export declare const Rule: Component;
|
|
5
|
+
/** The rules block: every child on its own line, wrapped so the model can see where it ends. */
|
|
6
|
+
export declare const Rules: Component;
|
|
7
|
+
/** The protocols block: how the agent behaves whatever the state says. */
|
|
8
|
+
export declare const Protocols: Component;
|
|
9
|
+
/** A titled part of the prompt: the title as a heading, then the children as paragraphs. */
|
|
10
|
+
export declare const Section: Component;
|
|
11
|
+
/** A worked example, wrapped so the model reads it as an example and not as an instruction. */
|
|
12
|
+
export declare const Example: Component;
|
|
13
|
+
/** A paragraph, for a view that prefers the component to the lowercase tag. */
|
|
14
|
+
export declare const p: Component;
|
|
15
|
+
/** A body wrapped in the tag the model reads it under, or nothing at all when the body is empty. */
|
|
16
|
+
export declare function tagged(name: string, body: string): string;
|
|
17
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/views/components.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAE5G,OAAO,EAAkD,KAAK,SAAS,EAAc,MAAM,kBAAkB,CAAC;AAE9G,uDAAuD;AACvD,eAAO,MAAM,IAAI,EAAE,SAAkE,CAAC;AAGtF,gGAAgG;AAChG,eAAO,MAAM,KAAK,EAAE,SAAoD,CAAC;AAEzE,0EAA0E;AAC1E,eAAO,MAAM,SAAS,EAAE,SAAwD,CAAC;AAEjF,4FAA4F;AAC5F,eAAO,MAAM,OAAO,EAAE,SAKrB,CAAC;AAEF,+FAA+F;AAC/F,eAAO,MAAM,OAAO,EAAE,SAAuE,CAAC;AAE9F,+EAA+E;AAC/E,eAAO,MAAM,CAAC,EAAE,SAAoD,CAAC;AAGrE,oGAAoG;AACpG,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The tags a view is written in: prose blocks and standing rules, rendered to text and to nothing else. */
|
|
2
|
+
import { blocks, renderInline, renderToText } from "./jsx-runtime.js";
|
|
3
|
+
/** One standing rule, on its own line, as a bullet. */
|
|
4
|
+
export const Rule = (props) => `- ${renderInline(children(props)).trim()}`;
|
|
5
|
+
Rule.inline = true;
|
|
6
|
+
/** The rules block: every child on its own line, wrapped so the model can see where it ends. */
|
|
7
|
+
export const Rules = (props) => tagged("rules", lines(props));
|
|
8
|
+
/** The protocols block: how the agent behaves whatever the state says. */
|
|
9
|
+
export const Protocols = (props) => tagged("protocols", lines(props));
|
|
10
|
+
/** A titled part of the prompt: the title as a heading, then the children as paragraphs. */
|
|
11
|
+
export const Section = (props) => {
|
|
12
|
+
const body = renderToText(children(props));
|
|
13
|
+
const title = String(props["title"] ?? "").trim();
|
|
14
|
+
if (!title)
|
|
15
|
+
return body;
|
|
16
|
+
return body ? `## ${title}\n\n${body}` : `## ${title}`;
|
|
17
|
+
};
|
|
18
|
+
/** A worked example, wrapped so the model reads it as an example and not as an instruction. */
|
|
19
|
+
export const Example = (props) => tagged("example", renderToText(children(props)));
|
|
20
|
+
/** A paragraph, for a view that prefers the component to the lowercase tag. */
|
|
21
|
+
export const p = (props) => renderInline(children(props));
|
|
22
|
+
p.inline = true;
|
|
23
|
+
/** A body wrapped in the tag the model reads it under, or nothing at all when the body is empty. */
|
|
24
|
+
export function tagged(name, body) {
|
|
25
|
+
return body ? `<${name}>\n${body}\n</${name}>` : "";
|
|
26
|
+
}
|
|
27
|
+
function children(props) {
|
|
28
|
+
return (props["children"] ?? null);
|
|
29
|
+
}
|
|
30
|
+
function lines(props) {
|
|
31
|
+
return blocks(children(props)).join("\n");
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/views/components.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAE5G,OAAO,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CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;AAEhB,oGAAoG;AACpG,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,IAAY;IAC/C,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAY;IAC5B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,IAAI,CAAU,CAAC;AAC9C,CAAC;AAED,SAAS,KAAK,CAAC,KAAY;IACzB,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../../src/views/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAI9F,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The dev runtime: the same text factory under the name a dev-mode JSX transform imports. */
|
|
2
|
+
// One re-export and no second implementation: a dev build and a prod build of the same prompt
|
|
3
|
+
// must not be able to differ. `jsxDEV` is already an alias of `jsx` next door.
|
|
4
|
+
export * from "./jsx-runtime.js";
|
|
5
|
+
//# sourceMappingURL=jsx-dev-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-dev-runtime.js","sourceRoot":"","sources":["../../src/views/jsx-dev-runtime.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F,8FAA8F;AAC9F,+EAA+E;AAC/E,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** The JSX runtime: elements become a small tree and the tree renders to TEXT, never to DOM. */
|
|
2
|
+
/** Anything a component may hand back; arrays and falsy values are part of the language. */
|
|
3
|
+
export type Child = Element | string | number | boolean | null | undefined | Child[];
|
|
4
|
+
export type Props = Record<string, unknown>;
|
|
5
|
+
/** A component is a function from props to text — the only kind of tag that carries behaviour. */
|
|
6
|
+
export interface Component {
|
|
7
|
+
(props: Props): Child;
|
|
8
|
+
/** Rendered on one line inside its parent instead of as its own paragraph. */
|
|
9
|
+
inline?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** The whole tree: a tag and its props. `children` lives in props, as the automatic runtime says. */
|
|
12
|
+
export interface Element {
|
|
13
|
+
readonly kind: "element";
|
|
14
|
+
readonly type: string | Component | typeof Fragment;
|
|
15
|
+
readonly props: Props;
|
|
16
|
+
}
|
|
17
|
+
/** The empty tag: `<>…</>` groups siblings without adding anything of its own to the text. */
|
|
18
|
+
export declare const Fragment: unique symbol;
|
|
19
|
+
/** The automatic runtime's element factory; `jsxs` is the same function with many children. */
|
|
20
|
+
export declare function jsx(type: Element["type"], props: Props): Element;
|
|
21
|
+
export { jsx as jsxs, jsx as jsxDEV };
|
|
22
|
+
/**
|
|
23
|
+
* One child rendered inline: strings keep their inner spacing exactly as written, because
|
|
24
|
+
* `{name} tiene cita el {day}` is a sentence whose spaces are the author's.
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderInline(child: Child): string;
|
|
27
|
+
/**
|
|
28
|
+
* One child rendered as a block: siblings become paragraphs separated by one blank line,
|
|
29
|
+
* `null`/`false`/`undefined` render nothing at all, and a bare string is trimmed at its ends.
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderToText(child: Child): string;
|
|
32
|
+
/** Each child as its own block, empties dropped — what a component needs to join them its own way. */
|
|
33
|
+
export declare function blocks(child: Child): string[];
|
|
34
|
+
/** The type-level half of the runtime: what TypeScript looks for behind `jsxImportSource`. */
|
|
35
|
+
type TextElement = Element;
|
|
36
|
+
export declare namespace JSX {
|
|
37
|
+
type Element = TextElement;
|
|
38
|
+
/** A tag is a lowercase intrinsic or any function that returns text — never a class. */
|
|
39
|
+
type ElementType = string | ((props: never) => Child) | Component;
|
|
40
|
+
interface ElementChildrenAttribute {
|
|
41
|
+
children: object;
|
|
42
|
+
}
|
|
43
|
+
interface IntrinsicElements {
|
|
44
|
+
p: {
|
|
45
|
+
children?: Child;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../../src/views/jsx-runtime.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,4FAA4F;AAC5F,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,EAAE,CAAC;AAErF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5C,kGAAkG;AAClG,MAAM,WAAW,SAAS;IACxB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qGAAqG;AACrG,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,QAAQ,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED,8FAA8F;AAC9F,eAAO,MAAM,QAAQ,eAAwC,CAAC;AAE9D,+FAA+F;AAC/F,wBAAgB,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAEhE;AAED,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,CAAC;AAYtC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAEjD;AAED,sGAAsG;AACtG,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CAmB7C;AAED,8FAA8F;AAC9F,KAAK,WAAW,GAAG,OAAO,CAAC;AAE3B,MAAM,CAAC,OAAO,WAAW,GAAG,CAAC;IAC3B,KAAK,OAAO,GAAG,WAAW,CAAC;IAC3B,wFAAwF;IACxF,KAAK,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,GAAG,SAAS,CAAC;IAClE,UAAU,wBAAwB;QAChC,QAAQ,EAAE,MAAM,CAAC;KAClB;IACD,UAAU,iBAAiB;QACzB,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;SAAE,CAAC;KACzB;CACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** The JSX runtime: elements become a small tree and the tree renders to TEXT, never to DOM. */
|
|
2
|
+
/** The empty tag: `<>…</>` groups siblings without adding anything of its own to the text. */
|
|
3
|
+
export const Fragment = Symbol.for("pinecall.views.fragment");
|
|
4
|
+
/** The automatic runtime's element factory; `jsxs` is the same function with many children. */
|
|
5
|
+
export function jsx(type, props) {
|
|
6
|
+
return { kind: "element", type, props: props ?? {} };
|
|
7
|
+
}
|
|
8
|
+
export { jsx as jsxs, jsx as jsxDEV };
|
|
9
|
+
function childrenOf(props) {
|
|
10
|
+
return (props["children"] ?? null);
|
|
11
|
+
}
|
|
12
|
+
// A paragraph is one line of prose: the newlines and indentation JSX left in the source are not
|
|
13
|
+
// content, so they collapse to single spaces, and the whole thing is trimmed at both ends.
|
|
14
|
+
function paragraph(text) {
|
|
15
|
+
return text.replace(/\s*\n\s*/g, " ").replace(/[ \t]{2,}/g, " ").trim();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One child rendered inline: strings keep their inner spacing exactly as written, because
|
|
19
|
+
* `{name} tiene cita el {day}` is a sentence whose spaces are the author's.
|
|
20
|
+
*/
|
|
21
|
+
export function renderInline(child) {
|
|
22
|
+
if (child === null || child === undefined || typeof child === "boolean")
|
|
23
|
+
return "";
|
|
24
|
+
if (typeof child === "string")
|
|
25
|
+
return child;
|
|
26
|
+
if (typeof child === "number")
|
|
27
|
+
return String(child);
|
|
28
|
+
if (Array.isArray(child))
|
|
29
|
+
return child.map(renderInline).join("");
|
|
30
|
+
const { type, props } = child;
|
|
31
|
+
if (typeof type === "function")
|
|
32
|
+
return renderInline(type(props));
|
|
33
|
+
return renderInline(childrenOf(props));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* One child rendered as a block: siblings become paragraphs separated by one blank line,
|
|
37
|
+
* `null`/`false`/`undefined` render nothing at all, and a bare string is trimmed at its ends.
|
|
38
|
+
*/
|
|
39
|
+
export function renderToText(child) {
|
|
40
|
+
return blocks(child).join("\n\n");
|
|
41
|
+
}
|
|
42
|
+
/** Each child as its own block, empties dropped — what a component needs to join them its own way. */
|
|
43
|
+
export function blocks(child) {
|
|
44
|
+
if (child === null || child === undefined || typeof child === "boolean")
|
|
45
|
+
return [];
|
|
46
|
+
if (typeof child === "string")
|
|
47
|
+
return child.trim() ? [child.trim()] : [];
|
|
48
|
+
if (typeof child === "number")
|
|
49
|
+
return [String(child)];
|
|
50
|
+
if (Array.isArray(child))
|
|
51
|
+
return child.flatMap(blocks);
|
|
52
|
+
const { type, props } = child;
|
|
53
|
+
if (typeof type === "function") {
|
|
54
|
+
if (type.inline) {
|
|
55
|
+
const line = paragraph(renderInline(child));
|
|
56
|
+
return line ? [line] : [];
|
|
57
|
+
}
|
|
58
|
+
return blocks(type(props));
|
|
59
|
+
}
|
|
60
|
+
// The one intrinsic tag: `<p>` is a paragraph. Every other lowercase tag is its children.
|
|
61
|
+
if (type === "p") {
|
|
62
|
+
const line = paragraph(renderInline(childrenOf(props)));
|
|
63
|
+
return line ? [line] : [];
|
|
64
|
+
}
|
|
65
|
+
return blocks(childrenOf(props));
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../../src/views/jsx-runtime.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAqBhG,8FAA8F;AAC9F,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE9D,+FAA+F;AAC/F,MAAM,UAAU,GAAG,CAAC,IAAqB,EAAE,KAAY;IACrD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;AACvD,CAAC;AAED,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,GAAG,IAAI,MAAM,EAAE,CAAC;AAEtC,SAAS,UAAU,CAAC,KAAY;IAC9B,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,IAAI,CAAU,CAAC;AAC9C,CAAC;AAED,gGAAgG;AAChG,2FAA2F;AAC3F,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAY;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACnF,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAA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IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,0FAA0F;IAC1F,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The framework's own words: the standing rules and the protocols, in the agent's `language`. */
|
|
2
|
+
/** The two blocks the framework contributes to every prompt, in one language. */
|
|
3
|
+
export interface Words {
|
|
4
|
+
rules: string;
|
|
5
|
+
protocols: string;
|
|
6
|
+
}
|
|
7
|
+
/** The default language, and the one an unknown `language` falls back to. */
|
|
8
|
+
export declare const DEFAULT_LANGUAGE = "es";
|
|
9
|
+
/**
|
|
10
|
+
* The framework's words for this agent: `language` is a config field, so it is read off the
|
|
11
|
+
* instance and never off the state. A language we do not speak yet falls back to the default
|
|
12
|
+
* rather than leaving the model with no rules at all.
|
|
13
|
+
*/
|
|
14
|
+
export declare function wordsFor(agent: object): Words;
|
|
15
|
+
/** The languages the framework has words for, for a test that wants to walk them all. */
|
|
16
|
+
export declare function languages(): string[];
|
|
17
|
+
//# sourceMappingURL=lang.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../src/views/lang.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAElG,iFAAiF;AACjF,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AA+BD,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAI7C;AAED,yFAAyF;AACzF,wBAAgB,SAAS,IAAI,MAAM,EAAE,CAEpC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** The framework's own words: the standing rules and the protocols, in the agent's `language`. */
|
|
2
|
+
// These are the framework's words, identical for every agent and every turn of a call, which is
|
|
3
|
+
// exactly why they belong in the cached region — and why they are a table and not a template.
|
|
4
|
+
const WORDS = {
|
|
5
|
+
es: {
|
|
6
|
+
rules: [
|
|
7
|
+
"- No inventes ningún dato: lo que no salga de una herramienta o del conocimiento, no lo digas.",
|
|
8
|
+
"- Una sola pregunta por turno, y espera la respuesta.",
|
|
9
|
+
"- Habla como una persona al teléfono: frases cortas, sin listas ni markdown.",
|
|
10
|
+
].join("\n"),
|
|
11
|
+
protocols: [
|
|
12
|
+
"- Para actuar usa una herramienta; decir que has hecho algo no lo hace.",
|
|
13
|
+
"- Antes de una acción irreversible lee en voz alta lo que vas a hacer y espera un sí explícito.",
|
|
14
|
+
"- Si no puedes resolverlo, dilo y ofrece pasar con una persona.",
|
|
15
|
+
].join("\n"),
|
|
16
|
+
},
|
|
17
|
+
en: {
|
|
18
|
+
rules: [
|
|
19
|
+
"- Invent nothing: if it did not come from a tool or from the knowledge, do not say it.",
|
|
20
|
+
"- One question per turn, and wait for the answer.",
|
|
21
|
+
"- Talk like a person on the phone: short sentences, no lists, no markdown.",
|
|
22
|
+
].join("\n"),
|
|
23
|
+
protocols: [
|
|
24
|
+
"- To act, call a tool; saying you have done something does not do it.",
|
|
25
|
+
"- Before an irreversible action read back what you are about to do and wait for an explicit yes.",
|
|
26
|
+
"- If you cannot solve it, say so and offer to hand over to a person.",
|
|
27
|
+
].join("\n"),
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
/** The default language, and the one an unknown `language` falls back to. */
|
|
31
|
+
export const DEFAULT_LANGUAGE = "es";
|
|
32
|
+
/**
|
|
33
|
+
* The framework's words for this agent: `language` is a config field, so it is read off the
|
|
34
|
+
* instance and never off the state. A language we do not speak yet falls back to the default
|
|
35
|
+
* rather than leaving the model with no rules at all.
|
|
36
|
+
*/
|
|
37
|
+
export function wordsFor(agent) {
|
|
38
|
+
const configured = agent.language;
|
|
39
|
+
const code = (configured ?? DEFAULT_LANGUAGE).toLowerCase().split(/[-_]/)[0] ?? DEFAULT_LANGUAGE;
|
|
40
|
+
return WORDS[code] ?? WORDS[DEFAULT_LANGUAGE];
|
|
41
|
+
}
|
|
42
|
+
/** The languages the framework has words for, for a test that wants to walk them all. */
|
|
43
|
+
export function languages() {
|
|
44
|
+
return Object.keys(WORDS);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/views/lang.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAQlG,gGAAgG;AAChG,8FAA8F;AAC9F,MAAM,KAAK,GAA0B;IACnC,EAAE,EAAE;QACF,KAAK,EAAE;YACL,gGAAgG;YAChG,uDAAuD;YACvD,8EAA8E;SAC/E,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,SAAS,EAAE;YACT,yEAAyE;YACzE,iGAAiG;YACjG,iEAAiE;SAClE,CAAC,IAAI,CAAC,IAAI,CAAC;KACb;IACD,EAAE,EAAE;QACF,KAAK,EAAE;YACL,wFAAwF;YACxF,mDAAmD;YACnD,4EAA4E;SAC7E,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,SAAS,EAAE;YACT,uEAAuE;YACvE,kGAAkG;YAClG,sEAAsE;SACvE,CAAC,IAAI,CAAC,IAAI,CAAC;KACb;CACF,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,UAAU,GAAI,KAA+B,CAAC,QAAQ,CAAC;IAC7D,MAAM,IAAI,GAAG,CAAC,UAAU,IAAI,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAgB,CAAC;IACjG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAE,CAAC;AACjD,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,SAAS;IACvB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The prompt as named blocks in two regions, in the one order they are sent: static · the history · dynamic. */
|
|
2
|
+
import type { PromptBlockSpec } from "@pinecall/protocol";
|
|
3
|
+
import { type Agent } from "../agent/agent.js";
|
|
4
|
+
/** One block of the prompt as this render produced it: its name, its region, and its text. */
|
|
5
|
+
export interface Block extends PromptBlockSpec {
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
/** The prompt, cut where the cache is cut: only a `dynamic` block may differ between two turns. */
|
|
9
|
+
export interface Blocks {
|
|
10
|
+
/** Every block, in send order: the static ones, then — after the history — the dynamic one. */
|
|
11
|
+
blocks: Block[];
|
|
12
|
+
/** The history is the runtime's. This is only what a `collapse()` left in it, for the printed page. */
|
|
13
|
+
history: string;
|
|
14
|
+
}
|
|
15
|
+
/** Every block of the prompt, by name and region, in the one order they are sent. */
|
|
16
|
+
export declare const PROMPT_BLOCKS: readonly PromptBlockSpec[];
|
|
17
|
+
/** The whole prompt, block by block in send order: this is what `promptOf(agent)` is. */
|
|
18
|
+
export declare function layout(agent: Agent): Blocks;
|
|
19
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/views/layout.ts"],"names":[],"mappings":"AAAA,iHAAiH;AAEjH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAW,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAMxD,8FAA8F;AAC9F,MAAM,WAAW,KAAM,SAAQ,eAAe;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,mGAAmG;AACnG,MAAM,WAAW,MAAM;IACrB,+FAA+F;IAC/F,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,uGAAuG;IACvG,OAAO,EAAE,MAAM,CAAC;CACjB;AAkBD,qFAAqF;AACrF,eAAO,MAAM,aAAa,EAAE,SAAS,eAAe,EAAyD,CAAC;AAE9G,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAG3C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** The prompt as named blocks in two regions, in the one order they are sent: static · the history · dynamic. */
|
|
2
|
+
import { changes } from "../agent/agent.js";
|
|
3
|
+
import { docOf, toolsOf } from "../agent/tools.js";
|
|
4
|
+
import { tagged } from "./components.js";
|
|
5
|
+
import { wordsFor } from "./lang.js";
|
|
6
|
+
import { renderToText } from "./jsx-runtime.js";
|
|
7
|
+
// The whole prompt, in the one order it is sent, each block beside whoever writes it. Everything
|
|
8
|
+
// the class says about itself is static and cached; the view is the whole dynamic region and the
|
|
9
|
+
// LAST thing the model reads, so what the state says about this turn is never buried under the
|
|
10
|
+
// history. The layout is the framework's: a class contributes the view and nothing else.
|
|
11
|
+
const BLOCKS = [
|
|
12
|
+
{ name: "identity", region: "static", text: identityBlock },
|
|
13
|
+
// The knowledge file travels whole in the declaration — `runtime/grounding.ts` reads it beside
|
|
14
|
+
// the class and sends `{path, text}` — and the runtime writes its text into this block, once per
|
|
15
|
+
// call, where it is the operator's own words in the cached prefix. The app sends nothing for it:
|
|
16
|
+
// this package never opens the file on a render, and the same file twice is a worse bug than an
|
|
17
|
+
// empty block.
|
|
18
|
+
{ name: "knowledge", region: "static", text: () => "" },
|
|
19
|
+
{ name: "tools", region: "static", text: toolsBlock },
|
|
20
|
+
{ name: "view", region: "dynamic", text: viewBlock },
|
|
21
|
+
];
|
|
22
|
+
/** Every block of the prompt, by name and region, in the one order they are sent. */
|
|
23
|
+
export const PROMPT_BLOCKS = BLOCKS.map(({ name, region }) => ({ name, region }));
|
|
24
|
+
/** The whole prompt, block by block in send order: this is what `promptOf(agent)` is. */
|
|
25
|
+
export function layout(agent) {
|
|
26
|
+
const blocks = BLOCKS.map(({ name, region, text }) => ({ name, region, text: text(agent) }));
|
|
27
|
+
return { blocks, history: collapsedHistory(agent) };
|
|
28
|
+
}
|
|
29
|
+
/** Who the agent is: the class docstring, the standing rules and the protocols. Cached; reads no state. */
|
|
30
|
+
function identityBlock(agent) {
|
|
31
|
+
const words = wordsFor(agent);
|
|
32
|
+
return paragraphs([docOf(agent) ?? "", tagged("rules", words.rules), tagged("protocols", words.protocols)]);
|
|
33
|
+
}
|
|
34
|
+
// Every tool the class declares, visible right now or not: see docs/decisions/views.md. The model
|
|
35
|
+
// reads the docstring, never the JSON schema — the schema is what the wire carries.
|
|
36
|
+
function toolsBlock(agent) {
|
|
37
|
+
const docs = toolsOf(agent)
|
|
38
|
+
.map((declared) => `- ${declared.name}: ${declared.spec.description}`)
|
|
39
|
+
.join("\n");
|
|
40
|
+
return tagged("tools", docs);
|
|
41
|
+
}
|
|
42
|
+
// The view: what the class's own `render()` says about this turn, and nothing else. All of it is
|
|
43
|
+
// the tenant's words, which is why nothing that came from outside the conversation is spliced into
|
|
44
|
+
// it — a recalled fact and a retrieved chunk reach the model as tool results, where they belong
|
|
45
|
+
// (the runtime's docs/security/prompt-injection.md).
|
|
46
|
+
function viewBlock(agent) {
|
|
47
|
+
return renderToText(agent.render());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What the framework knows of the history: the runtime owns the turns, so this is only the
|
|
51
|
+
* summaries a `collapse()` left where a stretch of the call used to be.
|
|
52
|
+
*/
|
|
53
|
+
function collapsedHistory(agent) {
|
|
54
|
+
return changes(agent)
|
|
55
|
+
.filter((change) => change.field === "@summary")
|
|
56
|
+
.map((change) => String(change.next))
|
|
57
|
+
.join("\n\n");
|
|
58
|
+
}
|
|
59
|
+
function paragraphs(parts) {
|
|
60
|
+
return parts.filter((part) => part.trim()).join("\n\n");
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/views/layout.ts"],"names":[],"mappings":"AAAA,iHAAiH;AAIjH,OAAO,EAAE,OAAO,EAAc,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAehD,iGAAiG;AACjG,iGAAiG;AACjG,+FAA+F;AAC/F,yFAAyF;AACzF,MAAM,MAAM,GAAG;IACb,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE;IAC3D,+FAA+F;IAC/F,iGAAiG;IACjG,iGAAiG;IACjG,gGAAgG;IAChG,eAAe;IACf,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;IACvD,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE;IACrD,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;CACgC,CAAC;A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