@wenathlan/devthink 2.0.12 → 2.0.14
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/CHANGELOG.md +20 -0
- package/accounts.ts +2087 -0
- package/agent.ts +2331 -0
- package/antigravity.ts +2139 -0
- package/apifreeze.ts +4146 -0
- package/auth.ts +642 -0
- package/background.ts +16837 -0
- package/bridge.ts +2080 -0
- package/build.ts +54 -0
- package/bun.ts +26 -0
- package/capture.ts +1614 -0
- package/checksecrets.ts +72 -0
- package/cjs.ts +9 -0
- package/cli.ts +3500 -0
- package/commands.ts +1101 -0
- package/companion.ts +450 -0
- package/compatibility.ts +37 -0
- package/config.ts +3137 -0
- package/constants.ts +943 -0
- package/core.ts +1473 -0
- package/crossbrowser.ts +1359 -0
- package/dashdone.ts +605 -0
- package/data.ts +943 -0
- package/database.ts +133 -0
- package/debug.ts +850 -0
- package/deno.ts +27 -0
- package/devthink.ts +707 -0
- package/dist/accounts.d.ts +409 -0
- package/dist/agent.d.ts +837 -0
- package/dist/antigravity.d.ts +380 -0
- package/dist/apifreeze.d.ts +113 -0
- package/dist/auth.d.ts +224 -0
- package/{bridge.d.ts → dist/bridge.d.ts} +1 -1
- package/dist/capture.d.ts +595 -0
- package/dist/cjs.d.ts +6 -0
- package/{cli.js → dist/cli.js} +2 -2
- package/dist/commands.d.ts +310 -0
- package/dist/compatibility.d.ts +17 -0
- package/dist/config.d.ts +1853 -0
- package/dist/constants.d.ts +637 -0
- package/dist/core.d.ts +361 -0
- package/dist/data.d.ts +330 -0
- package/dist/database.d.ts +24 -0
- package/dist/debug.d.ts +270 -0
- package/dist/engine.d.ts +74 -0
- package/dist/environments.d.ts +244 -0
- package/dist/evidence.d.ts +277 -0
- package/dist/export.d.ts +311 -0
- package/dist/fingerprint.d.ts +594 -0
- package/dist/flow.d.ts +300 -0
- package/dist/gates.d.ts +103 -0
- package/dist/identity.d.ts +51 -0
- package/dist/ids.d.ts +7 -0
- package/dist/llm.d.ts +652 -0
- package/dist/models.d.ts +1807 -0
- package/dist/net.d.ts +325 -0
- package/dist/neutral.d.ts +41 -0
- package/dist/oauth.d.ts +703 -0
- package/dist/page.d.ts +1166 -0
- package/dist/perf.d.ts +481 -0
- package/dist/plan.d.ts +134 -0
- package/dist/project.d.ts +395 -0
- package/dist/providers.d.ts +37 -0
- package/dist/quota.d.ts +453 -0
- package/dist/recovery.d.ts +621 -0
- package/dist/request.d.ts +1492 -0
- package/dist/run.d.ts +779 -0
- package/dist/runtime.d.ts +212 -0
- package/dist/search.d.ts +375 -0
- package/dist/security.d.ts +534 -0
- package/dist/serve.d.ts +136 -0
- package/dist/session.d.ts +296 -0
- package/dist/storage.d.ts +53 -0
- package/dist/streaming.d.ts +1119 -0
- package/dist/swarm.d.ts +328 -0
- package/dist/tools.d.ts +170 -0
- package/dist/types.d.ts +8357 -0
- package/dist/utils.d.ts +82 -0
- package/dist/version.d.ts +7 -0
- package/dist/versionregistry.d.ts +406 -0
- package/dist/views.d.ts +579 -0
- package/dist/workbenchsession.d.ts +69 -0
- package/dist/workflow.d.ts +649 -0
- package/docs/readme.md +92 -0
- package/docs/schemas/antigravity.json +192 -0
- package/engine.ts +1524 -0
- package/environments.ts +1005 -0
- package/evidence.ts +643 -0
- package/export.ts +889 -0
- package/fingerprint.ts +1458 -0
- package/flow.ts +1190 -0
- package/gates.ts +307 -0
- package/gateway.ts +34 -0
- package/hardening.ts +191 -0
- package/headless.ts +369 -0
- package/http.ts +2110 -0
- package/identity.ts +246 -0
- package/ids.ts +26 -0
- package/index.ts +369 -0
- package/llm.ts +2682 -0
- package/mcp.ts +1835 -0
- package/{memory.js → memory.ts} +3834 -2310
- package/models.ts +3805 -0
- package/modes.ts +43 -0
- package/net.ts +1214 -0
- package/neutral.ts +362 -0
- package/node.ts +26 -0
- package/oauth.ts +2216 -0
- package/offscreen.ts +170 -0
- package/pack.ts +956 -0
- package/package.json +175 -82
- package/page.ts +7824 -0
- package/pagebridge.ts +1116 -0
- package/perf.ts +957 -0
- package/plan.ts +672 -0
- package/plugin.ts +76 -0
- package/{policy.js → policy.ts} +5073 -4679
- package/prisma.config.ts +27 -0
- package/progress.ts +1308 -0
- package/project.ts +1291 -0
- package/protocol.ts +4187 -0
- package/providers.ts +246 -0
- package/quota.ts +1887 -0
- package/recovery.ts +2433 -0
- package/request.ts +4482 -0
- package/run.ts +2135 -0
- package/runtime.ts +526 -0
- package/search.ts +1760 -0
- package/security.ts +1673 -0
- package/serve.ts +419 -0
- package/server.ts +5538 -0
- package/session.ts +1162 -0
- package/storage.ts +182 -0
- package/streaming.ts +4101 -0
- package/swarm.ts +884 -0
- package/sync.ts +56 -0
- package/tests/agentcert.test.ts +128 -0
- package/tests/agentfleet.test.ts +214 -0
- package/tests/agentreview.test.ts +241 -0
- package/tests/agentstream.test.ts +335 -0
- package/tests/agentwork.test.ts +356 -0
- package/tests/apifreeze.test.ts +290 -0
- package/tests/apimap.test.ts +112 -0
- package/tests/approvalgate.test.ts +175 -0
- package/tests/artifactmanifest.test.ts +204 -0
- package/tests/attentionfeed.test.ts +163 -0
- package/tests/backgroundruns.test.ts +100 -0
- package/tests/batchscheduling.test.ts +131 -0
- package/tests/blackboard.test.ts +238 -0
- package/tests/bridge.test.ts +1088 -0
- package/tests/browsercoverage.test.ts +134 -0
- package/tests/browserpolyfills.test.ts +124 -0
- package/tests/build.mjs +1260 -0
- package/tests/clientauth.test.ts +223 -0
- package/tests/clitools.test.ts +578 -0
- package/tests/confirmgates.test.ts +190 -0
- package/tests/containerpack.test.ts +143 -0
- package/tests/controlflow.test.ts +2120 -0
- package/tests/coordination.test.ts +345 -0
- package/tests/copyscreen.test.ts +139 -0
- package/tests/core.test.ts +417 -0
- package/tests/costcert.test.ts +95 -0
- package/tests/crossbrowser.test.ts +115 -0
- package/tests/cspaudit.test.ts +79 -0
- package/tests/dashdone.test.ts +615 -0
- package/tests/datagrid.test.ts +137 -0
- package/tests/doccheck.test.ts +107 -0
- package/tests/dombatch.test.ts +109 -0
- package/tests/emulation.test.ts +282 -0
- package/tests/environments.test.ts +259 -0
- package/tests/evidenceviews.test.ts +88 -0
- package/tests/exporttools.test.ts +185 -0
- package/tests/firefoxprep.test.ts +134 -0
- package/tests/flowlibrary.test.ts +242 -0
- package/tests/flowrun.test.ts +303 -0
- package/tests/forensics.test.ts +439 -0
- package/tests/gateway.test.ts +939 -0
- package/tests/headlesslib.test.ts +171 -0
- package/tests/httpstream.test.ts +277 -0
- package/tests/immutablelog.test.ts +157 -0
- package/tests/inboundguard.test.ts +177 -0
- package/tests/lazyload.test.ts +72 -0
- package/tests/librarymodes.test.ts +623 -0
- package/tests/llm.test.ts +696 -0
- package/tests/manifest.test.ts +226 -0
- package/tests/maskinputs.test.ts +150 -0
- package/tests/matrixverify.test.ts +111 -0
- package/tests/mavenpack.test.ts +75 -0
- package/tests/mcpserver.test.ts +704 -0
- package/tests/memory.test.ts +4155 -0
- package/tests/memorycare.test.ts +230 -0
- package/tests/migrateplan.test.ts +349 -0
- package/tests/minimization.test.ts +414 -0
- package/tests/modelroute.test.ts +112 -0
- package/tests/multiagent.test.ts +440 -0
- package/tests/nativebridge.test.ts +807 -0
- package/tests/navigation.test.ts +284 -0
- package/tests/nugetpack.test.ts +83 -0
- package/tests/orchestration.test.ts +449 -0
- package/tests/originpolicy.test.ts +405 -0
- package/tests/outputcompare.test.ts +97 -0
- package/tests/package.test.ts +91 -0
- package/tests/pagebridge.test.ts +5909 -0
- package/tests/pentest.test.ts +75 -0
- package/tests/perfrecords.test.ts +257 -0
- package/tests/permdiff.test.ts +85 -0
- package/tests/phishguard.test.ts +128 -0
- package/tests/pickerviews.test.ts +155 -0
- package/tests/pipelines.test.ts +381 -0
- package/tests/planlint.test.ts +240 -0
- package/tests/planreview.test.ts +383 -0
- package/tests/platformtargets.test.ts +56 -0
- package/tests/policy.test.ts +8284 -0
- package/tests/portability.test.ts +96 -0
- package/tests/progress.test.ts +1036 -0
- package/tests/promptlibrary.test.ts +116 -0
- package/tests/protocol.test.ts +4793 -0
- package/tests/publishingpipeline.test.ts +314 -0
- package/tests/quickactions.test.ts +164 -0
- package/tests/readiness.test.ts +78 -0
- package/tests/recipes.test.ts +163 -0
- package/tests/redactshots.test.ts +216 -0
- package/tests/registernvidiakeys.ts +51 -0
- package/tests/relayserve.test.ts +304 -0
- package/tests/releasenotes.test.ts +276 -0
- package/tests/resilience.test.ts +467 -0
- package/tests/resourceaware.test.ts +187 -0
- package/tests/runbudget.test.ts +125 -0
- package/tests/runhistory.test.ts +299 -0
- package/tests/runreplay.test.ts +113 -0
- package/tests/runresume.test.ts +184 -0
- package/tests/runstate.test.ts +288 -0
- package/tests/runtimeadapters.test.ts +251 -0
- package/tests/safariskeleton.test.ts +115 -0
- package/tests/sandboxframe.test.ts +196 -0
- package/tests/sbom.test.ts +105 -0
- package/tests/secretvault.test.ts +188 -0
- package/tests/selcache.test.ts +111 -0
- package/tests/sessioninterface.test.ts +791 -0
- package/tests/sessions.test.ts +591 -0
- package/tests/siteprefs.test.ts +228 -0
- package/tests/snapshotdelta.test.ts +165 -0
- package/tests/statusviews.test.ts +237 -0
- package/tests/stepmeter.test.ts +200 -0
- package/tests/streamparse.test.ts +163 -0
- package/tests/stylepruning.test.ts +90 -0
- package/tests/surfaces.test.ts +282 -0
- package/tests/sweep.test.ts +78 -0
- package/tests/syncbridge.test.ts +164 -0
- package/tests/taskqueue.test.ts +206 -0
- package/tests/toolcalls.test.ts +336 -0
- package/tests/toolcatalog.test.ts +201 -0
- package/tests/torture-agent.test.ts +706 -0
- package/tests/torture-auth.test.ts +461 -0
- package/tests/torture-commands.test.ts +895 -0
- package/tests/torture-data.test.ts +923 -0
- package/tests/torture-environments.test.ts +285 -0
- package/tests/torture-export.test.ts +263 -0
- package/tests/torture-http.test.ts +1379 -0
- package/tests/torture-llm.test.ts +808 -0
- package/tests/torture-memory.test.ts +1084 -0
- package/tests/torture-plan.test.ts +829 -0
- package/tests/torture-run.test.ts +626 -0
- package/tests/torture-session.test.ts +928 -0
- package/tests/torture-swarm.test.ts +1245 -0
- package/tests/torture-tools.test.ts +964 -0
- package/tests/torture-workflow.test.ts +2354 -0
- package/tests/tourviews.test.ts +52 -0
- package/tests/transparency.test.ts +147 -0
- package/tests/trigger.test.ts +941 -0
- package/tests/v1sunset.test.ts +428 -0
- package/tests/virtlist.test.ts +94 -0
- package/tests/vision.test.ts +540 -0
- package/tests/vsixpack.test.ts +145 -0
- package/tests/webapi.test.ts +523 -0
- package/tests/workflow.test.ts +1785 -0
- package/tests/workfloweditor.test.ts +759 -0
- package/tests/xpipack.test.ts +128 -0
- package/tools.ts +734 -0
- package/types.ts +9908 -0
- package/umd.ts +9 -0
- package/utils.ts +249 -0
- package/version.ts +8 -0
- package/versionregistry.ts +1310 -0
- package/views.ts +2153 -0
- package/vitest.config.ts +12 -0
- package/web/App.tsx +78 -0
- package/web/README.md +47 -0
- package/web/capacitor.config.ts +46 -0
- package/web/const.ts +19 -0
- package/web/control.shell.tsx +66 -0
- package/web/dashboardpage.ts +554 -0
- package/web/db.ts +493 -0
- package/web/design.html +541 -0
- package/web/gatewayview/Gateway.tsx +345 -0
- package/web/gatewayview/config.ts +1042 -0
- package/web/gatewayview/definition.ts +174 -0
- package/web/icons.ts +15 -0
- package/{manifest.json → web/manifest.json} +1 -1
- package/web/optionspage.ts +691 -0
- package/web/popup.ts +1651 -0
- package/web/schema.prisma +176 -0
- package/web/sidepanel.ts +7941 -0
- package/web/sitemanifest.json +13 -0
- package/web/terminal-ui.tsx +622 -0
- package/web/transparencypage.ts +541 -0
- package/web/vite.config.ts +39 -0
- package/web/workspace.ts +23 -0
- package/workbenchmemory.ts +104 -0
- package/workbenchsession.ts +304 -0
- package/workflow.ts +4495 -0
- package/bridge.d.ts.map +0 -1
- package/bridge.js +0 -1877
- package/bun.d.ts.map +0 -1
- package/bun.js +0 -52329
- package/caps/background.json +0 -712
- package/caps/cli.json +0 -360
- package/caps/library.json +0 -3611
- package/caps/mcp.json +0 -126
- package/caps/pagebridge.json +0 -377
- package/caps/popup.json +0 -51
- package/caps/sidepanel.json +0 -522
- package/checksums.txt +0 -142
- package/cli.d.ts.map +0 -1
- package/companion.d.ts.map +0 -1
- package/companion.js +0 -389
- package/crossbrowser.d.ts.map +0 -1
- package/crossbrowser.js +0 -1191
- package/dashdone.d.ts.map +0 -1
- package/dashdone.js +0 -368
- package/deno.d.ts.map +0 -1
- package/deno.js +0 -52325
- package/devthink.umd.js +0 -52346
- package/fixtures/bun.ts +0 -7
- package/fixtures/cjs.js +0 -6
- package/fixtures/deno.ts +0 -6
- package/fixtures/example-org-pagestate.json +0 -22
- package/fixtures/importers/automa-workflow.json +0 -18
- package/fixtures/importers/selenium-side.json +0 -20
- package/fixtures/importers/tabular-plan.csv +0 -7
- package/fixtures/importers/uivision-macro.json +0 -10
- package/fixtures/importers/v1-plan.json +0 -13
- package/fixtures/mcp-client.mjs +0 -14
- package/fixtures/pages/checkout.html +0 -192
- package/fixtures/pages/dashboard.html +0 -110
- package/fixtures/pages/feed.html +0 -113
- package/fixtures/pages/product-grid.html +0 -150
- package/fixtures/plans/form-inventory-plan.json +0 -11
- package/fixtures/plans/release-notes-plan.json +0 -11
- package/fixtures/recipes/agentscompete.json +0 -11
- package/fixtures/recipes/agentsforms.json +0 -11
- package/fixtures/recipes/agentsmonitor.json +0 -11
- package/fixtures/recipes/agentsreview.json +0 -29
- package/fixtures/recipes/agentswarm.json +0 -11
- package/fixtures/recipes/fillcalendar.json +0 -12
- package/fixtures/recipes/fillcheckout.json +0 -13
- package/fixtures/recipes/filldependentdropdowns.json +0 -12
- package/fixtures/recipes/fillfromcsv.json +0 -13
- package/fixtures/recipes/fillloginform.json +0 -12
- package/fixtures/recipes/fillmultistepwizard.json +0 -13
- package/fixtures/recipes/fillregistration.json +0 -12
- package/fixtures/recipes/fillsearchfilters.json +0 -12
- package/fixtures/recipes/filltypeahead.json +0 -11
- package/fixtures/recipes/monitoralerts.json +0 -12
- package/fixtures/recipes/monitoravailability.json +0 -11
- package/fixtures/recipes/monitornetworkquiet.json +0 -12
- package/fixtures/recipes/monitorpagechanges.json +0 -11
- package/fixtures/recipes/monitorpricechange.json +0 -11
- package/fixtures/recipes/monitorschedule.json +0 -12
- package/fixtures/recipes/scrapedynamicprices.json +0 -13
- package/fixtures/recipes/scrapeimagegallery.json +0 -12
- package/fixtures/recipes/scrapeinfinitefeed.json +0 -13
- package/fixtures/recipes/scrapenestedlists.json +0 -12
- package/fixtures/recipes/scrapeproductgrid.json +0 -12
- package/fixtures/recipes/scrapereviews.json +0 -12
- package/fixtures/recipes/scrapesearchresults.json +0 -12
- package/fixtures/recipes/scrapetablepagination.json +0 -12
- package/fixtures/recipes/testaccessibility.json +0 -34
- package/fixtures/recipes/testconsoleerrors.json +0 -12
- package/fixtures/recipes/testdeeplinks.json +0 -12
- package/fixtures/recipes/testformvalidation.json +0 -13
- package/fixtures/recipes/testlayoutshift.json +0 -12
- package/fixtures/recipes/testlinkcheck.json +0 -12
- package/fixtures/recipes/testloadtiming.json +0 -12
- package/fixtures/recipes/testvisualdiff.json +0 -12
- package/fixtures/workflows/changelog-digest-workflow.json +0 -13
- package/fixtures/workflows/form-survey-workflow.json +0 -13
- package/gallery.json +0 -706
- package/hardening.d.ts.map +0 -1
- package/hardening.js +0 -188
- package/headless.d.ts.map +0 -1
- package/headless.js +0 -11522
- package/http.d.ts.map +0 -1
- package/http.js +0 -2165
- package/index.cjs +0 -54682
- package/index.d.ts.map +0 -1
- package/index.js +0 -52310
- package/index.neutral.js +0 -46343
- package/mcp.d.ts.map +0 -1
- package/mcp.js +0 -20515
- package/memory.d.ts.map +0 -1
- package/nativehost.template.json +0 -10
- package/node.cjs +0 -54686
- package/node.d.ts.map +0 -1
- package/pack.d.ts.map +0 -1
- package/pack.js +0 -805
- package/policy.d.ts.map +0 -1
- package/progress.d.ts.map +0 -1
- package/progress.js +0 -645
- package/protocol.d.ts.map +0 -1
- package/protocol.js +0 -8334
- package/schemas/audit.schema.json +0 -226
- package/schemas/capability.schema.json +0 -113
- package/schemas/envelope.schema.json +0 -162
- package/schemas/memory.schema.json +0 -51
- package/schemas/observation.schema.json +0 -113
- package/schemas/plan.schema.json +0 -208
- package/schemas/progress.schema.json +0 -126
- package/schemas/proposal.schema.json +0 -68
- package/schemas/session.schema.json +0 -82
- package/schemas/tool.schema.json +0 -94
- package/server.d.ts.map +0 -1
- package/server.js +0 -28877
- package/umd-example.html +0 -18
- package/umd.d.ts.map +0 -1
- /package/{bun.d.ts → dist/bun.d.ts} +0 -0
- /package/{cli.d.ts → dist/cli.d.ts} +0 -0
- /package/{companion.d.ts → dist/companion.d.ts} +0 -0
- /package/{crossbrowser.d.ts → dist/crossbrowser.d.ts} +0 -0
- /package/{dashdone.d.ts → dist/dashdone.d.ts} +0 -0
- /package/{deno.d.ts → dist/deno.d.ts} +0 -0
- /package/{hardening.d.ts → dist/hardening.d.ts} +0 -0
- /package/{headless.d.ts → dist/headless.d.ts} +0 -0
- /package/{http.d.ts → dist/http.d.ts} +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{mcp.d.ts → dist/mcp.d.ts} +0 -0
- /package/{memory.d.ts → dist/memory.d.ts} +0 -0
- /package/{node.d.ts → dist/node.d.ts} +0 -0
- /package/{pack.d.ts → dist/pack.d.ts} +0 -0
- /package/{policy.d.ts → dist/policy.d.ts} +0 -0
- /package/{progress.d.ts → dist/progress.d.ts} +0 -0
- /package/{protocol.d.ts → dist/protocol.d.ts} +0 -0
- /package/{server.d.ts → dist/server.d.ts} +0 -0
- /package/{umd.d.ts → dist/umd.d.ts} +0 -0
package/dist/llm.d.ts
ADDED
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The llm module of the 1.1.90 consolidation: every correlated variation of the model routing and prompt library logic interned in this one file, so the module family carries one surface without duplicate variations.
|
|
3
|
+
* The correlation is the llm family: llm holds the model call core of the 1.1.57 family (the shaped request building, the provider call through the transport seam, the local model path, the stream delta parsing, the command guard with intent classification and plan drafting, the replan on fail, the step reflection, the guardrail stripping, the parse output guard, the tool briefs and the usage accounting with its budget check); modelroute holds the routing table that resolves one request to its provider with fallback routes, provider marks and revision bumps; and promptlibrary holds the template library with its variables, rendering, saving, search and removal.
|
|
4
|
+
* No provider, key or template is ever hardcoded: every route and prompt stays the user's choice, and no model call ever bypasses the consent gates.
|
|
5
|
+
*/
|
|
6
|
+
import type { apikeyref, baseurlconfig, commandparse, costbudget, costestimate, gatewaychatstate, gatewaychattoken, gatewayerror, gatewaykind, gatewaymodelinfo, intentkind, localmodelconfig, modelcacherecord, modelmessage, modeloutput, modelroute, parseguard, plandraft, policyevaluation, prompttemplate, providerconfig, protocolstyle, reflectnote, replanrecord, secretvaultentry, tokenstream, toolbrief, tooldef, usagerecord } from "./types.js";
|
|
7
|
+
import { type fetchtransport } from "./http.js";
|
|
8
|
+
/**
|
|
9
|
+
* Llm integration logics of the 1.1.57 family.
|
|
10
|
+
* Every provider call concern lives in this file: the request shaping for the four protocol styles the user picks (the openai compatible chat completions shape, the openai responses shape, the anthropic messages shape and the google gemini shape — wire shapes for interoperability, never provider names), the response parsing per style, the completion call through the established fetch machinery with its reviewed retries and backoff, the local model calls that never leave the machine, the streaming token parse per style, the natural language command parsing with intent classification, the goal to plan drafting with the grammar lint, the replan of failed runs, the per step reflection with its running lessons, the openapi style tool briefs for model consumption, the parse guardrails that strip code fences and chatter, validate model text against the expected schema, retry malformed output and refuse after exhaustion, and the usage records with cost budget halts.
|
|
11
|
+
* Nothing is hardcoded: no endpoint, no model name, no key, no temperature and no token ceiling ever leaves the user configuration, page content never joins a call the user has not granted and every model drafted plan still passes the same human review.
|
|
12
|
+
*/
|
|
13
|
+
/** The refusal markers reviewed by default; user configured markers always win and an empty configured list disables the marker scan. */
|
|
14
|
+
export declare const defaultrefusalmarkers: string[];
|
|
15
|
+
/** One shaped model request: the url, the method, the headers and the body text per protocol style. */
|
|
16
|
+
export interface shapedrequest {
|
|
17
|
+
url: string;
|
|
18
|
+
method: string;
|
|
19
|
+
headers: Record<string, string>;
|
|
20
|
+
body: string;
|
|
21
|
+
}
|
|
22
|
+
/** The usage a completion answer reports: prompt, completion and total token counts. */
|
|
23
|
+
export interface modelusage {
|
|
24
|
+
prompttokens: number;
|
|
25
|
+
completiontokens: number;
|
|
26
|
+
totaltokens: number;
|
|
27
|
+
}
|
|
28
|
+
/** Builds the completion request of one protocol style: the endpoint url, the headers with the key placed where the style expects it and the body envelope the style speaks. The user configured headers merge over the shape headers so any gateway works. */
|
|
29
|
+
export declare function buildrequest(input: {
|
|
30
|
+
provider: {
|
|
31
|
+
endpoint: string;
|
|
32
|
+
style: protocolstyle;
|
|
33
|
+
headers?: Record<string, string>;
|
|
34
|
+
};
|
|
35
|
+
model: string;
|
|
36
|
+
messages: modelmessage[];
|
|
37
|
+
apikey?: string;
|
|
38
|
+
temperature?: number;
|
|
39
|
+
maxtokens?: number;
|
|
40
|
+
stream?: boolean;
|
|
41
|
+
}): shapedrequest;
|
|
42
|
+
/** Parses one completion answer of the protocol style: the answer text and the usage counts; a malformed answer reports why nothing parsed. */
|
|
43
|
+
export declare function parsecompletion(style: protocolstyle, body: string): {
|
|
44
|
+
text?: string;
|
|
45
|
+
usage?: modelusage;
|
|
46
|
+
reason?: string;
|
|
47
|
+
};
|
|
48
|
+
/** Returns true when the url points at a local machine endpoint: a loopback host keeps the model call inside the machine. */
|
|
49
|
+
export declare function islocalorigin(url: string): boolean;
|
|
50
|
+
/** Sends one completion request to a user configured provider: the request shapes per protocol style, the page content stays stripped unless the user granted it, a configured auth reference without a resolved key refuses the call and the answer parses per style with its usage counts; retries and backoff ride the reviewed fetch options. */
|
|
51
|
+
export declare function callmodel(input: {
|
|
52
|
+
provider: providerconfig;
|
|
53
|
+
model: string;
|
|
54
|
+
messages: modelmessage[];
|
|
55
|
+
apikey?: string;
|
|
56
|
+
temperature?: number;
|
|
57
|
+
maxtokens?: number;
|
|
58
|
+
pagecontent?: string;
|
|
59
|
+
pagegrant?: boolean;
|
|
60
|
+
stream?: boolean;
|
|
61
|
+
options?: {
|
|
62
|
+
timeout?: number;
|
|
63
|
+
retries?: number;
|
|
64
|
+
backoff?: number;
|
|
65
|
+
follow?: number;
|
|
66
|
+
};
|
|
67
|
+
transport: fetchtransport;
|
|
68
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
69
|
+
now?: () => number;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
text: string;
|
|
72
|
+
usage?: modelusage;
|
|
73
|
+
request: shapedrequest;
|
|
74
|
+
}>;
|
|
75
|
+
/** Sends one completion request to the local model endpoint: the endpoint must stay local so the call never leaves the machine, the key stays optional because local runtimes need none and the answer parses per the configured style. */
|
|
76
|
+
export declare function calllocal(input: {
|
|
77
|
+
local: localmodelconfig;
|
|
78
|
+
messages: modelmessage[];
|
|
79
|
+
apikey?: string;
|
|
80
|
+
temperature?: number;
|
|
81
|
+
maxtokens?: number;
|
|
82
|
+
options?: {
|
|
83
|
+
timeout?: number;
|
|
84
|
+
retries?: number;
|
|
85
|
+
backoff?: number;
|
|
86
|
+
follow?: number;
|
|
87
|
+
};
|
|
88
|
+
transport: fetchtransport;
|
|
89
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
90
|
+
now?: () => number;
|
|
91
|
+
}): Promise<{
|
|
92
|
+
text: string;
|
|
93
|
+
usage?: modelusage;
|
|
94
|
+
request: shapedrequest;
|
|
95
|
+
}>;
|
|
96
|
+
/** Parses one streaming event payload of the protocol style into its token text: the chat completions delta content, the responses output text delta, the messages content block text delta and the gemini candidate part text. */
|
|
97
|
+
export declare function streamdelta(style: protocolstyle, event: string): string;
|
|
98
|
+
/** Parses one server sent event body of the protocol style into the ordered token stream it carries; the done marker rides the last token of a finished stream. */
|
|
99
|
+
export declare function parsestream(style: protocolstyle, body: string): tokenstream[];
|
|
100
|
+
/** Streams one completion request when the provider supports it: the request carries the stream flag of its style, the transport seam returns the server sent event body and the ordered tokens assemble into the answer text with its token count. */
|
|
101
|
+
export declare function streammodel(input: {
|
|
102
|
+
provider: providerconfig;
|
|
103
|
+
model: string;
|
|
104
|
+
messages: modelmessage[];
|
|
105
|
+
apikey?: string;
|
|
106
|
+
temperature?: number;
|
|
107
|
+
maxtokens?: number;
|
|
108
|
+
pagecontent?: string;
|
|
109
|
+
pagegrant?: boolean;
|
|
110
|
+
options?: {
|
|
111
|
+
timeout?: number;
|
|
112
|
+
retries?: number;
|
|
113
|
+
backoff?: number;
|
|
114
|
+
follow?: number;
|
|
115
|
+
};
|
|
116
|
+
transport: fetchtransport;
|
|
117
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
118
|
+
now?: () => number;
|
|
119
|
+
}): Promise<{
|
|
120
|
+
text: string;
|
|
121
|
+
tokens: number;
|
|
122
|
+
request: shapedrequest;
|
|
123
|
+
}>;
|
|
124
|
+
/** The command parse guard schema: the intent kind, the entities array and the confidence number the parsed command answer carries. */
|
|
125
|
+
export declare const commandguard: parseguard;
|
|
126
|
+
/** Classifies one natural language request into its intent kind with a confidence score: the deterministic keyword scan works without any provider, the confidence rides the matched keyword density and an unmatched request classifies as ask with a low score. */
|
|
127
|
+
export declare function classifyintent(text: string): {
|
|
128
|
+
intent: intentkind;
|
|
129
|
+
confidence: number;
|
|
130
|
+
};
|
|
131
|
+
/** Parses one natural language command into its structured result: the model call rides the routed provider, the answer passes the command guard with its retries and the parsed intent, entities and confidence land in the commandparse record; a model refusal reports why nothing parsed. */
|
|
132
|
+
export declare function parsecommand(input: {
|
|
133
|
+
provider: providerconfig;
|
|
134
|
+
model: string;
|
|
135
|
+
text: string;
|
|
136
|
+
apikey?: string;
|
|
137
|
+
transport: fetchtransport;
|
|
138
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
139
|
+
now?: () => number;
|
|
140
|
+
guard?: parseguard;
|
|
141
|
+
}): Promise<{
|
|
142
|
+
parse?: commandparse;
|
|
143
|
+
output?: modeloutput;
|
|
144
|
+
reason?: string;
|
|
145
|
+
}>;
|
|
146
|
+
/** Builds one model drafted plan from a goal: the model call drafts the steps and open questions, the grammar lint checks every drafted step against the action grammar before review and the draft records its provider and model provenance; the draft never executes until the human review approves it. */
|
|
147
|
+
export declare function draftplan(input: {
|
|
148
|
+
provider: providerconfig;
|
|
149
|
+
model: string;
|
|
150
|
+
goal: string;
|
|
151
|
+
origin?: string;
|
|
152
|
+
lessons?: string[];
|
|
153
|
+
apikey?: string;
|
|
154
|
+
transport: fetchtransport;
|
|
155
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
156
|
+
now?: () => number;
|
|
157
|
+
}): Promise<{
|
|
158
|
+
draft?: plandraft;
|
|
159
|
+
output?: modeloutput;
|
|
160
|
+
reason?: string;
|
|
161
|
+
}>;
|
|
162
|
+
/** Regenerates the tail of a failed plan: the completed steps stay untouched, the failed steps fall away and the model drafted tail steps carry the fresh review marker so the human review approves every revised step again; the replan record keeps the failure reason and the model provenance. */
|
|
163
|
+
export declare function replannonfail(input: {
|
|
164
|
+
provider: providerconfig;
|
|
165
|
+
model: string;
|
|
166
|
+
draft: plandraft;
|
|
167
|
+
completedstepids: string[];
|
|
168
|
+
failedstepids: string[];
|
|
169
|
+
reason: string;
|
|
170
|
+
lessons?: string[];
|
|
171
|
+
apikey?: string;
|
|
172
|
+
transport: fetchtransport;
|
|
173
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
174
|
+
now?: () => number;
|
|
175
|
+
}): Promise<{
|
|
176
|
+
replan?: replanrecord;
|
|
177
|
+
output?: modeloutput;
|
|
178
|
+
reason?: string;
|
|
179
|
+
}>;
|
|
180
|
+
/** Reflects one executed step: the model call reads the step outcome with the running lessons of the earlier steps and answers the lesson learned plus the advice for the next step; the note records its run, step and model provenance. */
|
|
181
|
+
export declare function reflectstep(input: {
|
|
182
|
+
provider: providerconfig;
|
|
183
|
+
model: string;
|
|
184
|
+
runid: string;
|
|
185
|
+
stepid: string;
|
|
186
|
+
outcome: string;
|
|
187
|
+
lessons?: string[];
|
|
188
|
+
apikey?: string;
|
|
189
|
+
transport: fetchtransport;
|
|
190
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
191
|
+
now?: () => number;
|
|
192
|
+
}): Promise<{
|
|
193
|
+
note?: reflectnote;
|
|
194
|
+
output?: modeloutput;
|
|
195
|
+
reason?: string;
|
|
196
|
+
}>;
|
|
197
|
+
/** Summarizes the running lessons of the reflection notes so the next prompt carries them; the newest lesson of every step rides the summary in step order. */
|
|
198
|
+
export declare function reflectionsummary(notes: reflectnote[]): string;
|
|
199
|
+
/** Strips the guardrail noise of one model answer before parsing: code fences open the payload, chatter lines around a json object fall away and a fenced block without a language tag keeps its inner text. The fence runs through plain index scans, because a regex over the fence prefix would backtrack polynomially on adversarial answers built from repeated fence markers. */
|
|
200
|
+
export declare function stripguardrails(text: string): string;
|
|
201
|
+
/** Validates one stripped model answer against the guard schema: every required field must be present with its declared type while optional fields pass through; the verdict reports invalid with the reason otherwise. */
|
|
202
|
+
export declare function parseoutput(input: {
|
|
203
|
+
guard: parseguard;
|
|
204
|
+
text: string;
|
|
205
|
+
}): modeloutput;
|
|
206
|
+
/** Runs the parse guard over the model answer attempts: a valid attempt wins, a refusal marker refuses without retries, malformed answers retry up to the configured count and the exhaustion of every attempt refuses the output so nothing invalid ever executes. */
|
|
207
|
+
export declare function guardoutput(input: {
|
|
208
|
+
guard: parseguard;
|
|
209
|
+
attempts: string[];
|
|
210
|
+
}): modeloutput;
|
|
211
|
+
/** Builds the openapi style tool brief of one catalog tool: the name, the summary line, the description, the risk class and the typed parameter list with their required markers. */
|
|
212
|
+
export declare function toolbriefof(tool: tooldef): toolbrief;
|
|
213
|
+
/** Renders the tool briefs in openapi style for model consumption: every tool lists its name, summary, risk class and typed parameters so the model knows the surface it may propose; the consent notice states that side effects need the named approved step. */
|
|
214
|
+
export declare function rendertoolbriefs(tools: tooldef[]): string;
|
|
215
|
+
/** Records one usage entry of a model call: the run and step ids ride the record together with the provider, the endpoint, the model, the token counts and the cost; newer records prepend so the newest call reads first. */
|
|
216
|
+
export declare function addusage(records: usagerecord[], record: usagerecord): usagerecord[];
|
|
217
|
+
/** Aggregates the usage records per run, per step, per session and per period: the prompt, completion and total token counts, the cost total and the call count of every record the filter keeps; the session filter of the 1.1.83 gateway family reports the per session totals beside the per run totals. */
|
|
218
|
+
export declare function usagetotals(records: usagerecord[], filter?: {
|
|
219
|
+
runid?: string;
|
|
220
|
+
stepid?: string;
|
|
221
|
+
sessionid?: string;
|
|
222
|
+
since?: number;
|
|
223
|
+
until?: number;
|
|
224
|
+
}): {
|
|
225
|
+
prompttokens: number;
|
|
226
|
+
completiontokens: number;
|
|
227
|
+
totaltokens: number;
|
|
228
|
+
cost: number;
|
|
229
|
+
calls: number;
|
|
230
|
+
};
|
|
231
|
+
/** Checks the cost budget of a run: a reached token or currency ceiling halts the run and asks the user before anything else runs, while an absent ceiling stays unbounded because every ceiling is a user choice. */
|
|
232
|
+
export declare function budgetcheck(input: {
|
|
233
|
+
budget: costbudget | undefined;
|
|
234
|
+
totals: {
|
|
235
|
+
totaltokens: number;
|
|
236
|
+
cost: number;
|
|
237
|
+
};
|
|
238
|
+
}): {
|
|
239
|
+
allowed: boolean;
|
|
240
|
+
halted: boolean;
|
|
241
|
+
asksuser: boolean;
|
|
242
|
+
reason?: string;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Model routing of the 1.1.57 llm integration family.
|
|
246
|
+
* Every routing concern lives in this file: the task kind resolution that maps a task kind onto its preferred provider and model, the availability marking of providers that failed their last call, the fallback resolution on refusal or outage with the user configured fallback pair and the route validation that keeps every entry a user configured choice.
|
|
247
|
+
* No default route, no default model and no default provider ever applies: an unrouted task kind reports why nothing routed and the user picks the pair.
|
|
248
|
+
*/
|
|
249
|
+
/** Validates one model route entry: the task kind, the provider and the model stay user configured values and the fallback pair needs both halves or none. */
|
|
250
|
+
export declare function routevalid(route: modelroute): policyevaluation;
|
|
251
|
+
/** Returns every route of one task kind in revision order, newest revision first. */
|
|
252
|
+
export declare function routesfor(routes: modelroute[], kind: string): modelroute[];
|
|
253
|
+
/** Resolves the provider and model for one task kind: the newest route of the kind whose provider exists and stays available wins; an unrouted kind, a missing provider or an unavailable provider reports why nothing routed. */
|
|
254
|
+
export declare function resolveroute(input: {
|
|
255
|
+
routes: modelroute[];
|
|
256
|
+
providers: providerconfig[];
|
|
257
|
+
kind: string;
|
|
258
|
+
}): {
|
|
259
|
+
route?: modelroute;
|
|
260
|
+
provider?: providerconfig;
|
|
261
|
+
model?: string;
|
|
262
|
+
reason?: string;
|
|
263
|
+
};
|
|
264
|
+
/** Marks one provider unavailable after a failed call or available after a successful test; every other provider stays untouched. */
|
|
265
|
+
export declare function markprovider(input: {
|
|
266
|
+
providers: providerconfig[];
|
|
267
|
+
providerid: string;
|
|
268
|
+
available: boolean;
|
|
269
|
+
now: number;
|
|
270
|
+
}): providerconfig[];
|
|
271
|
+
/** Resolves the fallback pair of one task kind on refusal or outage: the user configured fallback provider and model win when they exist and stay available; a missing fallback reports why nothing fell back so the caller asks the user. */
|
|
272
|
+
export declare function fallbackroute(input: {
|
|
273
|
+
routes: modelroute[];
|
|
274
|
+
providers: providerconfig[];
|
|
275
|
+
kind: string;
|
|
276
|
+
}): {
|
|
277
|
+
route?: modelroute;
|
|
278
|
+
provider?: providerconfig;
|
|
279
|
+
model?: string;
|
|
280
|
+
reason?: string;
|
|
281
|
+
};
|
|
282
|
+
/** Bumps the revision of one route entry so the revision history of the routing table stays queryable; the newest revision of a kind wins the resolution. */
|
|
283
|
+
export declare function bumprevision(route: modelroute, now: number): modelroute;
|
|
284
|
+
/**
|
|
285
|
+
* Prompt template library of the 1.1.57 llm integration family.
|
|
286
|
+
* Every template concern lives in this file: the variable extraction from double braced placeholders, the template render that fills the variables, the consent notice requirement of sensitive flows, the versioning of every saved template with its change notes and the library search.
|
|
287
|
+
* The library holds user templates only: no built-in template ever ships, so every prompt body stays a user reviewed choice.
|
|
288
|
+
*/
|
|
289
|
+
/** Extracts the double braced variable names of one template body in order of appearance, deduplicated. */
|
|
290
|
+
export declare function templatevariables(body: string): string[];
|
|
291
|
+
/** Renders one template with its variables: every declared variable substitutes its value while a sensitive flow needs its consent notice before the render leaves; the notice rides the rendered text so the reviewer sees the consent line. */
|
|
292
|
+
export declare function rendertemplate(input: {
|
|
293
|
+
template: prompttemplate;
|
|
294
|
+
variables?: Record<string, unknown>;
|
|
295
|
+
sensitive?: boolean;
|
|
296
|
+
consentnotice?: string;
|
|
297
|
+
}): {
|
|
298
|
+
text?: string;
|
|
299
|
+
reason?: string;
|
|
300
|
+
};
|
|
301
|
+
/** Saves one template version: a new name creates the first version while a known name bumps the version with its change notes; every earlier version stays stored so the history never rewrites. */
|
|
302
|
+
export declare function savetemplate(input: {
|
|
303
|
+
templates: prompttemplate[];
|
|
304
|
+
name: string;
|
|
305
|
+
body: string;
|
|
306
|
+
notes?: string;
|
|
307
|
+
now: number;
|
|
308
|
+
}): prompttemplate[];
|
|
309
|
+
/** Returns the newest stored version of one template name; an unknown name reports undefined. */
|
|
310
|
+
export declare function latesttemplate(templates: prompttemplate[], name: string): prompttemplate | undefined;
|
|
311
|
+
/** Searches the library: the query matches the template name, the body text, the change notes or one of the declared variables, newest version first. */
|
|
312
|
+
export declare function searchtemplates(templates: prompttemplate[], query: string): prompttemplate[];
|
|
313
|
+
/** Removes every version of one template name from the library; the change history leaves with the name. */
|
|
314
|
+
export declare function removetemplate(templates: prompttemplate[], name: string): prompttemplate[];
|
|
315
|
+
/**
|
|
316
|
+
* Provider gateway logics of the 1.1.83 family.
|
|
317
|
+
* Every provider adapter concern lives in this file: the adapter interface one request, stream and cancel contract shares, the four adapters (the openaicompat chat completions shape with its streamed deltas, the anthropicgateway messages shape with its streamed content blocks and its system prompt mapping, the geminigateway generate content shape with its streamed candidate parts and its tool schema mapping, and the ollamalocal localhost runtime with its local model listing), the baseurlconfig one endpoint url per provider with its scheme, host and path shape validation, the per provider key vault behind the secretvault seam, the modellist discovery with its configurable cache window, the capabilityad tool catalog advertisement, the routing of task kinds onto providers with the local fallback, the token budget accounting with its warning threshold, the guardrails over every parsed model answer with the structured retry prompt and the capped retries, and the prompt template library of the per task templates with their variable slots.
|
|
318
|
+
* The module composes with the llm provider model instead of duplicating it: the three remote adapters speak through the same request shaping, answer parsing and stream parsing the llm module owns, while the ollamalocal adapter speaks its own localhost wire format. Nothing is hardcoded: no remote endpoint, no model name and no key ever leaves the user configuration, the ollamalocal adapter alone defaults to the localhost machine and never to a cloud url, every timeout, retry, backoff and cache window stays a user choice, all http rides the injected fetch transport seam and every key resolves through the vault seam at the last possible moment.
|
|
319
|
+
*/
|
|
320
|
+
/** The local machine base url the ollamalocal adapter alone defaults to: a loopback address of the machine itself, never a cloud url — the explicit contract exception, while every remote provider ships an empty base url until the user configures one. */
|
|
321
|
+
export declare const ollamalocaldefault = "http://localhost:11434";
|
|
322
|
+
/** The provider kinds of the gateway family in their stable order; every surface that lists the adapters reads this one list. */
|
|
323
|
+
export declare const gatewaykinds: gatewaykind[];
|
|
324
|
+
/** Reads the default base url of one provider kind: the ollamalocal runtime alone carries the localhost machine default and every remote kind carries none, so no provider endpoint is contacted unless the user configured one. */
|
|
325
|
+
export declare function defaultbaseurl(kind: gatewaykind): string;
|
|
326
|
+
/** Joins the user configured base url, the optional per provider path prefix and the wire path of the adapter into the request url; the base keeps its trailing shape and the prefix sits between the base and the wire path. The slash trims run through plain character walks, because a leading or trailing slash regex would itself read as polynomial on adversarial bases. */
|
|
327
|
+
export declare function gatewayurl(config: Pick<baseurlconfig, "baseurl" | "pathprefix">, path: string): string;
|
|
328
|
+
/** The input every adapter shapes into one wire request: the provider config, the model, the conversation, the resolved key material, the sampling choices, the stream flag, the tool catalog the capabilityad advertises and the extra headers the user reviewed. */
|
|
329
|
+
export interface gatewayrequestinput {
|
|
330
|
+
config: baseurlconfig;
|
|
331
|
+
model: string;
|
|
332
|
+
messages: modelmessage[];
|
|
333
|
+
/** Resolved key material; the value reaches the wire headers only and never a log, an audit entry or an export. */
|
|
334
|
+
apikey?: string;
|
|
335
|
+
temperature?: number;
|
|
336
|
+
maxtokens?: number;
|
|
337
|
+
stream?: boolean;
|
|
338
|
+
/** The tool catalog the request advertises through the capabilityad serialization of the adapter. */
|
|
339
|
+
tools?: tooldef[];
|
|
340
|
+
headers?: Record<string, string>;
|
|
341
|
+
}
|
|
342
|
+
/** The provider adapter contract: every adapter builds its wire request, parses one answer body, parses one streamed body into ordered tokens, lists its models and serializes the tool catalog in its own wire format — one request, stream and cancel contract shared by all four. */
|
|
343
|
+
export interface gatewayadapter {
|
|
344
|
+
readonly kind: gatewaykind;
|
|
345
|
+
/** The protocol style of the llm provider model this adapter extends, when it speaks one of them; the ollamalocal runtime speaks its own localhost wire format and carries none. */
|
|
346
|
+
readonly style?: "chatcompletions" | "messages" | "gemini";
|
|
347
|
+
/** The wire path of the chat endpoint relative to the base url; the gemini shape rides its model in the path. */
|
|
348
|
+
chatpath(model: string): string;
|
|
349
|
+
/** The wire path of the model list endpoint relative to the base url. */
|
|
350
|
+
modelspath(): string;
|
|
351
|
+
/** Builds one wire request: the url, the method, the headers with the key placed where the shape expects it and the body envelope the shape speaks, with the tool catalog embedded in the provider format when the request carries one. */
|
|
352
|
+
build(input: gatewayrequestinput): ReturnType<typeof buildrequest>;
|
|
353
|
+
/** Parses one answer body of the adapter wire format: the answer text and its usage counts, or the reason nothing parsed. */
|
|
354
|
+
parseanswer(body: string): {
|
|
355
|
+
text?: string;
|
|
356
|
+
usage?: modelusage;
|
|
357
|
+
reason?: string;
|
|
358
|
+
};
|
|
359
|
+
/** Parses one streamed body of the adapter wire format into its ordered token stream: the chat completions deltas, the messages content blocks, the gemini candidate parts or the ollama message lines. */
|
|
360
|
+
parsestream(body: string): tokenstream[];
|
|
361
|
+
/** Parses one model list body of the adapter wire format into the discovered models with their context and modality hints when offered. */
|
|
362
|
+
parsemodellist(body: string): gatewaymodelinfo[];
|
|
363
|
+
/** Serializes the tool catalog into the tool schema format of the provider for the capabilityad advertisement. */
|
|
364
|
+
toolcatalog(tools: tooldef[]): unknown[];
|
|
365
|
+
}
|
|
366
|
+
/** The openai compatible chat completions adapter: any endpoint the user configures that speaks the chat completions shape works, the bearer header carries the resolved key, the streamed answer rides server sent event deltas and the tool catalog serializes into the function tool schema. */
|
|
367
|
+
export declare const openaicompatadapter: gatewayadapter;
|
|
368
|
+
/** The anthropic messages adapter: the messages wire shape with its system prompt mapping to the top level system field, the streamed answer rides content block deltas and the tool catalog serializes into the input schema format. */
|
|
369
|
+
export declare const anthropicgatewayadapter: gatewayadapter;
|
|
370
|
+
/** The gemini generate content adapter: the generate content wire shape with the model riding the path, the streamed answer rides candidate parts and the tool schema maps into the function declarations format. */
|
|
371
|
+
export declare const geminigatewayadapter: gatewayadapter;
|
|
372
|
+
/** The ollama local runtime adapter: it speaks its own localhost wire format (the chat endpoint with the message envelope, the tag list of the locally installed models and the newline delimited stream lines), the base url defaults to the local machine alone and never to a cloud url, and a call never leaves the machine. */
|
|
373
|
+
export declare const ollamalocaladapter: gatewayadapter;
|
|
374
|
+
/** Every adapter of the gateway family in its stable order; the surfaces and the tests read this one record. */
|
|
375
|
+
export declare const gatewayadapters: Record<gatewaykind, gatewayadapter>;
|
|
376
|
+
/** Reads the adapter of one provider kind; an unknown kind refuses because the four adapters are the contract. */
|
|
377
|
+
export declare function adapterof(kind: gatewaykind): gatewayadapter;
|
|
378
|
+
/** The cancel contract of the gateway family: one cancel state the caller creates, passes into the request and stream calls and cancels from any surface; the calls check the flag before the dispatch, between the attempts and after every streamed token. */
|
|
379
|
+
export interface gatewaycancelstate {
|
|
380
|
+
cancelled(): boolean;
|
|
381
|
+
cancel(reason?: string): void;
|
|
382
|
+
reason(): string;
|
|
383
|
+
}
|
|
384
|
+
/** Creates one cancel state of the gateway stream contract; the state stays silent until the caller cancels it. */
|
|
385
|
+
export declare function gatewaycancel(): gatewaycancelstate;
|
|
386
|
+
/** Builds one structured gateway error with its code, message, retry hint and request id; every failure surface of the family answers this one shape. */
|
|
387
|
+
export declare function gatewayerrorof(code: gatewayerror["code"], message: string, requestid: string, retryhint?: string, retryafter?: number): gatewayerror;
|
|
388
|
+
/** Normalizes one thrown error into the structured gateway error surface: a thrown gateway error passes through, a timeout keeps its code and every other failure grades as a transport error with its retry hint. */
|
|
389
|
+
export declare function gatewayerrorfrom(error: unknown, requestid: string): gatewayerror;
|
|
390
|
+
/** Reads the retry after milliseconds a rate limited answer announced: the retry-after header carries seconds or milliseconds, the request epoch dates pass through and an absent or malformed header answers undefined. */
|
|
391
|
+
export declare function gatewayretryafterof(headers: Record<string, string>): number | undefined;
|
|
392
|
+
/** Masks one provider key for every log, audit entry and error message: the mask answers the key length alone, so no key material — no prefix, no suffix, no fragment — ever reaches a printed line. */
|
|
393
|
+
export declare function maskkey(key: string): string;
|
|
394
|
+
/** Builds the log safe view of one shaped request: the authorization, api key and proxy header values answer their masked form and a gemini url key parameter strips, so the audit trail and the surfaces never record key material. */
|
|
395
|
+
export declare function maskrequest(request: {
|
|
396
|
+
url: string;
|
|
397
|
+
method: string;
|
|
398
|
+
headers: Record<string, string>;
|
|
399
|
+
body: string;
|
|
400
|
+
}): {
|
|
401
|
+
url: string;
|
|
402
|
+
method: string;
|
|
403
|
+
headers: Record<string, string>;
|
|
404
|
+
body: string;
|
|
405
|
+
};
|
|
406
|
+
/** Stores one provider api key behind the vault seam under the explicit consent of the user: the key material enters the seam at the store moment and the metadata record alone answers, scoped to the origin of the provider base url so a key of one gateway never rides another. */
|
|
407
|
+
export declare function storeproviderkey(input: {
|
|
408
|
+
seam: {
|
|
409
|
+
put(vaultid: string, value: string): Promise<void>;
|
|
410
|
+
};
|
|
411
|
+
config: Pick<baseurlconfig, "providerid" | "kind" | "baseurl">;
|
|
412
|
+
profileid: string;
|
|
413
|
+
value: string;
|
|
414
|
+
consent: boolean;
|
|
415
|
+
now: number;
|
|
416
|
+
}): Promise<secretvaultentry>;
|
|
417
|
+
/** Resolves one provider key from the vault seam at the last possible moment before the wire header: the value answers to the dispatching caller only, never to a log writer, and the record stamps its use. */
|
|
418
|
+
export declare function resolveproviderkey(input: {
|
|
419
|
+
seam: {
|
|
420
|
+
fetch(vaultid: string): Promise<string | undefined>;
|
|
421
|
+
};
|
|
422
|
+
entry: secretvaultentry;
|
|
423
|
+
}): Promise<{
|
|
424
|
+
ok: boolean;
|
|
425
|
+
value?: string;
|
|
426
|
+
reason: string;
|
|
427
|
+
}>;
|
|
428
|
+
/** Revokes one provider key with one click: the value drops from the seam and the metadata record leaves with it, because a deleted key leaves no trace a surface could read. */
|
|
429
|
+
export declare function revokeproviderkey(input: {
|
|
430
|
+
seam: {
|
|
431
|
+
drop(vaultid: string): Promise<void>;
|
|
432
|
+
};
|
|
433
|
+
entry: secretvaultentry;
|
|
434
|
+
}): Promise<{
|
|
435
|
+
dropped: boolean;
|
|
436
|
+
label: string;
|
|
437
|
+
reason: string;
|
|
438
|
+
}>;
|
|
439
|
+
/** Checks one export candidate list for leaked provider keys: a candidate whose sha-256 digest matches a stored vault record is a leak the export refuses, because key material never rides an export path. */
|
|
440
|
+
export declare function keyexportcheck(input: {
|
|
441
|
+
candidates: string[];
|
|
442
|
+
entries: secretvaultentry[];
|
|
443
|
+
}): Promise<{
|
|
444
|
+
leaks: string[];
|
|
445
|
+
reason: string;
|
|
446
|
+
}>;
|
|
447
|
+
/** The call options of the one request contract: the timeout, the retry count, the backoff base, the jitter window and the extra headers the user reviewed — every bound a user choice with no code default. */
|
|
448
|
+
export interface gatewayoptions {
|
|
449
|
+
timeout?: number;
|
|
450
|
+
retries?: number;
|
|
451
|
+
backoff?: number;
|
|
452
|
+
/** Jitter window in milliseconds the backoff waits add; a zero window keeps the deterministic backoff. */
|
|
453
|
+
jitter?: number;
|
|
454
|
+
headers?: Record<string, string>;
|
|
455
|
+
}
|
|
456
|
+
/** The result of one gateway request: the answer text, the usage counts, the request id, the shaped request and the transport facts. */
|
|
457
|
+
export interface gatewayresult {
|
|
458
|
+
text: string;
|
|
459
|
+
usage?: modelusage;
|
|
460
|
+
requestid: string;
|
|
461
|
+
request: ReturnType<typeof buildrequest>;
|
|
462
|
+
status: number;
|
|
463
|
+
duration: number;
|
|
464
|
+
retries: number;
|
|
465
|
+
}
|
|
466
|
+
/** Sends one gateway request through the shared contract: the dispatch loop runs the gates, the retries, the rate limit honoring, the timeout race and the cancellation, and the adapter parses the answer body with its usage counts — every failure answers the structured gateway error. */
|
|
467
|
+
export declare function gatewaycall(input: {
|
|
468
|
+
config: baseurlconfig;
|
|
469
|
+
model: string;
|
|
470
|
+
messages: modelmessage[];
|
|
471
|
+
apikey?: string;
|
|
472
|
+
tools?: tooldef[];
|
|
473
|
+
temperature?: number;
|
|
474
|
+
maxtokens?: number;
|
|
475
|
+
options?: gatewayoptions;
|
|
476
|
+
requestid?: string;
|
|
477
|
+
cancel?: gatewaycancelstate;
|
|
478
|
+
transport: fetchtransport;
|
|
479
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
480
|
+
jitter?: () => number;
|
|
481
|
+
now?: () => number;
|
|
482
|
+
}): Promise<gatewayresult>;
|
|
483
|
+
/** Streams one gateway request through the shared contract: the request carries the stream flag of its wire format, the adapter parses the streamed body into its ordered tokens (the chat completions deltas, the messages content blocks, the gemini candidate parts or the ollama message lines), the onevent seam fires for every token as it parses so the surfaces append the answer incrementally, and the cancel state stops the parse loop at the token position it reached. */
|
|
484
|
+
export declare function gatewaystream(input: {
|
|
485
|
+
config: baseurlconfig;
|
|
486
|
+
model: string;
|
|
487
|
+
messages: modelmessage[];
|
|
488
|
+
apikey?: string;
|
|
489
|
+
tools?: tooldef[];
|
|
490
|
+
temperature?: number;
|
|
491
|
+
maxtokens?: number;
|
|
492
|
+
options?: gatewayoptions;
|
|
493
|
+
requestid?: string;
|
|
494
|
+
cancel?: gatewaycancelstate;
|
|
495
|
+
transport: fetchtransport;
|
|
496
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
497
|
+
jitter?: () => number;
|
|
498
|
+
now?: () => number;
|
|
499
|
+
onevent?: (token: tokenstream) => void;
|
|
500
|
+
}): Promise<{
|
|
501
|
+
tokens: tokenstream[];
|
|
502
|
+
text: string;
|
|
503
|
+
requestid: string;
|
|
504
|
+
request: ReturnType<typeof buildrequest>;
|
|
505
|
+
status: number;
|
|
506
|
+
retries: number;
|
|
507
|
+
}>;
|
|
508
|
+
/** Fetches the model list of one provider through the adapter: the cache window the user configured decides whether the cached list still serves, a fresh fetch rides the model list endpoint of the wire format, the discovered models annotate with their context and modality hints when the provider offers them and a failed fetch keeps the cache untouched. */
|
|
509
|
+
export declare function fetchmodellist(input: {
|
|
510
|
+
config: baseurlconfig;
|
|
511
|
+
apikey?: string;
|
|
512
|
+
cachewindow?: number;
|
|
513
|
+
cache?: modelcacherecord;
|
|
514
|
+
transport: fetchtransport;
|
|
515
|
+
options?: gatewayoptions;
|
|
516
|
+
now?: () => number;
|
|
517
|
+
}): Promise<{
|
|
518
|
+
models: gatewaymodelinfo[];
|
|
519
|
+
cached: boolean;
|
|
520
|
+
fetchedat: number;
|
|
521
|
+
reason?: string;
|
|
522
|
+
}>;
|
|
523
|
+
/** Builds the capabilityad advertisement of the tool catalog: the tools serialize into the wire format of the provider (the function schema of the chat completions shape, the input schema of the messages shape, the function declarations of the generate content shape or the function schema of the local runtime), every tool declares its consent requirement from its metadata and the plan review gate rides the required capabilities because a model answer never executes a step the human review did not approve. */
|
|
524
|
+
export declare function capabilityadvertisement(input: {
|
|
525
|
+
kind: gatewaykind;
|
|
526
|
+
tools: tooldef[];
|
|
527
|
+
}): {
|
|
528
|
+
kind: gatewaykind;
|
|
529
|
+
tools: unknown[];
|
|
530
|
+
consent: Array<{
|
|
531
|
+
tool: string;
|
|
532
|
+
review: string;
|
|
533
|
+
riskclass?: string;
|
|
534
|
+
approvalrequired?: boolean;
|
|
535
|
+
}>;
|
|
536
|
+
requiredcapabilities: string[];
|
|
537
|
+
};
|
|
538
|
+
/** Resolves the gateway route of one task kind: the user rules of the model routing table map the kind onto its provider and model, a remote provider the consent or enable gates refuse falls back to the user configured fallback pair, and when remote calls are not allowed at all the resolution falls back to the local provider so the task stays on the machine. */
|
|
539
|
+
export declare function resolvegatewayroute(input: {
|
|
540
|
+
kind: string;
|
|
541
|
+
routes: modelroute[];
|
|
542
|
+
providers: providerconfig[];
|
|
543
|
+
configs: baseurlconfig[];
|
|
544
|
+
local?: localmodelconfig;
|
|
545
|
+
remoteallowed?: boolean;
|
|
546
|
+
sessionorigin?: string;
|
|
547
|
+
}): {
|
|
548
|
+
source: "route" | "fallback" | "local";
|
|
549
|
+
provider?: providerconfig;
|
|
550
|
+
model?: string;
|
|
551
|
+
config?: baseurlconfig;
|
|
552
|
+
local?: localmodelconfig;
|
|
553
|
+
reason?: string;
|
|
554
|
+
};
|
|
555
|
+
/** Builds one usage record of a gateway call: the request id rides the record for the correlation across the run, the session id reports the per session totals beside the per run totals, the cost answers the user configured price per million tokens and the local marker stamps the calls that never left the machine. */
|
|
556
|
+
export declare function gatewayusagerecord(input: {
|
|
557
|
+
providerid: string;
|
|
558
|
+
endpoint: string;
|
|
559
|
+
model: string;
|
|
560
|
+
usage?: modelusage;
|
|
561
|
+
costpermilliontokens?: number;
|
|
562
|
+
sessionid?: string;
|
|
563
|
+
runid?: string;
|
|
564
|
+
stepid?: string;
|
|
565
|
+
requestid: string;
|
|
566
|
+
local?: boolean;
|
|
567
|
+
now: number;
|
|
568
|
+
}): usagerecord;
|
|
569
|
+
/** Checks the warning threshold of the cost budget: the budget tracking warns once the recorded tokens or cost cross the user configured share of their ceiling, while the halt of the reviewed budget check stays separate — a warning never blocks a call, the halt does. */
|
|
570
|
+
export declare function gatewaybudgetwarning(input: {
|
|
571
|
+
budget?: costbudget;
|
|
572
|
+
totals: {
|
|
573
|
+
totaltokens: number;
|
|
574
|
+
cost: number;
|
|
575
|
+
};
|
|
576
|
+
}): {
|
|
577
|
+
warned: boolean;
|
|
578
|
+
tokenratio?: number;
|
|
579
|
+
costratio?: number;
|
|
580
|
+
reason?: string;
|
|
581
|
+
};
|
|
582
|
+
/** Builds the cost estimate view of the configured providers: the projected cost per million tokens answers the user configured price of every provider and model pair beside the recorded tokens and cost of the usage records, so the surfaces show what a call costs before it runs — a pair without configured pricing answers zero instead of an invented number. */
|
|
583
|
+
export declare function costestimates(input: {
|
|
584
|
+
configs: baseurlconfig[];
|
|
585
|
+
providers: providerconfig[];
|
|
586
|
+
records: usagerecord[];
|
|
587
|
+
}): costestimate[];
|
|
588
|
+
/** The reviewed default guard of the gateway plan answers: the goal, the steps array and the open questions the plan schema asks, with one retry before the refusal. */
|
|
589
|
+
export declare const gatewayplanguard: parseguard;
|
|
590
|
+
/** Builds the structured retry prompt of one refused model answer: the prompt names the schema the answer failed, quotes the failure reason of the guard and asks the model to answer with the corrected json object alone, so a retry teaches the shape instead of repeating the failure. */
|
|
591
|
+
export declare function guardretryprompt(output: modeloutput): string;
|
|
592
|
+
/** Runs the gateway guardrails over the model answer attempts: every attempt validates against the plan schema through the shared parse guard, the attempts cap at the user configured retry count, a valid attempt wins, a refusal marker refuses without retries and the exhaustion of every capped attempt refuses the output so nothing invalid ever reaches a plan — the structured retry prompt answers whenever a retry is left. */
|
|
593
|
+
export declare function gatewayguard(input: {
|
|
594
|
+
guard?: parseguard;
|
|
595
|
+
attempts: string[];
|
|
596
|
+
}): {
|
|
597
|
+
output: modeloutput;
|
|
598
|
+
retryprompt?: string;
|
|
599
|
+
cappedat: number;
|
|
600
|
+
};
|
|
601
|
+
/** The per task prompt templates of the gateway family: every template ships with its double braced variable slots and its version, the memory store keeps the versions and a template renders through the shared prompt library with its variables. */
|
|
602
|
+
export declare function gatewaytemplates(now: number): prompttemplate[];
|
|
603
|
+
/** Composes one gateway prompt from a stored template and its variable values through the shared prompt library; a missing template name answers the reason so the caller refuses instead of sending a hollow prompt. */
|
|
604
|
+
export declare function composegatewayprompt(input: {
|
|
605
|
+
templates: prompttemplate[];
|
|
606
|
+
name: string;
|
|
607
|
+
variables: Record<string, unknown>;
|
|
608
|
+
}): {
|
|
609
|
+
text?: string;
|
|
610
|
+
reason?: string;
|
|
611
|
+
};
|
|
612
|
+
/** Assembles the streamed tokens of a gateway chat for incremental rendering: every poll reads the tokens past its cursor, the assembled text carries only the fresh batch and the done marker answers whether a finished stream delivered its last token — the sidepanel chat appends every batch as it arrives instead of waiting for the whole answer. */
|
|
613
|
+
export declare function streamrender(tokens: gatewaychattoken[], cursor: number, finished: boolean): {
|
|
614
|
+
text: string;
|
|
615
|
+
nextcursor: number;
|
|
616
|
+
done: boolean;
|
|
617
|
+
};
|
|
618
|
+
/** Builds one gateway chat state of a streamed exchange: the request id, the provider, the model, the prompt and the token list the panel polls through its cursor; the state never carries key material. */
|
|
619
|
+
export declare function gatewaychatstateof(input: {
|
|
620
|
+
requestid: string;
|
|
621
|
+
config: baseurlconfig;
|
|
622
|
+
model: string;
|
|
623
|
+
prompt: string;
|
|
624
|
+
tokens?: gatewaychattoken[];
|
|
625
|
+
done?: boolean;
|
|
626
|
+
error?: gatewayerror;
|
|
627
|
+
now: number;
|
|
628
|
+
}): gatewaychatstate;
|
|
629
|
+
/** Reads whether one base url points at the local machine, shared with the llm provider model so the local marker of the usage records answers one rule. */
|
|
630
|
+
export declare function gatewayislocal(config: Pick<baseurlconfig, "baseurl">): boolean;
|
|
631
|
+
/** Runs the reviewed budget check over the usage totals: the token and currency ceilings halt the run and ask the user, exactly as every model call of the llm family already does — the gateway calls pass the same budget gate. */
|
|
632
|
+
export declare function gatewaybudgetcheck(input: {
|
|
633
|
+
budget: costbudget | undefined;
|
|
634
|
+
totals: {
|
|
635
|
+
totaltokens: number;
|
|
636
|
+
cost: number;
|
|
637
|
+
};
|
|
638
|
+
}): {
|
|
639
|
+
allowed: boolean;
|
|
640
|
+
halted: boolean;
|
|
641
|
+
asksuser: boolean;
|
|
642
|
+
reason?: string;
|
|
643
|
+
};
|
|
644
|
+
/** Validates one gateway config before it saves: the base url passes its scheme, host and path shape gate, the path prefix passes its namespace gate, the ollamalocal base url defaults to the local machine when the user left it empty and every remote kind refuses an empty base url. */
|
|
645
|
+
export declare function validategatewayconfig(config: baseurlconfig): {
|
|
646
|
+
ok: boolean;
|
|
647
|
+
config: baseurlconfig;
|
|
648
|
+
reason?: string;
|
|
649
|
+
};
|
|
650
|
+
/** The key reference the gateway config carries: the name the surfaces show, the origin scope of the provider base url and the storage id of the vault entry — never the key material. */
|
|
651
|
+
export declare function gatewaykeyref(name: string, baseurl: string, storageid: string, configuredat: number): apikeyref;
|
|
652
|
+
//# sourceMappingURL=llm.d.ts.map
|