@lotagate/cli 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/bin/lotagate.mjs +50 -8
- package/dist/application/agent/agent-constants.d.ts +6 -0
- package/dist/application/agent/agent-constants.js +1 -0
- package/dist/application/agent/agent-session-store-registry.d.ts +16 -0
- package/dist/application/agent/agent-session-store-registry.js +1 -0
- package/dist/application/agent/agent-session-store.d.ts +4 -0
- package/dist/application/agent/agent-session-store.js +5 -5
- package/dist/application/agent/capability-profile.d.ts +0 -38
- package/dist/application/agent/capability-profile.js +0 -1
- package/dist/application/agent/cli-agent-execution-service.d.ts +22 -12
- package/dist/application/agent/cli-agent-execution-service.js +1 -1
- package/dist/application/agent/cli-agent-preparation-cache.d.ts +39 -0
- package/dist/application/agent/cli-agent-preparation-cache.js +1 -0
- package/dist/application/agent/context-compaction.d.ts +1 -0
- package/dist/application/agent/context-compaction.js +7 -6
- package/dist/application/agent/context-token-cache.d.ts +21 -0
- package/dist/application/agent/context-token-cache.js +4 -0
- package/dist/application/agent/context-usage-service.d.ts +52 -0
- package/dist/application/agent/context-usage-service.js +1 -0
- package/dist/application/agent/continuation-checkpoint.d.ts +15 -0
- package/dist/application/agent/continuation-checkpoint.js +2 -0
- package/dist/application/agent/interactive-agent-guidance.d.ts +3 -3
- package/dist/application/agent/interactive-agent-guidance.js +2 -2
- package/dist/application/chat/pending-attachment-store.d.ts +5 -2
- package/dist/application/chat/pending-attachment-store.js +1 -1
- package/dist/application/commands/application-command-executor.js +1 -1
- package/dist/application/commands/command-catalog.js +1 -1
- package/dist/application/commands/goal-command-handlers.js +6 -6
- package/dist/application/commands/media-command-handlers.js +7 -6
- package/dist/application/commands/runtime-command-handlers.js +9 -9
- package/dist/application/intent/completion-gate.d.ts +2 -5
- package/dist/application/intent/completion-gate.js +1 -1
- package/dist/application/intent/evidence-ledger.d.ts +2 -1
- package/dist/application/intent/evidence-recording-tool-executor.js +1 -1
- package/dist/application/intent/intent-compiler.js +2 -2
- package/dist/application/memory/memory-extractor.js +2 -2
- package/dist/application/model/cached-model-catalog.d.ts +7 -1
- package/dist/application/model/cached-model-catalog.js +1 -1
- package/dist/application/model/model-catalog-service.js +1 -1
- package/dist/application/model/model-context-window.js +1 -1
- package/dist/application/model/model-response-retry.d.ts +7 -1
- package/dist/application/model/model-response-retry.js +1 -1
- package/dist/application/orchestration/cli-subagent-service.d.ts +4 -0
- package/dist/application/orchestration/cli-subagent-service.js +3 -3
- package/dist/application/orchestration/cli-turn-event-projector.js +1 -1
- package/dist/application/orchestration/cli-turn-events.d.ts +0 -7
- package/dist/application/orchestration/goal-input.d.ts +1 -1
- package/dist/application/orchestration/goal-input.js +1 -1
- package/dist/application/orchestration/headless-agent-turn.d.ts +1 -0
- package/dist/application/orchestration/headless-agent-turn.js +3 -3
- package/dist/application/orchestration/orchestration-constants.d.ts +3 -0
- package/dist/application/orchestration/orchestration-constants.js +1 -0
- package/dist/application/orchestration/subagent-handoff.js +3 -3
- package/dist/application/project-intelligence/project-intelligence-constants.d.ts +56 -0
- package/dist/application/project-intelligence/project-intelligence-constants.js +1 -0
- package/dist/application/project-intelligence/project-intelligence-service.js +1 -1
- package/dist/application/protocol/browser-host-tool-executor.d.ts +13 -3
- package/dist/application/protocol/browser-host-tool-executor.js +2 -2
- package/dist/application/protocol/computer-host-tool-executor.d.ts +3 -0
- package/dist/application/protocol/computer-host-tool-executor.js +2 -2
- package/dist/application/protocol/desktop-agent-command.d.ts +2 -2
- package/dist/application/protocol/desktop-agent-command.js +2 -2
- package/dist/application/protocol/desktop-agent-contracts.d.ts +34 -0
- package/dist/application/protocol/desktop-agent-contracts.js +1 -0
- package/dist/application/protocol/desktop-agent-helpers.d.ts +5 -0
- package/dist/application/protocol/desktop-agent-helpers.js +1 -0
- package/dist/application/protocol/desktop-agent-request-parser.d.ts +31 -6
- package/dist/application/protocol/desktop-agent-request-parser.js +1 -1
- package/dist/application/protocol/desktop-approval-broker.d.ts +14 -4
- package/dist/application/protocol/desktop-approval-broker.js +1 -1
- package/dist/application/protocol/desktop-attachment-store.d.ts +19 -2
- package/dist/application/protocol/desktop-attachment-store.js +1 -1
- package/dist/application/protocol/desktop-execution-policy.d.ts +2 -0
- package/dist/application/protocol/desktop-execution-policy.js +1 -1
- package/dist/application/protocol/desktop-host-bridge.d.ts +33 -0
- package/dist/application/protocol/desktop-host-bridge.js +1 -0
- package/dist/application/protocol/desktop-host-capabilities.d.ts +12 -0
- package/dist/application/protocol/desktop-host-capabilities.js +1 -0
- package/dist/application/protocol/desktop-host-tool-executor.d.ts +15 -2
- package/dist/application/protocol/desktop-host-tool-executor.js +2 -2
- package/dist/application/protocol/desktop-intent-event-writer.js +1 -1
- package/dist/application/protocol/desktop-protocol-helpers.js +1 -1
- package/dist/application/protocol/json-line-writer.d.ts +24 -2
- package/dist/application/protocol/json-line-writer.js +2 -2
- package/dist/application/protocol/jsonl-agent-command.d.ts +1 -1
- package/dist/application/protocol/jsonl-agent-command.js +2 -2
- package/dist/application/protocol/jsonl-protocol.d.ts +1 -1
- package/dist/application/protocol/jsonl-protocol.js +2 -2
- package/dist/application/security/desktop-tool-scope-policy.js +1 -1
- package/dist/application/security/tool-action-risk-analyzer.js +1 -1
- package/dist/application/security/tool-approval-service.d.ts +9 -3
- package/dist/application/security/tool-approval-service.js +1 -1
- package/dist/application/security/tool-policy-registry.d.ts +20 -0
- package/dist/application/security/tool-policy-registry.js +1 -0
- package/dist/application/security/tool-risk-classifier.d.ts +2 -1
- package/dist/application/security/tool-risk-classifier.js +1 -1
- package/dist/application/security/workspace-permission-policy.js +1 -1
- package/dist/application/workspace/session-execution-workspace.d.ts +2 -2
- package/dist/application/workspace/session-execution-workspace.js +3 -3
- package/dist/application/workspace/workspace-constants.d.ts +17 -0
- package/dist/application/workspace/workspace-constants.js +1 -0
- package/dist/application/workspace/workspace-file-index.d.ts +0 -1
- package/dist/application/workspace/workspace-file-index.js +1 -1
- package/dist/application/workspace/workspace-instruction-loader.js +1 -1
- package/dist/bootstrap/composition-root.d.ts +1 -0
- package/dist/bootstrap/runtime-factory.d.ts +5 -0
- package/dist/bootstrap/runtime-factory.js +1 -1
- package/dist/domain/errors/cli-error.js +1 -1
- package/dist/domain/extensions/extension-constants.d.ts +1 -0
- package/dist/domain/extensions/extension-constants.js +1 -0
- package/dist/domain/extensions/host-tool-plugin-ids.d.ts +0 -4
- package/dist/domain/extensions/host-tool-plugin-ids.js +1 -1
- package/dist/domain/extensions/plugin-manifest.js +1 -1
- package/dist/domain/intent/intent-contract.d.ts +0 -8
- package/dist/domain/intent/intent-contract.js +1 -1
- package/dist/domain/media/gateway-media-contract.js +1 -1
- package/dist/domain/media/media-constants.d.ts +3 -0
- package/dist/domain/media/media-constants.js +1 -0
- package/dist/domain/media/media-execution-policy.js +1 -1
- package/dist/domain/memory/memory-constants.d.ts +3 -0
- package/dist/domain/memory/memory-constants.js +1 -0
- package/dist/domain/memory/memory-search.js +2 -2
- package/dist/domain/orchestration/goal.d.ts +0 -1
- package/dist/domain/orchestration/goal.js +1 -1
- package/dist/domain/orchestration/work-plan.d.ts +0 -62
- package/dist/domain/orchestration/work-plan.js +0 -1
- package/dist/domain/runtime/assistant-stream-text.d.ts +11 -0
- package/dist/domain/runtime/assistant-stream-text.js +1 -0
- package/dist/domain/runtime/gateway-request-budget.d.ts +19 -0
- package/dist/domain/runtime/gateway-request-budget.js +1 -0
- package/dist/domain/runtime/resource-limits.d.ts +17 -0
- package/dist/domain/runtime/resource-limits.js +1 -1
- package/dist/domain/session/attachment.d.ts +2 -0
- package/dist/domain/workspace/workspace-settings.d.ts +2 -0
- package/dist/domain/workspace/workspace-settings.js +1 -1
- package/dist/infrastructure/agent-sdk/model-response-metrics.d.ts +7 -0
- package/dist/infrastructure/agent-sdk/model-response-metrics.js +1 -0
- package/dist/infrastructure/agent-sdk/model-tool-name-mapper.js +1 -1
- package/dist/infrastructure/agent-sdk/sdk-constants.d.ts +2 -0
- package/dist/infrastructure/agent-sdk/sdk-constants.js +1 -0
- package/dist/infrastructure/agent-sdk/tool-calling-model-client.js +1 -1
- package/dist/infrastructure/cache/cache-policy.d.ts +2 -0
- package/dist/infrastructure/cache/cache-policy.js +1 -1
- package/dist/infrastructure/cache/file-cache-store.d.ts +8 -0
- package/dist/infrastructure/cache/file-cache-store.js +2 -2
- package/dist/infrastructure/clipboard/clipboard-constants.d.ts +1 -0
- package/dist/infrastructure/clipboard/clipboard-constants.js +1 -0
- package/dist/infrastructure/clipboard/image-normalizer.js +1 -1
- package/dist/infrastructure/extensions/extensions-constants.d.ts +6 -0
- package/dist/infrastructure/extensions/extensions-constants.js +1 -0
- package/dist/infrastructure/extensions/mcp-runtime.d.ts +7 -0
- package/dist/infrastructure/extensions/mcp-runtime.js +1 -1
- package/dist/infrastructure/extensions/plugin-manager.js +2 -2
- package/dist/infrastructure/extensions/skill-tool-executor.d.ts +3 -1
- package/dist/infrastructure/extensions/skill-tool-executor.js +2 -2
- package/dist/infrastructure/filesystem/atomic-file-store.d.ts +11 -0
- package/dist/infrastructure/filesystem/atomic-file-store.js +1 -1
- package/dist/infrastructure/filesystem/filesystem-constants.d.ts +8 -0
- package/dist/infrastructure/filesystem/filesystem-constants.js +1 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.d.ts +3 -0
- package/dist/infrastructure/filesystem/local-filesystem-tool-executor.js +3 -3
- package/dist/infrastructure/logging/daily-rotating-file-writer.d.ts +1 -1
- package/dist/infrastructure/logging/daily-rotating-file-writer.js +2 -2
- package/dist/infrastructure/logging/log-redactor.js +1 -1
- package/dist/infrastructure/logging/logging-constants.d.ts +3 -0
- package/dist/infrastructure/logging/logging-constants.js +1 -0
- package/dist/infrastructure/logging/structured-logger.d.ts +1 -1
- package/dist/infrastructure/logging/structured-logger.js +2 -2
- package/dist/infrastructure/observability/tool-execution-logger.d.ts +11 -0
- package/dist/infrastructure/observability/tool-execution-logger.js +1 -0
- package/dist/infrastructure/platform/host-platform.d.ts +2 -0
- package/dist/infrastructure/platform/host-platform.js +1 -1
- package/dist/infrastructure/platform/host-process.d.ts +3 -1
- package/dist/infrastructure/platform/host-process.js +1 -1
- package/dist/infrastructure/platform/platform-constants.d.ts +4 -0
- package/dist/infrastructure/platform/platform-constants.js +1 -0
- package/dist/infrastructure/platform/process-identity.d.ts +8 -0
- package/dist/infrastructure/platform/process-identity.js +1 -0
- package/dist/infrastructure/platform/read-only-executable.d.ts +2 -1
- package/dist/infrastructure/platform/read-only-executable.js +1 -1
- package/dist/infrastructure/sdk/lotagate-client-factory.js +1 -1
- package/dist/infrastructure/sdk/sdk-media-gateway-client.d.ts +4 -0
- package/dist/infrastructure/sdk/sdk-media-gateway-client.js +1 -1
- package/dist/infrastructure/sessions/file-session-store.d.ts +3 -0
- package/dist/infrastructure/sessions/file-session-store.js +4 -4
- package/dist/infrastructure/sessions/session-constants.d.ts +3 -0
- package/dist/infrastructure/sessions/session-constants.js +1 -0
- package/dist/infrastructure/sessions/session-index.js +3 -3
- package/dist/infrastructure/sessions/session-journal-health.d.ts +7 -0
- package/dist/infrastructure/sessions/session-journal-health.js +1 -0
- package/dist/infrastructure/shell/shell-tool-executor.d.ts +5 -1
- package/dist/infrastructure/shell/shell-tool-executor.js +2 -2
- package/dist/infrastructure/tokens/tiktoken-token-estimator.js +1 -1
- package/dist/infrastructure/tokens/token-constants.d.ts +1 -0
- package/dist/infrastructure/tokens/token-constants.js +1 -0
- package/dist/infrastructure/workspace/workspace-settings-store.d.ts +1 -0
- package/dist/infrastructure/workspace/workspace-settings-store.js +4 -4
- package/dist/main.js +3 -3
- package/dist/ports/media-gateway-client.d.ts +6 -0
- package/dist/ports/session-store.d.ts +1 -0
- package/dist/presentation/tui/ink/components/composer.js +4 -4
- package/dist/presentation/tui/ink/components/transcript.d.ts +1 -0
- package/dist/presentation/tui/ink/components/transcript.js +5 -5
- package/dist/presentation/tui/ink/tui-bridge.d.ts +2 -2
- package/dist/presentation/tui/ink/tui-bridge.js +1 -1
- package/dist/presentation/tui/tui-agent-turn-controller.d.ts +45 -0
- package/dist/presentation/tui/tui-agent-turn-controller.js +1 -0
- package/dist/presentation/tui/tui-application-contract.d.ts +1 -0
- package/dist/presentation/tui/tui-application.d.ts +1 -4
- package/dist/presentation/tui/tui-application.js +3 -3
- package/dist/presentation/tui/tui-clipboard-paste-handlers.d.ts +2 -2
- package/dist/presentation/tui/tui-clipboard-paste-handlers.js +1 -1
- package/dist/presentation/tui/tui-command-executor.js +3 -3
- package/dist/presentation/tui/tui-context-compaction.d.ts +4 -1
- package/dist/presentation/tui/tui-context-compaction.js +1 -1
- package/dist/presentation/tui/tui-context-service.d.ts +2 -34
- package/dist/presentation/tui/tui-context-service.js +1 -2
- package/dist/presentation/tui/tui-initial-model.js +1 -1
- package/dist/presentation/tui/tui-tool-approval.d.ts +1 -1
- package/dist/presentation/tui/tui-tool-approval.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/native-targets.mjs +1 -1
- package/package.json +9 -10
- package/scripts/install-native.mjs +5 -13
- package/bin/lotagate.exe +0 -1
- package/dist/application/protocol/document-host-tool-definitions.d.ts +0 -4
- package/dist/application/protocol/document-host-tool-definitions.js +0 -1
- package/dist/application/protocol/document-host-tool-executor.d.ts +0 -49
- package/dist/application/protocol/document-host-tool-executor.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConfigLoader as
|
|
1
|
+
import{ConfigLoader as M}from"../infrastructure/config/config-loader.js";import{StructuredLogger as R}from"../infrastructure/logging/structured-logger.js";import{resolvePlatformPaths as D}from"../infrastructure/platform/platform-paths.js";import{AuthenticationService as L}from"../application/auth/authentication-service.js";import{CompositeCredentialStore as j}from"../infrastructure/credentials/composite-credential-store.js";import{EncryptedFileCredentialStore as k}from"../infrastructure/credentials/encrypted-file-credential-store.js";import{EnvironmentCredentialStore as T}from"../infrastructure/credentials/environment-credential-store.js";import{FileProjectTrustStore as W}from"../infrastructure/project/file-project-trust-store.js";import{ProjectTrustService as x}from"../application/project/project-trust-service.js";import{DefaultShutdownManager as E}from"./shutdown-manager.js";import{FileSessionStore as A}from"../infrastructure/sessions/file-session-store.js";import{WorkspaceSettingsStore as I}from"../infrastructure/workspace/workspace-settings-store.js";import{FileCacheStore as b}from"../infrastructure/cache/file-cache-store.js";import{resolveCachePolicy as G}from"../infrastructure/cache/cache-policy.js";import{DailyRotatingFileWriter as H}from"../infrastructure/logging/daily-rotating-file-writer.js";import{resolveLoggingPolicy as q}from"../infrastructure/logging/logging-policy.js";import{FileGoalStore as z}from"../infrastructure/sessions/file-goal-store.js";import{detectHostPlatform as B}from"../infrastructure/platform/host-platform.js";import{McpRuntime as J,resolveMcpRuntimePolicy as K}from"../infrastructure/extensions/mcp-runtime.js";import{FileMemoryStore as N}from"../infrastructure/memory/file-memory-store.js";import{MemoryService as O}from"../application/memory/memory-service.js";import{SessionExecutionWorkspaceService as Q}from"../application/workspace/session-execution-workspace.js";import{ModelCatalogInFlightRegistry as U}from"../application/model/cached-model-catalog.js";import{CliAgentPreparationCache as V}from"../application/agent/cli-agent-preparation-cache.js";function ve(i={}){const t=B(),e=D(process.env,t),n=new E,c=G(),g=new b(e.cacheDir,c),m=q();let o;try{o=new H(e.logsDir,m)}catch{}const d=i.interactive?o===void 0?"warn":"none":"warn",r=new R({output:i.stderr??process.stderr,level:m.level,consoleLevel:d,...o===void 0?{}:{file:o}}),s=new J(void 0,K(),r);o!==void 0&&n.register(()=>o?.close()),n.register(()=>s.close());const u=new M(r,e),l=new k(e),a=new j([new T,l],l),w=new L(a),p=new W(e),S=new x(p),f=new A(e),h=new z(f),v=new I,C=new O(new N(e,r),void 0,r),y=new Q(e.globalConfigDir,t),P=new U,F=new V;return{platform:t,paths:e,logger:r,configLoader:u,credentialStore:a,auth:w,projectTrustStore:p,projectTrust:S,sessionStore:f,goalStore:h,workspaceSettings:v,cache:g,cachePolicy:c,mcpRuntime:s,memory:C,executionWorkspaces:y,modelCatalogInFlight:P,agentPreparation:F,shutdown:n}}export{ve as createCliRuntime};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CLI_ERROR_CODES as
|
|
1
|
+
import{CLI_ERROR_CODES as r}from"./error-codes.js";class i extends Error{code;category;userMessage;retryable;exitCode;correlationId;details;hint;constructor(t,a,s){super(a,{cause:s.cause}),this.name="CliError",this.code=t,this.category=s.category,this.userMessage=s.userMessage??a,this.retryable=s.retryable??!1,this.exitCode=s.exitCode??1,this.correlationId=s.correlationId,this.details=s.details,this.hint=s.hint}toJSON(){return{code:this.code,category:this.category,message:this.message,userMessage:this.userMessage,retryable:this.retryable,exitCode:this.exitCode,...this.correlationId!==void 0?{correlationId:this.correlationId}:{},...this.details!==void 0?{details:this.details}:{}}}}function h(e){if(e instanceof i)return e;const t=c(e),a=u(e);if(t==="REQUEST_ABORTED"||d(e))return new i(r.INTERRUPTED,n(e),{category:"agent",userMessage:"The request was interrupted.",retryable:!0,...a,cause:e});if(t==="REQUEST_TIMEOUT"||t==="NETWORK_ERROR")return new i(r.MEDIA_REQUEST_FAILED,n(e),{category:"media",userMessage:"The media request could not be completed. Retry the request; if it persists, check the selected model, credentials, and network connection.",retryable:!0,...a,cause:e});if(t==="REQUEST_PAYLOAD_TOO_LARGE"){const s=a.details?.kind==="json-body",o=E(a.details?.maxBytes);return new i(r.INVALID_ARGUMENT,n(e),{category:"media",userMessage:s?`The serialized Gateway request exceeds ${o}. Remove some attachments or reduce the prompt/context.`:"The media request exceeds a Gateway file or aggregate size limit. Review the command options and input file size.",...a,cause:e})}return t==="REQUEST_VALIDATION_ERROR"?new i(r.INVALID_ARGUMENT,n(e),{category:"media",userMessage:"The media request does not satisfy a gateway validation limit. Review the command options and input file size.",...a,cause:e}):t==="RESPONSE_TOO_LARGE"?new i(r.MEDIA_RESPONSE_TOO_LARGE,n(e),{category:"media",userMessage:"The generated media exceeds the supported download size.",retryable:!1,...a,cause:e}):t==="TOOL_ARGUMENTS_INVALID"?new i(r.TOOL_ARGUMENT_INVALID,n(e),{category:"tool",userMessage:"The selected model returned malformed tool arguments. Retry the request or choose a model with reliable tool-calling support.",retryable:!0,cause:e}):t==="TOOL_DENIED"||t==="TOOL_APPROVAL_REQUIRED"?new i(r.TOOL_DENIED,n(e),{category:"tool",userMessage:"The tool action was denied by the active workspace policy. Use interactive approval or configure an explicit workspace permission.",retryable:!1,...a,cause:e}):t==="TOOL_EXECUTION_FAILED"||t==="MCP_OPERATION_FAILED"||t==="MCP_DISCONNECTED"?new i(r.TOOL_EXECUTION_FAILED,n(e),{category:"tool",userMessage:"The selected tool could not complete. Retry the request; if it persists, check the tool or MCP server connection.",retryable:!0,...a,cause:e}):t==="TOOL_NOT_FOUND"?new i(r.MODEL_STREAM_FAILED,n(e),{category:"model",userMessage:"The selected model requested a tool that is unavailable in this CLI session. Retry the request or choose another model.",retryable:!0,cause:e}):t==="AGENT_LIMIT_EXCEEDED"?new i(r.AGENT_STUCK,n(e),{category:"agent",userMessage:"The agent reached a safety limit before completing. Narrow the task and try again.",retryable:!0,cause:e}):t==="MODEL_RESPONSE_INVALID"||t==="RESPONSE_PARSE_ERROR"||f(e)?new i(r.MODEL_STREAM_FAILED,n(e),{category:"model",userMessage:"The model provider could not complete the request. Retry; if it persists, check the selected model, credentials, and base URL.",retryable:!0,cause:e}):new i(r.INTERNAL_ERROR,e instanceof Error?e.message:String(e),{category:"general",userMessage:"An internal error occurred.",hint:{actionId:"doctor"},cause:e})}function c(e){if(typeof e!="object"||e===null)return;const t=e;return typeof t.code=="string"?t.code:typeof t.errorCode=="string"?t.errorCode:void 0}function d(e){let t=e;for(let a=0;a<5&&t!==void 0&&t!==null;a+=1){if(typeof t!="object")return!1;const s=t;if(s.name==="AbortError"||s.code==="ABORT_ERR"||typeof s.message=="string"&&/\b(aborted|cancelled|canceled)\b/iu.test(s.message))return!0;t=s.cause}return!1}function u(e){if(typeof e!="object"||e===null)return{};const t=e;return{...typeof t.correlationId=="string"?{correlationId:t.correlationId}:{},...l(t.details)?{details:t.details}:{}}}function l(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"the configured size limit";const t=e/1e6;return Number.isInteger(t)?`${t} MB`:`${e} bytes`}function f(e){return n(e)==="Upstream AI provider request failed."}function n(e){return e instanceof Error?e.message:String(e)}export{i as CliError,h as asCliError};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MAX_PLUGIN_DISPLAY_NAME_LENGTH = 128;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=128;export{_ as MAX_PLUGIN_DISPLAY_NAME_LENGTH};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={browser:"browser-use",computer:"computer-use"
|
|
1
|
+
const e={browser:"browser-use",computer:"computer-use"};export{e as HOST_TOOL_PLUGIN_IDS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CliError as g}from"../errors/cli-error.js";import{CLI_ERROR_CODES as h}from"../errors/error-codes.js";import{findUnexpectedRecordKey as N,isRecord as w}from"../validation/record-schema.js";const
|
|
1
|
+
import{CliError as g}from"../errors/cli-error.js";import{CLI_ERROR_CODES as h}from"../errors/error-codes.js";import{findUnexpectedRecordKey as N,isRecord as w}from"../validation/record-schema.js";import{MAX_PLUGIN_DISPLAY_NAME_LENGTH as y}from"./extension-constants.js";const v={markerDirectory:".lotagate-plugin",manifestFile:"plugin.json",skillsDirectory:"skills",agentsDirectory:"agents",hooksDirectory:"hooks",mcpDirectory:"mcp",readmeFile:"README.md",licenseFile:"LICENSE"};function L(n,t){if(!w(n))throw i("Manifest must be a JSON object.");const e=n,r=N(e,["name","displayName","version","description","author","license","homepage","repository","keywords"]);if(r!==void 0)throw i(`Unsupported manifest field: \`${r}\`.`);const s=e.name,d=A(e),a=e.version,f=o(e,"description"),u=o(e,"author"),c=o(e,"license"),m=o(e,"homepage"),l=o(e,"repository"),p=k(e,"keywords");if(typeof s!="string"||!/^[a-z0-9][a-z0-9-]{0,63}$/.test(s))throw i("Plugin name must use lowercase kebab-case.");if(typeof a!="string"||!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(a))throw i("Plugin version must be semver-like.");return{name:s,...d===void 0?{}:{displayName:d},version:a,...f===void 0?{}:{description:f},...u===void 0?{}:{author:u},...c===void 0?{}:{license:c},...m===void 0?{}:{homepage:m},...l===void 0?{}:{repository:l},...p===void 0?{}:{keywords:p},directory:t}}function A(n){const t=n.displayName;if(t===void 0)return;if(typeof t!="string")throw i("Manifest field `displayName` must be a string.");const e=t.trim();if(e.length===0||e.length>y||M(e))throw i(`Manifest field \`displayName\` must be a non-empty string of at most ${y} characters.`);return e}function M(n){return[...n].some(t=>{const e=t.codePointAt(0)??0;return e<32||e===127})}function o(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw i(`Manifest field \`${t}\` must be a string.`);return e}}function k(n,t){const e=n[t];if(e!==void 0){if(!Array.isArray(e)||e.some(r=>typeof r!="string"||r.trim().length===0))throw i(`Manifest field \`${t}\` must be an array of non-empty strings.`);return e.map(r=>r.trim())}}function i(n){return new g(h.PLUGIN_MANIFEST_INVALID,n,{category:"extension",userMessage:`Invalid plugin: ${n}`})}export{v as PLUGIN_LAYOUT,L as parsePluginManifest};
|
|
@@ -18,14 +18,6 @@ export interface IntentCompilationInput {
|
|
|
18
18
|
readonly objective: string;
|
|
19
19
|
readonly steps: readonly Omit<IntentStep, 'id'>[];
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Applies a deterministic safety correction to the model-assisted intent
|
|
23
|
-
* classification. Direct information questions are answer work, even when
|
|
24
|
-
* the model describes them with a research-like objective such as "find".
|
|
25
|
-
* Explicit work requests remain unchanged and continue through host evidence
|
|
26
|
-
* and verification gates.
|
|
27
|
-
*/
|
|
28
|
-
export declare function stabilizeIntentCompilation(prompt: string, input: IntentCompilationInput): IntentCompilationInput;
|
|
29
21
|
export interface CompletionAssessment {
|
|
30
22
|
readonly decision: 'complete' | 'continue';
|
|
31
23
|
readonly missing: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p from"node:crypto";import{CliError as f}from"../errors/cli-error.js";import{CLI_ERROR_CODES as d}from"../errors/error-codes.js";import{findUnexpectedRecordKey as s,isRecord as a}from"../validation/record-schema.js";const u=["answer","research","change","automation"];function l(t){return t==="change"||t==="automation"}function h(t,n=new Date().toISOString()){const e=m(t),i=l(e.kind);return{id:p.randomUUID(),kind:e.kind,objective:e.objective,steps:e.steps.map((o,c)=>({...o,requiresVerification:i||o.requiresVerification,id:`step-${c+1}`})),createdAt:n}}function m(t){if(!a(t))throw r("Intent compilation must be an object.");const n=s(t,["kind","objective","steps"]);if(n!==void 0)throw r(`Unsupported intent field: ${n}.`);const e=t.kind,i=t.objective,o=t.steps;if(!g(e))throw r("Intent kind is invalid.");if(typeof i!="string"||i.trim().length===0||i.length>16384)throw r("Intent objective is invalid.");if(!Array.isArray(o)||o.length===0||o.length>10)throw r("Intent requires between one and ten steps.");return{kind:e,objective:i.trim(),steps:o.map(I)}}function j(t){const n=t.trim();if(n.length===0)throw r("Intent objective is required.");return h({kind:"change",objective:n,steps:[{title:"Handle and verify the requested outcome",acceptanceCriteria:[n],requiresVerification:!0}]})}function g(t){return typeof t=="string"&&u.includes(t)}function I(t){if(!a(t))throw r("Intent step is invalid.");const n=s(t,["title","acceptanceCriteria","requiresVerification"]);if(n!==void 0)throw r(`Unsupported intent step field: ${n}.`);const e=t.title,i=t.acceptanceCriteria,o=t.requiresVerification;if(typeof e!="string"||e.trim().length===0||e.length>2048)throw r("Intent step title is invalid.");if(!Array.isArray(i)||i.length===0||i.length>16||i.some(c=>typeof c!="string"||c.trim().length===0||c.length>2048))throw r("Intent acceptance criteria are invalid.");if(typeof o!="boolean")throw r("Intent verification requirement is invalid.");return{title:e.trim(),acceptanceCriteria:i.map(c=>String(c).trim()),requiresVerification:o}}function r(t){return new f(d.INVALID_ARGUMENT,t,{category:"intent",userMessage:t})}export{u as INTENT_KINDS,h as createIntentContract,j as fallbackIntent,g as isIntentKind,m as normalizeIntentCompilation,l as requiresHostVerification};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CliError as I}from"../errors/cli-error.js";import{CLI_ERROR_CODES as l}from"../errors/error-codes.js";const
|
|
1
|
+
import{CliError as I}from"../errors/cli-error.js";import{CLI_ERROR_CODES as l}from"../errors/error-codes.js";const p=1e3,s=1e6,u={imagePromptCharacters:32e3,imageCount:16,imageEditFileBytes:47*s,imageEditMaskBytes:4*s,imageEditTotalBytes:128*s,audioUploadBytes:50*s,speechInputCharacters:4096,speechInstructionsCharacters:4096,speechVoiceCharacters:64,audioPromptCharacters:4096,transcriptionLanguageCharacters:10},M=50*1024*1024;function O(e,t,i){v(i),(e==="image.generate"||e==="image.edit")&&C(t,i),e==="image.edit"&&E(i),e==="audio.speech"&&_(t,i),e==="audio.transcribe"&&h(i,!0),e==="audio.translate"&&h(i,!1),e==="video.generate"&&$(i)}function T(e){if(e.length===0)throw n("`--image` requires at least one workspace image path.");if(e.length>u.imageCount)throw n(`Image edits support at most ${u.imageCount} input images.`)}function A(e,t,i){if(!(e>0&&e<=t))throw n(`${i} must be between 1 byte and ${f(t)}.`)}function q(e){if(!(e<=u.imageEditTotalBytes))throw n(`Image edit uploads must not exceed ${f(u.imageEditTotalBytes)} in total.`)}function f(e){return e>=s?`${e/s} MB`:e>=p?`${e/p} KB`:`${e} bytes`}function v(e){const t=r(e,"out");if(c(e,"force")&&t===void 0)throw n("`--force` is only valid with `--out`.")}function C(e,t){d(w(e,"image"),u.imagePromptCharacters,"Image prompt");const i=g(t,"n");if(i!==void 0&&(i<1||i>u.imageCount))throw n(`--n must be an integer between 1 and ${u.imageCount}.`);if(i!==void 0&&i>1&&r(t,"out")!==void 0)throw n("--out can only be used when exactly one image artifact is requested. Use --out-dir instead.");const o=r(t,"size");if(o!==void 0&&o!=="auto"&&!/^\d{2,4}x\d{2,4}$/u.test(o))throw n("--size must be `auto` or WIDTHxHEIGHT.");o!==void 0&&o!=="auto"&&S(o);const a=r(t,"output-format"),m=g(t,"output-compression");if(m!==void 0&&(m<0||m>100))throw n("--output-compression must be an integer between 0 and 100.");if(m!==void 0&&a!=="jpeg"&&a!=="webp")throw n("--output-compression requires --output-format jpeg or webp.");d(r(t,"moderation"),64,"Moderation value"),d(r(t,"user"),255,"User value")}function E(e){if(r(e,"image")===void 0)throw n("Missing required option --image.")}function _(e,t){d(w(e,"speech"),u.speechInputCharacters,"Speech input"),d(x(t,"voice"),u.speechVoiceCharacters,"Voice"),d(r(t,"instructions"),u.speechInstructionsCharacters,"Speech instructions");const i=r(t,"stream-format");if(i!==void 0&&i!=="audio"&&i!=="sse")throw n("--stream-format must be either `audio` or `sse`.");if(i==="sse"&&(r(t,"out")!==void 0||r(t,"out-dir")!==void 0||c(t,"force")))throw n("--stream-format sse cannot be combined with output file options.");const o=b(t,"speed");if(o!==void 0&&(o<.25||o>4))throw n("--speed must be between 0.25 and 4.")}function h(e,t){d(r(e,"prompt"),u.audioPromptCharacters,"Audio prompt");const i=b(e,"temperature");if(i!==void 0&&(i<0||i>1))throw n("--temperature must be between 0 and 1.");if(t&&(d(r(e,"language"),u.transcriptionLanguageCharacters,"Language code"),r(e,"timestamp-granularities")!==void 0&&r(e,"response-format")!=="verbose_json"))throw n("--timestamp-granularities requires --response-format verbose_json.")}function $(e){if(c(e,"no-wait")&&(r(e,"out")!==void 0||r(e,"out-dir")!==void 0||c(e,"force")))throw n("--no-wait cannot be combined with output options. Use video download after the operation completes.")}function S(e){const[t,i]=e.split("x"),o=Number(t),a=Number(i);if(!Number.isSafeInteger(o)||!Number.isSafeInteger(a)||o<1||a<1||o>4096||a>4096||Math.max(o,a)/Math.min(o,a)>3||o%16!==0||a%16!==0)throw n("--size must use positive dimensions up to 4096px, a maximum 3:1 aspect ratio, and multiples of 16.")}function w(e,t){const i=e.join(" ").trim();if(i.length===0)throw n(`A prompt is required for ${t}.`);return i}function x(e,t){const i=r(e,t);if(i===void 0)throw n(`Missing required option --${t}.`);return i}function d(e,t,i){if(e!==void 0&&e.length>t)throw n(`${i} must not exceed ${t} characters.`)}function g(e,t){const i=r(e,t);if(i!==void 0){if(!/^\d+$/u.test(i)||!Number.isSafeInteger(Number(i)))throw n(`--${t} must be an integer.`);return Number(i)}}function b(e,t){const i=r(e,t);if(i===void 0)return;const o=Number(i);if(!Number.isFinite(o))throw n(`--${t} must be a finite number.`);return o}function r(e,t){const i=e.get(t);return typeof i=="string"&&i.trim().length>0?i.trim():void 0}function c(e,t){return e.get(t)===!0||e.get(t)==="true"}function n(e){return new I(l.INVALID_ARGUMENT,e,{category:"media",userMessage:e})}export{u as GATEWAY_MEDIA_LIMITS,M as SDK_BINARY_MEDIA_RESPONSE_BYTES,f as formatByteLimit,T as validateImageEditInputCount,q as validateImageEditTotalSize,O as validateMediaCommandOptions,A as validateUploadSize};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=5e3,E=12e5,T=6e4;export{T as DEFAULT_MEDIA_DOWNLOAD_TIMEOUT_MS,_ as DEFAULT_VIDEO_POLL_INTERVAL_MS,E as DEFAULT_VIDEO_WAIT_TIMEOUT_MS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CliError as E}from"../errors/cli-error.js";import{CLI_ERROR_CODES as I}from"../errors/error-codes.js";
|
|
1
|
+
import{CliError as E}from"../errors/cli-error.js";import{CLI_ERROR_CODES as I}from"../errors/error-codes.js";import{DEFAULT_MEDIA_DOWNLOAD_TIMEOUT_MS as O,DEFAULT_VIDEO_POLL_INTERVAL_MS as A,DEFAULT_VIDEO_WAIT_TIMEOUT_MS as n}from"./media-constants.js";function D(t=process.env){const _=r(t,"LOTAGATE_VIDEO_POLL_INTERVAL_MS",A),o=r(t,"LOTAGATE_VIDEO_WAIT_TIMEOUT_MS",n);if(o<_)throw T("LOTAGATE_VIDEO_WAIT_TIMEOUT_MS must not be smaller than LOTAGATE_VIDEO_POLL_INTERVAL_MS.");return{videoPollIntervalMs:_,videoWaitTimeoutMs:o,downloadTimeoutMs:r(t,"LOTAGATE_MEDIA_DOWNLOAD_TIMEOUT_MS",O)}}function r(t,_,o){const e=t[_];if(e===void 0||e.trim().length===0)return o;if(!/^\d+$/u.test(e))throw T(`${_} must be a positive integer.`);const i=Number(e);if(!Number.isSafeInteger(i)||i<=0)throw T(`${_} must be a positive integer.`);return i}function T(t){return new E(I.CONFIG_SCHEMA_INVALID,t,{category:"config",userMessage:t})}export{D as resolveMediaExecutionPolicy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=2,t=1.2,_=.75;export{_ as BM25_B,t as BM25_K1,o as SEARCH_TOKEN_MIN_LENGTH};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`))}function
|
|
1
|
+
import{BM25_B as d,BM25_K1 as f,SEARCH_TOKEN_MIN_LENGTH as h}from"./memory-constants.js";function k(e){const n=new Map,c={};let i=0;for(const r of e){const t=new Map;for(const s of y(r))t.set(s,(t.get(s)??0)+1);const o=Object.fromEntries(t.entries()),a=Object.values(o).reduce((s,l)=>s+l,0);c[r.id]={id:r.id,termFrequency:o,length:a},i+=a;for(const s of t.keys()){const l=n.get(s)??new Set;l.add(r.id),n.set(s,l)}}const u=Object.fromEntries([...n.entries()].map(([r,t])=>[r,[...t].sort()])),m=Object.fromEntries(Object.entries(u).map(([r,t])=>[r,t.length]));return{documents:c,postings:u,documentFrequency:m,averageDocumentLength:e.length===0?0:i/e.length}}function F(e,n,c){if(c.maximum<=0)return[];const i=p(c.text);if(i.length===0)return[];const u=new Set;for(const t of i)for(const o of n.postings[t]??[])u.add(o);const m=Object.keys(n.documents).length,r=[...u].flatMap(t=>{const o=e[t],a=n.documents[t];if(o===void 0||a===void 0||!b(o))return[];const s=M(a,i,n,m);return s>0?[{record:o,lexicalScore:s,rank:0}]:[]});return r.sort((t,o)=>o.lexicalScore-t.lexicalScore||o.record.updatedAt.localeCompare(t.record.updatedAt)||t.record.id.localeCompare(o.record.id)),r.slice(0,c.maximum).map((t,o)=>({...t,rank:o+1}))}function x(e){return e.normalize("NFKC").toLocaleLowerCase()}function p(e){const n=x(e),c=n.normalize("NFD").replace(/[\u0300-\u036f]/gu,"");return[...new Set([...g(n),...g(c)])]}function b(e,n=Date.now()){return e.state==="active"&&(e.expiresAt===void 0||Date.parse(e.expiresAt)>n)}function y(e){return p([e.statement,e.rationale??"",...e.topics].join(`
|
|
2
|
+
`))}function g(e){return e.split(/[^\p{L}\p{N}_-]+/u).filter(n=>n.length>=h)}function M(e,n,c,i){return c.averageDocumentLength<=0||e.length<=0?0:n.reduce((u,m)=>{const r=e.termFrequency[m]??0,t=c.documentFrequency[m]??0;if(r===0||t===0)return u;const o=Math.log(1+(i-t+.5)/(t+.5)),a=r+f*(1-d+d*e.length/c.averageDocumentLength);return u+o*r*(f+1)/a},0)}export{k as buildMemorySearchIndex,b as isMemoryRetrievable,x as normalizeSearchText,F as searchMemoryIndex,p as uniqueTokens};
|
|
@@ -53,6 +53,5 @@ export declare function isGoalState(value: unknown): value is GoalState;
|
|
|
53
53
|
export declare function isGoalEvaluation(value: unknown): value is GoalEvaluation;
|
|
54
54
|
/** Validates the data payload written by a durable goal lifecycle event. */
|
|
55
55
|
export declare function isPersistedGoalEventData(value: unknown): boolean;
|
|
56
|
-
export declare function transitionGoal(state: GoalState, status: GoalStatus): GoalState;
|
|
57
56
|
export declare function addGoalUsage(current: GoalUsage, delta: GoalUsageDelta): GoalUsage;
|
|
58
57
|
export declare const EMPTY_GOAL_USAGE: GoalUsage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{RESOURCE_LIMITS as n}from"../runtime/resource-limits.js";const
|
|
1
|
+
import{RESOURCE_LIMITS as n}from"../runtime/resource-limits.js";import{CliError as c}from"../errors/cli-error.js";import{CLI_ERROR_CODES as p}from"../errors/error-codes.js";const l=new Set(["goal.created","goal.replaced","goal.paused","goal.resumed","goal.evaluated","goal.completed","goal.blocked","goal.budget_limited","goal.usage_limited","goal.usage_recorded","goal.cleared","goal.turn.started"]);function S(t){const e=t.objective.trim();if(e.length===0||Buffer.byteLength(e,"utf8")>n.goalObjectiveBytes||/\0/u.test(e))throw d(`Goal objective must contain between 1 and ${n.goalObjectiveBytes} bytes and must not contain null characters.`);for(const[r,i]of Object.entries(t))if(!(r==="objective"||i===void 0)&&(!Number.isSafeInteger(i)||i<=0))throw d(`Goal limit ${r} must be a positive integer.`);if(t.maxDurationMs!==void 0&&t.maxDurationMs>n.goalMaximumMaxDurationMs)throw d("Goal maxDurationMs cannot exceed the supported maximum.");return{objective:e,...t.tokenBudget===void 0?{}:{tokenBudget:t.tokenBudget},...t.maxTurns===void 0?{}:{maxTurns:t.maxTurns},...t.maxDurationMs===void 0?{}:{maxDurationMs:t.maxDurationMs}}}function B(t){return l.has(t)}function b(t){return a(t)?typeof t.id=="string"&&typeof t.sessionId=="string"&&G(t.objective)&&y(t.status)&&f(t.createdAt)&&f(t.updatedAt)&&f(t.startedAt)&&o(t.turns)&&o(t.evaluatorRuns)&&k(t.usage)&&g(t.tokenBudget)&&g(t.maxTurns)&&E(t.maxDurationMs)&&x(t.lastEvaluation)&&(t.lastError===void 0||typeof t.lastError=="string"&&Buffer.byteLength(t.lastError,"utf8")<=n.goalReasonBytes):!1}function u(t){return a(t)?T(t.decision)&&typeof t.reason=="string"&&Buffer.byteLength(t.reason,"utf8")<=n.goalReasonBytes&&Array.isArray(t.evidence)&&t.evidence.length<=n.goalEvidenceItems&&t.evidence.every(e=>typeof e=="string"&&Buffer.byteLength(e,"utf8")<=n.goalEvidenceBytes)&&f(t.timestamp)&&(t.evaluatorModel===void 0||typeof t.evaluatorModel=="string"):!1}function D(t){return!a(t)||!b(t.goal)?!1:t.evaluation===void 0||u(t.evaluation)}function h(t,e){const r=s(t.inputTokens+(e.inputTokens??0)),i=s(t.outputTokens+(e.outputTokens??0)),m=s(t.totalTokens+(e.totalTokens??(e.inputTokens??0)+(e.outputTokens??0)));return{inputTokens:r,outputTokens:i,totalTokens:m,modelCalls:s(t.modelCalls+(e.modelCalls??0)),estimated:t.estimated||e.estimated===!0}}const A=Object.freeze({inputTokens:0,outputTokens:0,totalTokens:0,modelCalls:0,estimated:!1});function s(t){return Number.isSafeInteger(t)&&t>=0?t:Number.MAX_SAFE_INTEGER}function a(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function y(t){return t==="active"||t==="paused"||t==="completed"||t==="blocked"||t==="budget_limited"||t==="usage_limited"}function T(t){return t==="continue"||t==="complete"||t==="blocked"||t==="budget_limited"||t==="usage_limited"}function k(t){return a(t)?o(t.inputTokens)&&o(t.outputTokens)&&o(t.totalTokens)&&o(t.modelCalls)&&typeof t.estimated=="boolean":!1}function x(t){return t===void 0||u(t)}function g(t){return t===void 0||typeof t=="number"&&Number.isSafeInteger(t)&&t>0}function E(t){return t===void 0||typeof t=="number"&&Number.isSafeInteger(t)&&t>0&&t<=n.goalMaximumMaxDurationMs}function o(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function f(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function G(t){return typeof t=="string"&&t.trim().length>0&&Buffer.byteLength(t,"utf8")<=n.goalObjectiveBytes&&!/\0/u.test(t)}function d(t){return new c(p.INVALID_ARGUMENT,t,{category:"goal",userMessage:t})}export{A as EMPTY_GOAL_USAGE,h as addGoalUsage,u as isGoalEvaluation,B as isGoalEventType,b as isGoalState,D as isPersistedGoalEventData,S as validateGoalInput};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export declare const MAX_WORK_PLAN_STEPS = 10;
|
|
2
1
|
export type WorkItemStatus = 'queued' | 'active' | 'completed' | 'failed' | 'blocked';
|
|
3
|
-
export type WorkPlanStatus = 'active' | 'completed' | 'failed' | 'blocked';
|
|
4
|
-
export type WorkEvidenceKind = 'read' | 'diff' | 'test' | 'typecheck' | 'lint' | 'build' | 'runtime';
|
|
5
2
|
export interface WorkItem {
|
|
6
3
|
id: string;
|
|
7
4
|
title: string;
|
|
@@ -10,68 +7,9 @@ export interface WorkItem {
|
|
|
10
7
|
status: WorkItemStatus;
|
|
11
8
|
assignedAgent?: string;
|
|
12
9
|
}
|
|
13
|
-
export interface WorkPlanStep extends WorkItem {
|
|
14
|
-
index: number;
|
|
15
|
-
scope: readonly string[];
|
|
16
|
-
acceptanceCriteria: readonly string[];
|
|
17
|
-
verificationHints: readonly string[];
|
|
18
|
-
evidenceIds: readonly string[];
|
|
19
|
-
}
|
|
20
|
-
export interface WorkPlan {
|
|
21
|
-
id: string;
|
|
22
|
-
turnId: string;
|
|
23
|
-
goal: string;
|
|
24
|
-
language: string;
|
|
25
|
-
version: number;
|
|
26
|
-
status: WorkPlanStatus;
|
|
27
|
-
steps: readonly WorkPlanStep[];
|
|
28
|
-
createdAt: string;
|
|
29
|
-
updatedAt: string;
|
|
30
|
-
}
|
|
31
|
-
export interface WorkEvidence {
|
|
32
|
-
id: string;
|
|
33
|
-
turnId: string;
|
|
34
|
-
planId: string;
|
|
35
|
-
stepId: string;
|
|
36
|
-
kind: WorkEvidenceKind;
|
|
37
|
-
summary: string;
|
|
38
|
-
status: 'passed' | 'failed' | 'informational';
|
|
39
|
-
command?: string;
|
|
40
|
-
paths?: readonly string[];
|
|
41
|
-
exitCode?: number;
|
|
42
|
-
createdAt: string;
|
|
43
|
-
}
|
|
44
10
|
export interface SchedulerLimits {
|
|
45
11
|
maxConcurrency: number;
|
|
46
12
|
maxTasks: number;
|
|
47
13
|
maxDurationMs: number;
|
|
48
14
|
maxTokens?: number;
|
|
49
15
|
}
|
|
50
|
-
export interface WorkPlanUpdateInput {
|
|
51
|
-
action: 'create' | 'replace' | 'step_status' | 'record_evidence' | 'complete' | 'fail' | 'block';
|
|
52
|
-
goal?: string;
|
|
53
|
-
language?: string;
|
|
54
|
-
steps?: readonly WorkPlanStepInput[];
|
|
55
|
-
stepId?: string;
|
|
56
|
-
status?: Exclude<WorkItemStatus, 'queued'>;
|
|
57
|
-
evidence?: WorkEvidenceInput;
|
|
58
|
-
reason?: string;
|
|
59
|
-
}
|
|
60
|
-
export interface WorkPlanStepInput {
|
|
61
|
-
id: string;
|
|
62
|
-
title: string;
|
|
63
|
-
description: string;
|
|
64
|
-
dependencies?: readonly string[];
|
|
65
|
-
scope?: readonly string[];
|
|
66
|
-
acceptanceCriteria: readonly string[];
|
|
67
|
-
verificationHints?: readonly string[];
|
|
68
|
-
}
|
|
69
|
-
export interface WorkEvidenceInput {
|
|
70
|
-
stepId: string;
|
|
71
|
-
kind: WorkEvidenceKind;
|
|
72
|
-
summary: string;
|
|
73
|
-
status: WorkEvidence['status'];
|
|
74
|
-
command?: string;
|
|
75
|
-
paths?: readonly string[];
|
|
76
|
-
exitCode?: number;
|
|
77
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const _=10;export{_ as MAX_WORK_PLAN_STEPS};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a provider assistant frame into the text that has not already been
|
|
3
|
+
* emitted for the current model segment.
|
|
4
|
+
*
|
|
5
|
+
* Providers normally send incremental frames, but compatibility gateways can
|
|
6
|
+
* send cumulative snapshots or replay an already-complete text fragment. The
|
|
7
|
+
* model boundary is the single place where those representations are
|
|
8
|
+
* normalized before they reach the Agent SDK and the desktop JSONL protocol.
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeAssistantDelta(previousText: string, incomingDelta: string): string;
|
|
11
|
+
export declare function mergeAssistantText(previousText: string, incomingDelta: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(t,n){if(n.length===0)return"";const i=n.startsWith(t)?n.slice(t.length):n,r=f(i);return r.length===0||t.endsWith(r)&&c(r)?"":r}function h(t,n){return`${t}${d(t,n)}`}function f(t){if(t.length<2)return t;const n=new Array(t.length).fill(0);for(let s=1;s<t.length;s+=1){let e=n[s-1]??0;for(;e>0&&t[s]!==t[e];)e=n[e-1]??0;t[s]===t[e]&&(e+=1),n[s]=e}const i=n.at(-1)??0,r=t.length-i,o=t.slice(0,r);return i>0&&t.length%r===0&&c(o)?o:t}function c(t){const n=t.trimEnd().at(-1);return n!==void 0&&/[\p{P}\p{S}]/u.test(n)}export{h as mergeAssistantText,d as normalizeAssistantDelta};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Public Gateway JSON body limit mirrored from the server and SDK contract. */
|
|
2
|
+
export declare const GATEWAY_JSON_BODY_LIMIT_BYTES: number;
|
|
3
|
+
export declare const GATEWAY_JSON_NEAR_LIMIT_RATIO = 0.8;
|
|
4
|
+
export interface GatewayAttachmentBudgetInput {
|
|
5
|
+
readonly byteLength: number;
|
|
6
|
+
readonly mimeType: string;
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GatewayRequestBudget {
|
|
10
|
+
readonly projectedBytes: number;
|
|
11
|
+
readonly limitBytes: number;
|
|
12
|
+
readonly remainingBytes: number;
|
|
13
|
+
readonly utilization: number;
|
|
14
|
+
readonly isWithinLimit: boolean;
|
|
15
|
+
readonly isNearLimit: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function estimateGatewayMessageBytes(prompt: string, attachments?: readonly GatewayAttachmentBudgetInput[]): number;
|
|
18
|
+
export declare function evaluateGatewayRequestBudget(prompt: string, attachments?: readonly GatewayAttachmentBudgetInput[], reservedBytes?: number): GatewayRequestBudget;
|
|
19
|
+
export declare function base64ByteLength(byteLength: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const T=2e7,u=.8;function a(e,t=[]){const i=t.length===0?{role:"user",content:e}:{role:"user",content:[{type:"text",text:e},...t.map(o)]};return Buffer.byteLength(JSON.stringify({messages:[i]}),"utf8")+t.reduce((_,r)=>_+s(r.byteLength),0)}function A(e,t=[],i=0){const n=a(e,t)+Math.max(0,i),_=2e7-n;return{projectedBytes:n,limitBytes:2e7,remainingBytes:_,utilization:n/2e7,isWithinLimit:n<=2e7,isNearLimit:n>=2e7*.8}}function s(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError("Attachment byte length must be a non-negative safe integer.");return Math.ceil(e/3)*4}function o(e){const t=`data:${e.mimeType};base64:`;return e.mimeType.startsWith("image/")?{type:"image_url",image_url:{url:t,detail:"auto"}}:{type:"input_file",file_data:t,filename:e.name??"attachment",media_type:e.mimeType}}export{T as GATEWAY_JSON_BODY_LIMIT_BYTES,u as GATEWAY_JSON_NEAR_LIMIT_RATIO,s as base64ByteLength,a as estimateGatewayMessageBytes,A as evaluateGatewayRequestBudget};
|
|
@@ -3,6 +3,7 @@ export declare const RESOURCE_LIMITS: {
|
|
|
3
3
|
readonly processTerminationGraceMs: 500;
|
|
4
4
|
readonly processTerminationTimeoutMs: 2000;
|
|
5
5
|
readonly configFileBytes: number;
|
|
6
|
+
readonly sessionIndexBytes: number;
|
|
6
7
|
readonly workspaceSettingsBytes: number;
|
|
7
8
|
readonly mcpConfigBytes: number;
|
|
8
9
|
readonly sessionBundleBytes: number;
|
|
@@ -25,12 +26,15 @@ export declare const RESOURCE_LIMITS: {
|
|
|
25
26
|
readonly memoryEvidenceReferenceBytes: 512;
|
|
26
27
|
readonly memoryContextRecords: 12;
|
|
27
28
|
readonly jsonlLineBytes: number;
|
|
29
|
+
/** Desktop protocol responses may carry bounded base64 speech payloads. */
|
|
30
|
+
readonly desktopJsonlLineBytes: number;
|
|
28
31
|
readonly desktopAttachmentChunkBytes: number;
|
|
29
32
|
readonly jsonlIdBytes: 256;
|
|
30
33
|
readonly jsonlPathBytes: 4096;
|
|
31
34
|
readonly jsonlPromptBytes: number;
|
|
32
35
|
readonly pendingAttachments: 16;
|
|
33
36
|
readonly pendingAttachmentTotalBytes: number;
|
|
37
|
+
readonly desktopAttachmentTtlMs: number;
|
|
34
38
|
readonly maxAttachmentBytes: number;
|
|
35
39
|
readonly clipboardTextBytes: number;
|
|
36
40
|
readonly clipboardTimeoutMs: 15000;
|
|
@@ -48,10 +52,12 @@ export declare const RESOURCE_LIMITS: {
|
|
|
48
52
|
readonly subagentMaxTokens: 200000;
|
|
49
53
|
readonly subagentMaxConcurrent: 4;
|
|
50
54
|
readonly subagentMaxRetainedJobs: 32;
|
|
55
|
+
readonly desktopSessionStoreMaxEntries: 20;
|
|
51
56
|
readonly subagentMaxIterations: 200;
|
|
52
57
|
readonly subagentMaxToolCallsPerTurn: 100;
|
|
53
58
|
readonly agentMaxIterations: 500;
|
|
54
59
|
readonly agentMaxToolCallsPerTurn: 1;
|
|
60
|
+
readonly intentMaxCompletionAttempts: 2;
|
|
55
61
|
readonly subagentToolArgumentBytes: number;
|
|
56
62
|
readonly subagentToolResultBytes: number;
|
|
57
63
|
readonly goalObjectiveBytes: number;
|
|
@@ -65,11 +71,22 @@ export declare const RESOURCE_LIMITS: {
|
|
|
65
71
|
readonly goalMaximumMaxDurationMs: number;
|
|
66
72
|
readonly goalDefaultMaxEvaluatorRuns: 100;
|
|
67
73
|
readonly tuiTranscriptMessages: 2000;
|
|
74
|
+
readonly tuiAgentSessionMaxEntries: 4;
|
|
75
|
+
readonly tuiAgentSessionMaxBytes: number;
|
|
76
|
+
readonly agentPreparationCacheMaxEntries: 8;
|
|
77
|
+
readonly agentPreparationCacheMaxBytes: number;
|
|
78
|
+
readonly contextTokenCacheMaxEntries: 8;
|
|
79
|
+
readonly contextTokenCacheMaxBytes: number;
|
|
68
80
|
readonly jsonlMaxInFlight: 4;
|
|
81
|
+
readonly protocolWriteQueueEntries: 256;
|
|
82
|
+
readonly protocolWriteQueueBytes: number;
|
|
69
83
|
readonly workspaceReferenceCount: 32;
|
|
70
84
|
readonly workspaceReferenceInstructionBytes: number;
|
|
71
85
|
readonly logQueueEntries: 10000;
|
|
72
86
|
readonly logQueueBytes: number;
|
|
73
87
|
readonly internalProcessTimeoutMs: number;
|
|
74
88
|
readonly internalProcessOutputBytes: number;
|
|
89
|
+
readonly hostShellTimeoutMs: 120000;
|
|
90
|
+
readonly guestShellTimeoutMs: number;
|
|
91
|
+
readonly defaultShellTimeoutMs: 30000;
|
|
75
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={processTerminationGraceMs:500,processTerminationTimeoutMs:2e3,configFileBytes:262144,workspaceSettingsBytes:262144,mcpConfigBytes:524288,sessionBundleBytes:20971520,sessionJournalBytes:20971520,sessionEvents:1e5,sessionTranscriptEntries:5e4,sessionAttachments:32,sessionAttachmentTotalBytes:
|
|
1
|
+
const e=1e6,t={processTerminationGraceMs:500,processTerminationTimeoutMs:2e3,configFileBytes:262144,sessionIndexBytes:8388608,workspaceSettingsBytes:262144,mcpConfigBytes:524288,sessionBundleBytes:20971520,sessionJournalBytes:20971520,sessionEvents:1e5,sessionTranscriptEntries:5e4,sessionAttachments:32,sessionAttachmentTotalBytes:5e7,sessionTextBytes:524288,memoryJournalBytes:8388608,memoryIndexBytes:8388608,memoryBundleBytes:8388608,memoryRecords:2e3,memoryStatementBytes:4096,memoryRationaleBytes:2048,memoryTopics:16,memoryTopicBytes:256,memorySupersedes:16,memoryEvidenceReferences:32,memoryEvidenceReferenceBytes:512,memoryContextRecords:12,jsonlLineBytes:1048576,desktopJsonlLineBytes:4194304,desktopAttachmentChunkBytes:524288,jsonlIdBytes:256,jsonlPathBytes:4096,jsonlPromptBytes:524288,pendingAttachments:16,pendingAttachmentTotalBytes:5e7,desktopAttachmentTtlMs:9e5,maxAttachmentBytes:1e7,clipboardTextBytes:1e7,clipboardTimeoutMs:15e3,instructionFileBytes:131072,instructionTotalBytes:262144,instructionFiles:32,skillDocumentBytes:524288,pluginManifestBytes:262144,subagentTaskBytes:16384,subagentContextBytes:16384,subagentMaxWriteScopeItems:32,subagentWriteScopeItemBytes:512,subagentSummaryBytes:24576,subagentMaxDurationMs:18e5,subagentMaxTokens:2e5,subagentMaxConcurrent:4,subagentMaxRetainedJobs:32,desktopSessionStoreMaxEntries:20,subagentMaxIterations:200,subagentMaxToolCallsPerTurn:100,agentMaxIterations:500,agentMaxToolCallsPerTurn:1,intentMaxCompletionAttempts:2,subagentToolArgumentBytes:65536,subagentToolResultBytes:262144,goalObjectiveBytes:16384,goalReasonBytes:2048,goalEvidenceItems:8,goalEvidenceBytes:4096,goalDefaultMaxTurns:100,goalMaximumMaxTurns:1e4,goalMaximumTokenBudget:1e7,goalDefaultMaxDurationMs:72e5,goalMaximumMaxDurationMs:288e5,goalDefaultMaxEvaluatorRuns:100,tuiTranscriptMessages:2e3,tuiAgentSessionMaxEntries:4,tuiAgentSessionMaxBytes:8388608,agentPreparationCacheMaxEntries:8,agentPreparationCacheMaxBytes:16777216,contextTokenCacheMaxEntries:8,contextTokenCacheMaxBytes:8388608,jsonlMaxInFlight:4,protocolWriteQueueEntries:256,protocolWriteQueueBytes:16777216,workspaceReferenceCount:32,workspaceReferenceInstructionBytes:16384,logQueueEntries:1e4,logQueueBytes:4194304,internalProcessTimeoutMs:12e4,internalProcessOutputBytes:4194304,hostShellTimeoutMs:12e4,guestShellTimeoutMs:6e5,defaultShellTimeoutMs:3e4};export{t as RESOURCE_LIMITS};
|
|
@@ -5,6 +5,8 @@ export interface Attachment {
|
|
|
5
5
|
mimeType: string;
|
|
6
6
|
sizeBytes: number;
|
|
7
7
|
source: AttachmentSource;
|
|
8
|
+
/** Optional requested filename for session-backed Desktop attachments. */
|
|
9
|
+
storageName?: string;
|
|
8
10
|
storagePath?: string;
|
|
9
11
|
}
|
|
10
12
|
export interface AttachmentPayload {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const WORKSPACE_SETTINGS_SCHEMA_VERSION = 1;
|
|
2
|
+
export declare const MAX_WORKSPACE_PERMISSION_RULE_LENGTH = 1024;
|
|
2
3
|
export interface WorkspacePermissionPolicy {
|
|
3
4
|
readonly allow: readonly string[];
|
|
4
5
|
readonly ask: readonly string[];
|
|
@@ -10,3 +11,4 @@ export interface WorkspaceSettings {
|
|
|
10
11
|
}
|
|
11
12
|
export declare const DEFAULT_WORKSPACE_SETTINGS: WorkspaceSettings;
|
|
12
13
|
export declare function validateWorkspaceSettings(value: unknown): WorkspaceSettings;
|
|
14
|
+
export declare function normalizePermissionRule(value: unknown, field?: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{CliError as a}from"../errors/cli-error.js";import{CLI_ERROR_CODES as
|
|
1
|
+
import{CliError as a}from"../errors/cli-error.js";import{CLI_ERROR_CODES as d}from"../errors/error-codes.js";import{findUnexpectedRecordKey as f,isRecord as c}from"../validation/record-schema.js";const i=1,o=1024,w={schemaVersion:i,permissions:{allow:[],ask:[],deny:[]}};function g(s){if(!c(s))throw r("Workspace settings must be a JSON object.");if(m(s,["schemaVersion","permissions"],"workspace settings"),s.schemaVersion!==void 0&&s.schemaVersion!==i)throw r("Unsupported workspace settings schema version.");const e=s.permissions===void 0?w.permissions:S(s.permissions);return{schemaVersion:i,permissions:e}}function S(s){if(!c(s))throw r("Workspace permissions must be a JSON object.");return m(s,["allow","ask","deny"],"workspace permissions"),{allow:t(s.allow,"permissions.allow"),ask:t(s.ask,"permissions.ask"),deny:t(s.deny,"permissions.deny")}}function t(s,e){if(s===void 0)return[];if(!Array.isArray(s))throw r(`${e} must be an array of non-empty strings (max ${o} characters each).`);return[...new Set(s.map(n=>h(n,e)))]}function h(s,e="permission rule"){if(typeof s!="string"||s.trim().length===0||s.length>o)throw r(`${e} must be a non-empty string (max ${o} characters).`);return s.trim()}function r(s){return new a(d.CONFIG_SCHEMA_INVALID,s,{category:"config",userMessage:`Invalid workspace settings: ${s}`})}function m(s,e,n){const p=f(s,e);if(p!==void 0)throw r(`Unsupported ${n} field: \`${p}\`.`)}export{w as DEFAULT_WORKSPACE_SETTINGS,o as MAX_WORKSPACE_PERMISSION_RULE_LENGTH,i as WORKSPACE_SETTINGS_SCHEMA_VERSION,h as normalizePermissionRule,g as validateWorkspaceSettings};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function r(t){return typeof t=="string"?t.length:Array.isArray(t)?t.reduce((o,e)=>{if(typeof e!="object"||e===null||!("text"in e))return o;const n=e.text;return o+(typeof n=="string"?n.length:0)},0):0}function p(t){return{...typeof t.prompt_tokens=="number"?{promptTokens:t.prompt_tokens}:{},...typeof t.completion_tokens=="number"?{completionTokens:t.completion_tokens}:{},...typeof t.total_tokens=="number"?{totalTokens:t.total_tokens}:{}}}export{p as mapUsage,r as textLength};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{PROVIDER_TOOL_NAME_MAX_LENGTH as l,PROVIDER_TOOL_NAME_PATTERN as s}from"./sdk-constants.js";function g(n){const t=new Map,e=new Map;for(const o of[...new Set((n??[]).flatMap(c))]){const i=u(o),a=e.get(i);if(a!==void 0&&a!==o)throw new Error(`Tool names "${a}" and "${o}" normalize to the same provider name "${i}".`);t.set(o,i),e.set(i,o)}return{toProviderName:o=>t.get(o)??u(o),toInternalName:o=>e.get(o)??o}}function _(n,t){const e={...n,messages:n.messages.map(o=>!("tool_calls"in o)||o.tool_calls===void 0?o:{...o,tool_calls:o.tool_calls.map(i=>r(i,t.toProviderName))}),...n.tools===void 0?{}:{tools:n.tools.map(o=>d(o,t.toProviderName))}};return n.tool_choice!==void 0&&(e.tool_choice=f(n.tool_choice,t.toProviderName)),n.toolChoice!==void 0&&(e.toolChoice=f(n.toolChoice,t.toProviderName)),n.toolConfig!==void 0&&(e.toolConfig=f(n.toolConfig,t.toProviderName)),e}function N(n,t){return{...n,choices:n.choices.map(e=>({...e,message:e.message.tool_calls===void 0?e.message:{...e.message,tool_calls:e.message.tool_calls.map(o=>r(o,t.toInternalName))}}))}}function C(n,t){return{...n,choices:n.choices.map(e=>({...e,delta:e.delta.tool_calls===void 0?e.delta:{...e.delta,tool_calls:e.delta.tool_calls.map(o=>r(o,t.toInternalName))}}))}}function u(n){const t=n.replace(/[^A-Za-z0-9_-]+/gu,"_");if(t.length<=l&&s.test(t))return t;const e=m(n).slice(0,8);return`${t.slice(0,l-e.length-1)}_${e}`}function m(n){let t=2166136261;for(const e of n)t^=e.codePointAt(0)??0,t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function d(n,t){return"function"in n&&n.function!==void 0?{...n,function:{...n.function,name:t(n.function.name)}}:"functionDeclarations"in n?{...n,functionDeclarations:n.functionDeclarations.map(e=>({...e,name:t(e.name)}))}:"name"in n?{...n,name:t(n.name)}:n}function r(n,t){return{...n,function:{...n.function,name:t(n.function.name)}}}function f(n,t){return typeof n=="string"?n:"function"in n&&n.function!==void 0?{...n,function:{...n.function,name:t(n.function.name)}}:"name"in n&&typeof n.name=="string"?{...n,name:t(n.name)}:"functionCallingConfig"in n&&n.functionCallingConfig.allowedFunctionNames!==void 0?{...n,functionCallingConfig:{...n.functionCallingConfig,allowedFunctionNames:n.functionCallingConfig.allowedFunctionNames.map(t)}}:n}function c(n){return"function"in n&&n.function!==void 0?[n.function.name]:"name"in n&&typeof n.name=="string"?[n.name]:"functionDeclarations"in n?n.functionDeclarations.map(t=>t.name):[]}export{g as createModelToolNameMap,C as mapChunkToolNames,_ as mapRequestToolNames,N as mapResponseToolNames};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const _=/^[A-Za-z0-9_-]+$/u,E=64;export{E as PROVIDER_TOOL_NAME_MAX_LENGTH,_ as PROVIDER_TOOL_NAME_PATTERN};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@lotagate/sdk";import{AssistantDeltaNormalizer as q}from"../../domain/runtime/assistant-delta-normalizer.js";import{createModelToolNameMap as nn,mapChunkToolNames as tn,mapRequestToolNames as U,mapResponseToolNames as z}from"./model-tool-name-mapper.js";import{isRetryableModelResponseError as en,MODEL_RESPONSE_MAX_RETRIES as on,retryModelStream as rn}from"../../application/model/model-response-retry.js";const W=on;function kn(n,t={}){return{chat:{completions:{create:((e,s)=>{const r=nn(e.tools),i=e.tools!==void 0&&e.tools.length>0?1:void 0;if(e.stream===!0){const l=U(v({...e,stream:!0}),r),f=cn(e)?ln(n,l,s,i):rn({create:async()=>await n.chat.completions.create(l,s),isObservable:un,...s?.signal===void 0?{}:{signal:s.signal}});return an(n,l,e.tools,s,f,e.model,t,r,i)}const a=U(v({...e,stream:!1}),r);return sn(n.chat.completions.create(a,s),e.model,t,r,i)})}}}}async function sn(n,t,o,e,s){const r=O(z(w(await n),e),s),i=r.choices[0]?.message;return o.onComplete?.({model:t,stream:!1,contentLength:$(i?.content),toolCallCount:i?.tool_calls?.length??0,toolNames:(i?.tool_calls??[]).map(a=>a.function.name),...r.usage===void 0?{}:{usage:k(r.usage)},...r.choices[0]?.finish_reason===void 0?{}:{finishReason:r.choices[0].finish_reason}}),r}async function*an(n,t,o,e,s,r,i,a,l){let f=0,c;const d=new Set,m=new Set,_=new dn(o);let S=!1,b,x,M=!1;const Z=new q;try{for await(const C of s){const h=tn(fn(C,Z),a),p=_.consume(h).chunk,y=p.choices[0];p.usage!==void 0&&(b=k(p.usage));const I=$(y?.delta.content);if(f+=I,c=y?.finish_reason??c,I>0&&(S=!0),y?.finish_reason==="tool_calls"&&!M){const J=_.flush(p);if(!S&&B(J)){const R=z(w(await N(n,t,e,l)),a);R.usage!==void 0&&(b=k(R.usage)),G(R,m,d),c=R.choices[0]?.finish_reason??c,yield T(R);return}const L=P(J,l);K(L,m,d),M=!0,yield p,yield L}else yield p;x=p}if(!M&&x!==void 0&&_.hasCalls()){const C=_.flush(x);if(!S&&B(C)){const g=z(w(await N(n,t,e,l)),a);g.usage!==void 0&&(b=k(g.usage)),G(g,m,d),c=g.choices[0]?.finish_reason??c,yield T(g);return}const h=P(C,l);K(h,m,d),M=!0,yield h}}catch(C){if(!S&&!M&&Y(C)&&e?.signal?.aborted!==!0){const h=z(w(await N(n,t,e,l)),a);h.usage!==void 0&&(b=k(h.usage));const g=h.choices[0]?.message,p=$(g?.content);f+=p;for(const y of g?.tool_calls??[])y.id.length>0&&m.add(y.id),y.function.name.length>0&&d.add(y.function.name);c=h.choices[0]?.finish_reason??c,yield T(h);return}throw C}finally{i.onComplete?.({model:r,stream:!0,contentLength:f,toolCallCount:m.size||d.size,toolNames:[...d],...c===void 0?{}:{finishReason:c},...b===void 0?{}:{usage:b}})}}async function N(n,t,o,e){const s=v({...t,stream:!1});for(let r=0;;r+=1)try{const i=w(await n.chat.completions.create(s,o));if(r<W&&B(i))continue;return O(i,e)}catch(i){if(r>=W||!Y(i)||o?.signal?.aborted===!0)throw i}}async function*ln(n,t,o,e){yield T(await N(n,t,o,e))}function v(n){return n.tools===void 0||n.tools.length===0?n:{...n,tool_choice:"auto"}}function cn(n){const t=n.messages.at(-1);return t!==void 0&&"role"in t&&t.role==="tool"}function un(n){return n.choices.some(t=>{const o=t.delta.content,e=t.delta.tool_calls,s=t.delta;return typeof o=="string"&&o.length>0||Array.isArray(o)&&o.length>0||Array.isArray(e)&&e.length>0||u(s.function_call)})}function O(n,t){return t===void 0?n:{...n,choices:n.choices.map(o=>{const e=o.message.tool_calls;return e===void 0||e.length<=t?o:{...o,message:{...o.message,tool_calls:e.slice(0,t)}}})}}function P(n,t){return t===void 0?n:{...n,choices:n.choices.map(o=>{const e=o.delta.tool_calls;return e===void 0||e.length<=t?o:{...o,delta:{...o.delta,tool_calls:e.slice(0,t)}}})}}function T(n){const t=w(n),o=t.choices[0],e=o?.message;return{id:t.id,object:"chat.completion.chunk",created:t.created,model:t.model,choices:[{index:o?.index??0,delta:{role:"assistant",content:F(e?.content),...e?.tool_calls===void 0?{}:{tool_calls:e.tool_calls.map((s,r)=>({...s,index:r}))}},...o?.finish_reason===void 0?{}:{finish_reason:o.finish_reason}}],...t.usage===void 0?{}:{usage:t.usage}}}function fn(n,t){return{...n,choices:n.choices.map(o=>{const e=o.delta.content,r=Array.isArray(e)?t.normalize(F(e)):typeof e=="string"?t.normalize(e):e,i=o.delta,a=[...Array.isArray(e)?H(e):[],...Q(i.function_call,0)];return r===e&&a.length===0?o:{...o,delta:{...o.delta,...r===e?{}:{content:r},...a.length===0?{}:{tool_calls:[...o.delta.tool_calls??[],...a]}}}})}}class dn{knownNames;calls=new Map;order=[];keysByPosition=new Map;constructor(t){this.knownNames=new Set((t??[]).flatMap(o=>Cn(o)))}consume(t){let o=!1;const e=t.choices.map(s=>{const r=s.delta.tool_calls;if(r===void 0||r.length===0)return s;o=!0,r.forEach((a,l)=>{u(a)&&this.append(a,l)});const i={...s.delta};return delete i.tool_calls,{...s,delta:i}});return{chunk:{...t,choices:e},hadToolCalls:o}}hasCalls(){return this.order.length>0}flush(t){const o=this.order.map((i,a)=>{const l=this.calls.get(i);return{id:l.id||`tool-call-${a}`,type:l.type,function:{name:l.name,arguments:l.arguments},...l.providerMetadata===void 0?{}:{provider_metadata:l.providerMetadata}}}),e=new Set,s=o.filter(i=>{const a=`${i.function.name}\0${i.function.arguments}`;return e.has(a)?!1:(e.add(a),!0)}),r=t.choices.map((i,a)=>a===0?{...i,delta:{...i.delta,tool_calls:s}}:i);return{...t,choices:r}}append(t,o){const e=E(t),s=gn(t),r=j(t),i=X(t),a=A(t),l=hn(t,o),f=this.keysByPosition.get(l)??mn(e,l);this.keysByPosition.set(l,f);const c=this.calls.get(f),d=pn(c?.name??"",r,this.knownNames),m=yn(c?.arguments??"",i);if(c===void 0){this.calls.set(f,{id:e,type:s,name:d,arguments:m,...a===void 0?{}:{providerMetadata:a}}),this.order.push(f);return}const _=c.providerMetadata??a;this.calls.set(f,{id:c.id.length===0&&e.length>0?e:c.id,type:s||c.type,name:c.name+d,arguments:m,..._===void 0?{}:{providerMetadata:_}})}}function A(n){if(!u(n))return;const t=n.provider_metadata??n.providerMetadata;if(u(t))return t;const o=n.thoughtSignature??n.thought_signature;return typeof o=="string"&&o.length>0?{google:{thought_signature:o}}:void 0}function hn(n,t){const o=n.index;return typeof o=="number"&&Number.isInteger(o)?o:t}function mn(n,t){return n.length>0?`id:${n}`:`index:${t}`}function E(n){const t=n;return u(t)&&typeof t.id=="string"?t.id:""}function gn(n){const t=n;return u(t)&&typeof t.type=="string"&&t.type.length>0?t.type:"function"}function j(n){const t=n;return u(t)&&u(t.function)&&typeof t.function.name=="string"?t.function.name:""}function X(n){const t=n;return u(t)&&u(t.function)&&typeof t.function.arguments=="string"?t.function.arguments:""}function pn(n,t,o){return t.length===0||t===n?"":o!==void 0&&o.has(t)&&t.startsWith(n)||t.startsWith(n)&&n.length>0?t.slice(n.length):t}function yn(n,t){if(t.length===0)return n;if(n.length===0||t===n)return n.length===0?t:n;if(t.startsWith(n))return t;const o=_n(n,t);return o!==void 0?o:n+t}function B(n){const t=n.choices[0];return((t!==void 0&&"message"in t?t.message.tool_calls:t?.delta.tool_calls)??[]).some(e=>D(X(e))===void 0)}function _n(n,t){if(n.length===0||t.length===0)return;const o=D(n),e=D(t);if(!(o===void 0||e===void 0))return JSON.stringify({...o,...e})}function D(n){try{const t=JSON.parse(n);return u(t)?t:void 0}catch{return}}function K(n,t,o){for(const e of n.choices[0]?.delta.tool_calls??[]){const s=E(e),r=j(e);s.length>0&&t.add(s),r.length>0&&o.add(r)}}function G(n,t,o){for(const e of n.choices[0]?.message?.tool_calls??[]){const s=E(e),r=j(e);s.length>0&&t.add(s),r.length>0&&o.add(r)}}function Cn(n){return"function"in n&&typeof n.function.name=="string"?[n.function.name]:"name"in n&&typeof n.name=="string"?[n.name]:"functionDeclarations"in n?n.functionDeclarations.flatMap(t=>typeof t.name=="string"?[t.name]:[]):[]}function w(n){return{...n,choices:n.choices.map(t=>({...t,message:An(t.message)}))}}function An(n){const t=n,o=[...Array.isArray(n.content)?H(n.content):[],...Q(t.function_call,0)],e=Array.isArray(n.content)?F(n.content):typeof n.content=="string"?n.content:void 0,s=e??null,r=Array.isArray(n.content)||typeof n.content=="string"&&e!==n.content;return!r&&o.length===0?n:{...n,...r?{content:s}:{},...o.length===0?{}:{tool_calls:[...n.tool_calls??[],...o]}}}function H(n){const t=[];for(const[o,e]of n.entries())if(!(typeof e!="object"||e===null)){if("functionCall"in e&&u(e.functionCall)&&typeof e.functionCall.name=="string"){const s=e.functionCall.args;t.push({id:typeof e.functionCall.id=="string"&&e.functionCall.id.length>0?e.functionCall.id:`provider-call-${o}`,type:"function",function:{name:e.functionCall.name,arguments:V(s)},...A(e)===void 0?{}:{provider_metadata:A(e)}});continue}if("tool_use"in e&&u(e.tool_use)&&typeof e.tool_use.name=="string"){const s=e.tool_use.input;t.push({id:typeof e.tool_use.id=="string"&&e.tool_use.id.length>0?e.tool_use.id:`provider-call-${o}`,type:"function",function:{name:e.tool_use.name,arguments:JSON.stringify(s??{})},...A(e)===void 0?{}:{provider_metadata:A(e)}})}}return t}function Q(n,t){if(!u(n)||typeof n.name!="string")return[];const o=n.arguments;return[{id:typeof n.id=="string"&&n.id.length>0?n.id:`provider-call-${t}`,type:"function",function:{name:n.name,arguments:V(o)},...A(n)===void 0?{}:{provider_metadata:A(n)}}]}function V(n){if(n===void 0)return"";if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return""}}function u(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Y(n){return en(n)}function F(n){return typeof n=="string"?n:Array.isArray(n)?n.reduce((t,o)=>{if(typeof o!="object"||o===null||!("text"in o))return t;const e=o.text;return t+(typeof e=="string"?e:"")},""):""}function $(n){return typeof n=="string"?n.length:Array.isArray(n)?n.reduce((t,o)=>{if(typeof o!="object"||o===null||!("text"in o))return t;const e=o.text;return t+(typeof e=="string"?e.length:0)},0):0}function k(n){return{...typeof n.prompt_tokens=="number"?{promptTokens:n.prompt_tokens}:{},...typeof n.completion_tokens=="number"?{completionTokens:n.completion_tokens}:{},...typeof n.total_tokens=="number"?{totalTokens:n.total_tokens}:{}}}export{kn as createToolCallingModelClient};
|
|
1
|
+
import"@lotagate/sdk";import{AssistantDeltaNormalizer as q}from"../../domain/runtime/assistant-delta-normalizer.js";import{createModelToolNameMap as nn,mapChunkToolNames as tn,mapRequestToolNames as U,mapResponseToolNames as N}from"./model-tool-name-mapper.js";import{isRetryableModelResponseError as en,isRetryableToolResultFollowUpError as on,MODEL_RESPONSE_MAX_RETRIES as rn,retryModelStream as sn}from"../../application/model/model-response-retry.js";import{mapUsage as S,textLength as k}from"./model-response-metrics.js";const W=rn;function En(n,t={}){return{chat:{completions:{create:((e,i)=>{const r=nn(e.tools),a=e.tools!==void 0&&e.tools.length>0?1:void 0;if(e.stream===!0){const l=U(v({...e,stream:!0}),r),f=fn(e)?cn(n,l,i,a):sn({create:async()=>await n.chat.completions.create(l,i),isObservable:dn,...i?.signal===void 0?{}:{signal:i.signal}});return ln(n,l,e.tools,i,f,e.model,t,r,a)}const s=U(v({...e,stream:!1}),r);return an(n.chat.completions.create(s,i),e.model,t,r,a)})}}}}async function an(n,t,o,e,i){const r=O(N(b(await n),e),i),a=r.choices[0]?.message;return o.onComplete?.({model:t,stream:!1,contentLength:k(a?.content),toolCallCount:a?.tool_calls?.length??0,toolNames:(a?.tool_calls??[]).map(s=>s.function.name),...r.usage===void 0?{}:{usage:S(r.usage)},...r.choices[0]?.finish_reason===void 0?{}:{finishReason:r.choices[0].finish_reason}}),r}async function*ln(n,t,o,e,i,r,a,s,l){let f=0,c;const d=new Set,h=new Set,_=new mn(o);let z=!1,w,x,R=!1;const Z=new q;try{for await(const C of i){const g=tn(hn(C,Z),s),p=_.consume(g).chunk,y=p.choices[0];p.usage!==void 0&&(w=S(p.usage));const I=k(y?.delta.content);if(f+=I,c=y?.finish_reason??c,I>0&&(z=!0),y?.finish_reason==="tool_calls"&&!R){const J=_.flush(p);if(!z&&D(J)){const M=N(b(await T(n,t,e,l)),s);M.usage!==void 0&&(w=S(M.usage)),G(M,h,d),c=M.choices[0]?.finish_reason??c,yield E(M);return}const L=P(J,l);K(L,h,d),R=!0,yield p,yield L}else yield p;x=p}if(!R&&x!==void 0&&_.hasCalls()){const C=_.flush(x);if(!z&&D(C)){const m=N(b(await T(n,t,e,l)),s);m.usage!==void 0&&(w=S(m.usage)),G(m,h,d),c=m.choices[0]?.finish_reason??c,yield E(m);return}const g=P(C,l);K(g,h,d),R=!0,yield g}}catch(C){if(!z&&!R&&Y(C)&&e?.signal?.aborted!==!0){const g=N(b(await T(n,t,e,l)),s);g.usage!==void 0&&(w=S(g.usage));const m=g.choices[0]?.message,p=k(m?.content);f+=p;for(const y of m?.tool_calls??[])y.id.length>0&&h.add(y.id),y.function.name.length>0&&d.add(y.function.name);c=g.choices[0]?.finish_reason??c,yield E(g);return}throw C}finally{a.onComplete?.({model:r,stream:!0,contentLength:f,toolCallCount:h.size||d.size,toolNames:[...d],...c===void 0?{}:{finishReason:c},...w===void 0?{}:{usage:w}})}}async function T(n,t,o,e,i=!1){const r=v({...t,stream:!1});for(let a=0;;a+=1)try{const s=b(await n.chat.completions.create(r,o));if(a<W&&D(s))continue;return O(s,e)}catch(s){const l=i?on(s):Y(s);if(a>=W||!l||o?.signal?.aborted===!0)throw s}}async function*cn(n,t,o,e){yield E(await T(n,t,o,e,!0))}function v(n){return n.tools===void 0||n.tools.length===0||un(n)?n:{...n,tool_choice:"auto"}}function un(n){return n.tool_choice!==void 0||n.toolChoice!==void 0||n.toolConfig!==void 0}function fn(n){const t=n.messages.at(-1);return t!==void 0&&"role"in t&&t.role==="tool"}function dn(n){return n.choices.some(t=>{const o=t.delta.content,e=t.delta.tool_calls,i=t.delta;return typeof o=="string"&&o.length>0||Array.isArray(o)&&o.length>0||Array.isArray(e)&&e.length>0||typeof i.reasoning_content=="string"&&i.reasoning_content.length>0||u(i.function_call)})}function O(n,t){return t===void 0?n:{...n,choices:n.choices.map(o=>{const e=o.message.tool_calls;return e===void 0||e.length<=t?o:{...o,message:{...o.message,tool_calls:e.slice(0,t)}}})}}function P(n,t){return t===void 0?n:{...n,choices:n.choices.map(o=>{const e=o.delta.tool_calls;return e===void 0||e.length<=t?o:{...o,delta:{...o.delta,tool_calls:e.slice(0,t)}}})}}function E(n){const t=b(n),o=t.choices[0],e=o?.message,i=gn(e);return{id:t.id,object:"chat.completion.chunk",created:t.created,model:t.model,choices:[{index:o?.index??0,delta:{role:"assistant",content:j(e?.content),...i===void 0?{}:{reasoning_content:i},...e?.tool_calls===void 0?{}:{tool_calls:e.tool_calls.map((r,a)=>({...r,index:a}))}},...o?.finish_reason===void 0?{}:{finish_reason:o.finish_reason}}],...t.usage===void 0?{}:{usage:t.usage}}}function gn(n){if(!u(n))return;const t=n.reasoning_content;return typeof t=="string"&&t.length>0?t:void 0}function hn(n,t){return{...n,choices:n.choices.map(o=>{const e=o.delta.content,r=Array.isArray(e)?t.normalize(j(e)):typeof e=="string"?t.normalize(e):e,a=o.delta,s=[...Array.isArray(e)?H(e):[],...Q(a.function_call,0)];return r===e&&s.length===0?o:{...o,delta:{...o.delta,...r===e?{}:{content:r},...s.length===0?{}:{tool_calls:[...o.delta.tool_calls??[],...s]}}}})}}class mn{knownNames;calls=new Map;order=[];keysByPosition=new Map;constructor(t){this.knownNames=new Set((t??[]).flatMap(o=>bn(o)))}consume(t){let o=!1;const e=t.choices.map(i=>{const r=i.delta.tool_calls;if(r===void 0||r.length===0)return i;o=!0,r.forEach((s,l)=>{u(s)&&this.append(s,l)});const a={...i.delta};return delete a.tool_calls,{...i,delta:a}});return{chunk:{...t,choices:e},hadToolCalls:o}}hasCalls(){return this.order.length>0}flush(t){const o=this.order.map((a,s)=>{const l=this.calls.get(a);return{id:l.id||`tool-call-${s}`,type:l.type,function:{name:l.name,arguments:l.arguments},...l.providerMetadata===void 0?{}:{provider_metadata:l.providerMetadata}}}),e=new Set,i=o.filter(a=>{const s=`${a.function.name}\0${a.function.arguments}`;return e.has(s)?!1:(e.add(s),!0)}),r=t.choices.map((a,s)=>s===0?{...a,delta:{...a.delta,tool_calls:i}}:a);return{...t,choices:r}}append(t,o){const e=F(t),i=_n(t),r=B(t),a=X(t),s=A(t),l=pn(t,o),f=this.keysByPosition.get(l)??yn(e,l);this.keysByPosition.set(l,f);const c=this.calls.get(f),d=Cn(c?.name??"",r,this.knownNames),h=An(c?.arguments??"",a);if(c===void 0){this.calls.set(f,{id:e,type:i,name:d,arguments:h,...s===void 0?{}:{providerMetadata:s}}),this.order.push(f);return}const _=c.providerMetadata??s;this.calls.set(f,{id:c.id.length===0&&e.length>0?e:c.id,type:i||c.type,name:c.name+d,arguments:h,..._===void 0?{}:{providerMetadata:_}})}}function A(n){if(!u(n))return;const t=n.provider_metadata??n.providerMetadata;if(u(t))return t;const o=n.thoughtSignature??n.thought_signature;return typeof o=="string"&&o.length>0?{google:{thought_signature:o}}:void 0}function pn(n,t){const o=n.index;return typeof o=="number"&&Number.isInteger(o)?o:t}function yn(n,t){return n.length>0?`id:${n}`:`index:${t}`}function F(n){const t=n;return u(t)&&typeof t.id=="string"?t.id:""}function _n(n){const t=n;return u(t)&&typeof t.type=="string"&&t.type.length>0?t.type:"function"}function B(n){const t=n;return u(t)&&u(t.function)&&typeof t.function.name=="string"?t.function.name:""}function X(n){const t=n;return u(t)&&u(t.function)&&typeof t.function.arguments=="string"?t.function.arguments:""}function Cn(n,t,o){return t.length===0||t===n?"":o!==void 0&&o.has(t)&&t.startsWith(n)||t.startsWith(n)&&n.length>0?t.slice(n.length):t}function An(n,t){if(t.length===0)return n;if(n.length===0||t===n)return n.length===0?t:n;if(t.startsWith(n))return t;const o=wn(n,t);return o!==void 0?o:n+t}function D(n){const t=n.choices[0];return((t!==void 0&&"message"in t?t.message.tool_calls:t?.delta.tool_calls)??[]).some(e=>$(X(e))===void 0)}function wn(n,t){if(n.length===0||t.length===0)return;const o=$(n),e=$(t);if(!(o===void 0||e===void 0))return JSON.stringify({...o,...e})}function $(n){try{const t=JSON.parse(n);return u(t)?t:void 0}catch{return}}function K(n,t,o){for(const e of n.choices[0]?.delta.tool_calls??[]){const i=F(e),r=B(e);i.length>0&&t.add(i),r.length>0&&o.add(r)}}function G(n,t,o){for(const e of n.choices[0]?.message?.tool_calls??[]){const i=F(e),r=B(e);i.length>0&&t.add(i),r.length>0&&o.add(r)}}function bn(n){return"function"in n&&typeof n.function.name=="string"?[n.function.name]:"name"in n&&typeof n.name=="string"?[n.name]:"functionDeclarations"in n?n.functionDeclarations.flatMap(t=>typeof t.name=="string"?[t.name]:[]):[]}function b(n){return{...n,choices:n.choices.map(t=>({...t,message:Rn(t.message)}))}}function Rn(n){const t=n,o=[...Array.isArray(n.content)?H(n.content):[],...Q(t.function_call,0)],e=Array.isArray(n.content)?j(n.content):typeof n.content=="string"?n.content:void 0,i=e??null,r=Array.isArray(n.content)||typeof n.content=="string"&&e!==n.content;return!r&&o.length===0?n:{...n,...r?{content:i}:{},...o.length===0?{}:{tool_calls:[...n.tool_calls??[],...o]}}}function H(n){const t=[];for(const[o,e]of n.entries())if(!(typeof e!="object"||e===null)){if("functionCall"in e&&u(e.functionCall)&&typeof e.functionCall.name=="string"){const i=e.functionCall.args;t.push({id:typeof e.functionCall.id=="string"&&e.functionCall.id.length>0?e.functionCall.id:`provider-call-${o}`,type:"function",function:{name:e.functionCall.name,arguments:V(i)},...A(e)===void 0?{}:{provider_metadata:A(e)}});continue}if("tool_use"in e&&u(e.tool_use)&&typeof e.tool_use.name=="string"){const i=e.tool_use.input;t.push({id:typeof e.tool_use.id=="string"&&e.tool_use.id.length>0?e.tool_use.id:`provider-call-${o}`,type:"function",function:{name:e.tool_use.name,arguments:JSON.stringify(i??{})},...A(e)===void 0?{}:{provider_metadata:A(e)}})}}return t}function Q(n,t){if(!u(n)||typeof n.name!="string")return[];const o=n.arguments;return[{id:typeof n.id=="string"&&n.id.length>0?n.id:`provider-call-${t}`,type:"function",function:{name:n.name,arguments:V(o)},...A(n)===void 0?{}:{provider_metadata:A(n)}}]}function V(n){if(n===void 0)return"";if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return""}}function u(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Y(n){return en(n)}function j(n){return typeof n=="string"?n:Array.isArray(n)?n.reduce((t,o)=>{if(typeof o!="object"||o===null||!("text"in o))return t;const e=o.text;return t+(typeof e=="string"?e:"")},""):""}export{En as createToolCallingModelClient};
|
|
@@ -3,5 +3,7 @@ export interface CachePolicy {
|
|
|
3
3
|
modelCatalogTtlMs: number;
|
|
4
4
|
maxEntryBytes: number;
|
|
5
5
|
maxTotalBytes: number;
|
|
6
|
+
maxMemoryEntries: number;
|
|
7
|
+
maxMemoryBytes: number;
|
|
6
8
|
}
|
|
7
9
|
export declare function resolveCachePolicy(env?: Readonly<Record<string, string | undefined>>): CachePolicy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _(e=process.env){return{enabled:t(e.LOTAGATE_CACHE_ENABLED,!0),modelCatalogTtlMs:r(e.LOTAGATE_MODEL_CACHE_TTL_SECONDS,300,1,86400)*1e3,maxEntryBytes:r(e.LOTAGATE_CACHE_MAX_ENTRY_BYTES,5*1024*1024,1024,50*1024*1024),maxTotalBytes:r(e.LOTAGATE_CACHE_MAX_BYTES,50*1024*1024,1*1024*1024,500*1024*1024),maxMemoryEntries:r(e.LOTAGATE_CACHE_MAX_MEMORY_ENTRIES,64,1,1e4),maxMemoryBytes:r(e.LOTAGATE_CACHE_MAX_MEMORY_BYTES,8*1024*1024,1*1024*1024,500*1024*1024)}}function t(e,E){return e===void 0?E:e.trim().toLowerCase()==="true"?!0:e.trim().toLowerCase()==="false"?!1:E}import{readBoundedEnvironmentInteger as r}from"../config/environment-values.js";export{_ as resolveCachePolicy};
|
|
@@ -5,6 +5,9 @@ export declare class FileCacheStore implements CacheStore {
|
|
|
5
5
|
private readonly policy;
|
|
6
6
|
private readonly now;
|
|
7
7
|
private prunePromise;
|
|
8
|
+
private readonly memoryCache;
|
|
9
|
+
private memoryBytes;
|
|
10
|
+
private lastPruneAt;
|
|
8
11
|
constructor(root: string, policy: CachePolicy, now?: () => number);
|
|
9
12
|
get<T>(namespace: string, key: string): Promise<T | undefined>;
|
|
10
13
|
set<T>(namespace: string, key: string, value: T, options: CacheWriteOptions): Promise<void>;
|
|
@@ -14,4 +17,9 @@ export declare class FileCacheStore implements CacheStore {
|
|
|
14
17
|
private schedulePrune;
|
|
15
18
|
private namespacePath;
|
|
16
19
|
private filePath;
|
|
20
|
+
private setMemoryEntry;
|
|
21
|
+
private removeMemoryEntry;
|
|
22
|
+
private touchMemoryEntry;
|
|
23
|
+
private clearMemory;
|
|
24
|
+
private pruneMemory;
|
|
17
25
|
}
|