theokit 0.48.13 → 0.48.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/dist/{actions-virtual-module-YQXRSSMW.js → actions-virtual-module-E4PISKMB.js} +3 -3
- package/dist/{actions-virtual-module-LB4NGONI.js → actions-virtual-module-YZRZMHAX.js} +3 -3
- package/dist/{agent-7JJW3TPB.js → agent-XAQCUQNB.js} +3 -3
- package/dist/{app-typed-client-GHO3EWZK.js → app-typed-client-HLP26EYM.js} +3 -3
- package/dist/{app-typed-client-G3J5G7E5.js → app-typed-client-I4X2UJWW.js} +3 -3
- package/dist/{aws-lambda-CYNDGU5O.js → aws-lambda-KES4MFJV.js} +3 -3
- package/dist/{build-WU6AKKIB.js → build-F2Q5QTSC.js} +6 -6
- package/dist/{bun-33RD6K7O.js → bun-A5B2MJMO.js} +3 -3
- package/dist/{chunk-S433N3CT.js → chunk-AATSV4UV.js} +2 -2
- package/dist/{chunk-6E5WKMDS.js → chunk-AXKUA57G.js} +31 -4
- package/dist/chunk-AXKUA57G.js.map +1 -0
- package/dist/{chunk-E576KYYT.js → chunk-BHOTGS7N.js} +2 -2
- package/dist/{chunk-GVW5EKEU.js → chunk-CMYSHZFT.js} +2 -2
- package/dist/{chunk-6GGWS7J3.js → chunk-DQIPV7L5.js} +29 -2
- package/dist/chunk-DQIPV7L5.js.map +1 -0
- package/dist/{chunk-PXFXSFJL.js → chunk-DS5MCU2X.js} +5 -5
- package/dist/{chunk-GXEX4CBH.js → chunk-FTFN4MYN.js} +98 -32
- package/dist/chunk-FTFN4MYN.js.map +1 -0
- package/dist/{chunk-OJLL4YD6.js → chunk-KTKTHIUF.js} +5 -3
- package/dist/chunk-KTKTHIUF.js.map +1 -0
- package/dist/{chunk-GRI4XHBJ.js → chunk-NTWNO24W.js} +6 -4
- package/dist/{chunk-GRI4XHBJ.js.map → chunk-NTWNO24W.js.map} +1 -1
- package/dist/{chunk-YRBR424R.js → chunk-OOBYPCZC.js} +99 -35
- package/dist/chunk-OOBYPCZC.js.map +1 -0
- package/dist/{chunk-7VPQHEAJ.js → chunk-WSXNGF7X.js} +1 -1
- package/dist/{chunk-7VPQHEAJ.js.map → chunk-WSXNGF7X.js.map} +1 -1
- package/dist/{chunk-BIVCP6X5.js → chunk-WYHYOYRH.js} +6 -4
- package/dist/{chunk-BIVCP6X5.js.map → chunk-WYHYOYRH.js.map} +1 -1
- package/dist/{chunk-J5MXCGKA.js → chunk-YXG2SGQ3.js} +1 -1
- package/dist/{chunk-J5MXCGKA.js.map → chunk-YXG2SGQ3.js.map} +1 -1
- package/dist/cli/index.js +8 -8
- package/dist/{cloudflare-KYUWCEPL.js → cloudflare-IN2WB7FZ.js} +3 -3
- package/dist/{deno-deploy-CCTB7HGS.js → deno-deploy-LYXQEJ6A.js} +3 -3
- package/dist/{dev-MUWJAZRD.js → dev-CDFPXISP.js} +8 -8
- package/dist/{index-BEtEv6ZH.d.ts → index-D_PxPXgQ.d.ts} +2 -2
- package/dist/index.js +3 -3
- package/dist/{info-XW7HGUPH.js → info-QXZW722N.js} +4 -4
- package/dist/{internal-api-V5L65YSJ.js → internal-api-FBK2YXSI.js} +3 -3
- package/dist/{internal-api-WEOSTMSN.js → internal-api-ZCJWJ5EC.js} +3 -3
- package/dist/{load-config-VKD6LKWU.js → load-config-FIWNKOJO.js} +4 -4
- package/dist/{mcp-ULUFJNSZ.js → mcp-KTYP4ZON.js} +4 -4
- package/dist/{netlify-AFMDNKT4.js → netlify-DLEOCFAD.js} +3 -3
- package/dist/node-QXYSUWQ4.js +10 -0
- package/dist/{openapi-HZXR335W.js → openapi-OUXNB2F2.js} +4 -4
- package/dist/{plugin-runner-BFEcgtmJ.d.ts → plugin-runner-DHVr1cC5.d.ts} +1 -1
- package/dist/{plugin-types-D69-lJZ9.d.ts → plugin-types-4VN1GMqV.d.ts} +12 -0
- package/dist/registry-S7OMF3OS.js +23 -0
- package/dist/{routes-OLNQX7CT.js → routes-NJR4ISCT.js} +4 -4
- package/dist/{schema-ZO3OSWVG.js → schema-DNIT7JQX.js} +3 -3
- package/dist/server/agent/index.d.ts +20 -5
- package/dist/server/agent/index.js +1 -1
- package/dist/server/define/index.d.ts +9 -1
- package/dist/server/define/index.js +1 -1
- package/dist/server/http/index.d.ts +3 -3
- package/dist/server/index.d.ts +4 -4
- package/dist/server/index.js +2 -2
- package/dist/server/plugins/index.d.ts +3 -3
- package/dist/{services-typed-client-PSAGRPFF.js → services-typed-client-P4JERLBL.js} +2 -2
- package/dist/{start-KR2JJR7K.js → start-25OV2CAK.js} +198 -29
- package/dist/start-25OV2CAK.js.map +1 -0
- package/dist/{static-M2W4HUWS.js → static-RTO637XW.js} +3 -3
- package/dist/{theo-cloud-XAHWOUFK.js → theo-cloud-UZ3GINRU.js} +2 -2
- package/dist/{vercel-SRS2DH6O.js → vercel-6D6EZUVD.js} +3 -3
- package/dist/vite-plugin/index.js +3 -3
- package/dist/{vite-plugin-VPJFD4HK.js → vite-plugin-RJFKLF2U.js} +8 -8
- package/package.json +3 -3
- package/dist/chunk-6E5WKMDS.js.map +0 -1
- package/dist/chunk-6GGWS7J3.js.map +0 -1
- package/dist/chunk-GXEX4CBH.js.map +0 -1
- package/dist/chunk-OJLL4YD6.js.map +0 -1
- package/dist/chunk-YRBR424R.js.map +0 -1
- package/dist/node-ZJQEJSP3.js +0 -10
- package/dist/registry-GKR3EWRW.js +0 -23
- package/dist/start-KR2JJR7K.js.map +0 -1
- /package/dist/{actions-virtual-module-YQXRSSMW.js.map → actions-virtual-module-E4PISKMB.js.map} +0 -0
- /package/dist/{actions-virtual-module-LB4NGONI.js.map → actions-virtual-module-YZRZMHAX.js.map} +0 -0
- /package/dist/{agent-7JJW3TPB.js.map → agent-XAQCUQNB.js.map} +0 -0
- /package/dist/{app-typed-client-GHO3EWZK.js.map → app-typed-client-HLP26EYM.js.map} +0 -0
- /package/dist/{app-typed-client-G3J5G7E5.js.map → app-typed-client-I4X2UJWW.js.map} +0 -0
- /package/dist/{aws-lambda-CYNDGU5O.js.map → aws-lambda-KES4MFJV.js.map} +0 -0
- /package/dist/{build-WU6AKKIB.js.map → build-F2Q5QTSC.js.map} +0 -0
- /package/dist/{bun-33RD6K7O.js.map → bun-A5B2MJMO.js.map} +0 -0
- /package/dist/{chunk-S433N3CT.js.map → chunk-AATSV4UV.js.map} +0 -0
- /package/dist/{chunk-E576KYYT.js.map → chunk-BHOTGS7N.js.map} +0 -0
- /package/dist/{chunk-GVW5EKEU.js.map → chunk-CMYSHZFT.js.map} +0 -0
- /package/dist/{chunk-PXFXSFJL.js.map → chunk-DS5MCU2X.js.map} +0 -0
- /package/dist/{cloudflare-KYUWCEPL.js.map → cloudflare-IN2WB7FZ.js.map} +0 -0
- /package/dist/{deno-deploy-CCTB7HGS.js.map → deno-deploy-LYXQEJ6A.js.map} +0 -0
- /package/dist/{dev-MUWJAZRD.js.map → dev-CDFPXISP.js.map} +0 -0
- /package/dist/{info-XW7HGUPH.js.map → info-QXZW722N.js.map} +0 -0
- /package/dist/{internal-api-V5L65YSJ.js.map → internal-api-FBK2YXSI.js.map} +0 -0
- /package/dist/{internal-api-WEOSTMSN.js.map → internal-api-ZCJWJ5EC.js.map} +0 -0
- /package/dist/{load-config-VKD6LKWU.js.map → load-config-FIWNKOJO.js.map} +0 -0
- /package/dist/{mcp-ULUFJNSZ.js.map → mcp-KTYP4ZON.js.map} +0 -0
- /package/dist/{netlify-AFMDNKT4.js.map → netlify-DLEOCFAD.js.map} +0 -0
- /package/dist/{node-ZJQEJSP3.js.map → node-QXYSUWQ4.js.map} +0 -0
- /package/dist/{openapi-HZXR335W.js.map → openapi-OUXNB2F2.js.map} +0 -0
- /package/dist/{registry-GKR3EWRW.js.map → registry-S7OMF3OS.js.map} +0 -0
- /package/dist/{routes-OLNQX7CT.js.map → routes-NJR4ISCT.js.map} +0 -0
- /package/dist/{schema-ZO3OSWVG.js.map → schema-DNIT7JQX.js.map} +0 -0
- /package/dist/{services-typed-client-PSAGRPFF.js.map → services-typed-client-P4JERLBL.js.map} +0 -0
- /package/dist/{static-M2W4HUWS.js.map → static-RTO637XW.js.map} +0 -0
- /package/dist/{theo-cloud-XAHWOUFK.js.map → theo-cloud-UZ3GINRU.js.map} +0 -0
- /package/dist/{vercel-SRS2DH6O.js.map → vercel-6D6EZUVD.js.map} +0 -0
- /package/dist/{vite-plugin-VPJFD4HK.js.map → vite-plugin-RJFKLF2U.js.map} +0 -0
package/dist/server/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ActionAccept, ActionBuilder, ActionConfig, ChannelHandler, MiddlewareBu
|
|
|
3
3
|
export { W as WebSocketHandler, a as WebSocketHandlerWeb, b as WebSocketLike } from '../define-websocket-DzPn1sR6.js';
|
|
4
4
|
export { C as CustomTool, D as DefineAgentToolSpec, T as ToolContextMessage, a as ToolHandlerContext, b as ToolTransform, c as applyTransform } from '../define-agent-tool-cRuSpidb.js';
|
|
5
5
|
export { H as HEALTH_PATH, a as HealthRouteConfig, b as READY_PATH, c as ReadyRouteConfig, d as ReservedResponse, R as ReservedRoutes, e as defineHealthRoute, f as defineReadyRoute, s as serveReservedRoute } from '../health-route-C0hk64_U.js';
|
|
6
|
-
export { B as BATCH_PATH, a as BatchExecuteFn, b as BatchPathConflictError, c as BatchPayload, d as BatchRequestItem, e as BatchResponse, f as BatchResultItem, C as CookieOptions, g as CorsConfig, h as CorsHandler, i as CorsOrigin, j as CorsWebHandler, k as CustomErrorPages, E as ExecuteActionOptions, l as ExecuteRouteContext, H as HandleBatchOptions, M as MAX_ERROR_HTML_BYTES, m as MiddlewareResult, N as NotFoundError, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, q as TheoError, r as TheoTransformer, _ as _resetMiddlewareCacheForTests, s as appendCookieToHeaders, t as appendDeleteCookieToHeaders, u as createCorsHandler, v as createCorsWebHandler, w as deleteCookie, x as envelopeCodeToStatus, y as executeAction, z as executeRoute, A as extractTraceId, D as extractTraceIdFromRequest, F as fromUnknown, G as getCookie, I as getCookieFromRequest, J as handleBatchRequest, K as handleRequestError, L as handleWebRequestError, O as jsonTransformer, P as loadCustomErrorPages, Q as matchesOrigin, R as parseCookieHeader, U as parseTraceparent, V as resolveTransformer, W as runMiddlewareAndContext, X as sendError, Y as sendJson, Z as serializeCookie, $ as serveStaticFile, a0 as serverErrorToEnvelope, a1 as setCookie, a2 as superjsonTransformer } from '../index-
|
|
6
|
+
export { B as BATCH_PATH, a as BatchExecuteFn, b as BatchPathConflictError, c as BatchPayload, d as BatchRequestItem, e as BatchResponse, f as BatchResultItem, C as CookieOptions, g as CorsConfig, h as CorsHandler, i as CorsOrigin, j as CorsWebHandler, k as CustomErrorPages, E as ExecuteActionOptions, l as ExecuteRouteContext, H as HandleBatchOptions, M as MAX_ERROR_HTML_BYTES, m as MiddlewareResult, N as NotFoundError, S as STRIPPED_HEADERS, n as SendErrorInput, o as SendErrorOptions, T as TRACE_HEADER, p as TRACE_PARENT_HEADER, q as TheoError, r as TheoTransformer, _ as _resetMiddlewareCacheForTests, s as appendCookieToHeaders, t as appendDeleteCookieToHeaders, u as createCorsHandler, v as createCorsWebHandler, w as deleteCookie, x as envelopeCodeToStatus, y as executeAction, z as executeRoute, A as extractTraceId, D as extractTraceIdFromRequest, F as fromUnknown, G as getCookie, I as getCookieFromRequest, J as handleBatchRequest, K as handleRequestError, L as handleWebRequestError, O as jsonTransformer, P as loadCustomErrorPages, Q as matchesOrigin, R as parseCookieHeader, U as parseTraceparent, V as resolveTransformer, W as runMiddlewareAndContext, X as sendError, Y as sendJson, Z as serializeCookie, $ as serveStaticFile, a0 as serverErrorToEnvelope, a1 as setCookie, a2 as superjsonTransformer } from '../index-D_PxPXgQ.js';
|
|
7
7
|
export { ActionNode, ActionScanError, LoadedManifest, ManifestAction, ManifestAgent, ManifestRoute, ManifestWebSocket, TheoManifest, WebSocketRouteNode, generateManifest, loadManifest, scanMiddlewares, scanServerActions, scanServerActionsEnriched, scanServerRoutes, scanWebSocketRoutes, writeManifest } from './scan/index.js';
|
|
8
8
|
export { L as LoadModule, S as ServerRouteNode, c as compilePattern, a as createProductionLoader, b as createViteLoader, m as matchRoute } from '../match-CfbEFRG4.js';
|
|
9
9
|
import { T as TheoErrorEnvelope, a as TheoErrorCode, V as ValidationFieldsExt } from '../error-envelope-DG47lt8E.js';
|
|
@@ -17,7 +17,7 @@ export { DuplicateContextKeyError, DuplicateJobNameError, EnqueueOptions, InMemo
|
|
|
17
17
|
export { J as JobBackend, a as JobEnqueueInput, b as JobLease, N as NonRetryableError } from '../job-backend-CgC8Xf33.js';
|
|
18
18
|
export { ConsoleObservabilityAdapter, LogLevel, LoggerFn, NoopObservabilityAdapter, NoopSpan, ObservabilityAdapter, RequestLog, SpanAttributes, SpanHandle, SpanImpl, StructuredLog, TheoCloudObservabilityAdapter, TheoLogger, _resetWarnOnceForTests, createLogger, createObservabilityPlugin, defineObservabilityAdapter, findSuggestion, levenshtein, logRequest, resolveAdapter, serializeSpansToOtlp, warnOnce } from './observability/index.js';
|
|
19
19
|
export { a as AuditEvent, A as AuditLogger, J as JsonStdoutSink, c as createNoOpLogger, s as safeAudit } from '../audit-log-BQWM5YLG.js';
|
|
20
|
-
export { D as DuplicateDecorationError, a as DuplicatePluginError, P as PluginRunner } from '../plugin-runner-
|
|
20
|
+
export { D as DuplicateDecorationError, a as DuplicatePluginError, P as PluginRunner } from '../plugin-runner-DHVr1cC5.js';
|
|
21
21
|
export { InvalidPluginShapeError, createPluginRunnerFromConfig } from './plugins/index.js';
|
|
22
22
|
export { R as RateLimitConfig, a as RateLimitResult, c as createRateLimiter, b as createRateLimiterWeb } from '../rate-limit-BdNDZ3vt.js';
|
|
23
23
|
export { I as InMemoryStore, a as RateLimitState, R as RateLimitStore } from '../rate-limit-store-BEJnhWdw.js';
|
|
@@ -33,8 +33,8 @@ export { BodyTooLargeError, DEFAULT_MAX_BODY_BYTES, RawBodyResult, ReadRawBodyOp
|
|
|
33
33
|
export { D as DefineWebhookOptions, V as VerifyFn, a as VerifyResult, W as WebhookContext, b as WebhookDefinition } from '../webhook-types-DGIjjcaI.js';
|
|
34
34
|
import { z } from 'zod';
|
|
35
35
|
import { IncomingMessage } from 'node:http';
|
|
36
|
-
import { W as WebOnRequestHook, b as WebPreHandlerHook, c as WebOnResponseHook, d as WebOnErrorHook } from '../plugin-types-
|
|
37
|
-
export { e as HookName, H as HookResult, O as OnErrorHook, f as OnRequestHook, g as OnResponseHook, P as PluginContext, h as PluginErrorContext, i as PreHandlerHook, R as RunHookOptions, a as TheoApp, T as TheoPlugin } from '../plugin-types-
|
|
36
|
+
import { W as WebOnRequestHook, b as WebPreHandlerHook, c as WebOnResponseHook, d as WebOnErrorHook } from '../plugin-types-4VN1GMqV.js';
|
|
37
|
+
export { e as HookName, H as HookResult, O as OnErrorHook, f as OnRequestHook, g as OnResponseHook, P as PluginContext, h as PluginErrorContext, i as PreHandlerHook, R as RunHookOptions, a as TheoApp, T as TheoPlugin } from '../plugin-types-4VN1GMqV.js';
|
|
38
38
|
export { ComposeInstructionsOptions, ComposedInstructions, ConfigLayer, ContextPressure, ContextPressureThresholdError, ContextPressureThresholds, CustomCommand, CustomCommandsResult, DEFAULT_CONTEXT_PRESSURE_THRESHOLDS, InstructionBlock, InstructionSource, InstructionTree, InstructionTreeBudget, LayerOutOfOrderError, LayeredConfig, LayeredConfigInput, LayeredConfigResult, LoadCustomCommandsInput, LoadInstructionTreeInput, ParsedFrontmatter, PrecedenceReport, ProvenancePerKey, TrustRecord, TrustStore, TrustStorePermissionsError, composeInstructions, contextPressure, effectiveContextWindow, frontmatterValue, loadCustomCommands, loadInstructionTree, splitFrontmatter } from '@theokit/agents/config';
|
|
39
39
|
export { a as ServiceDefinition, S as ServicesConfig, b as ServicesConfigInput, c as ServicesConfigOutput } from '../schema-BdakLtuC.js';
|
|
40
40
|
import '@theokit/presenter/wire';
|
package/dist/server/index.js
CHANGED
|
@@ -204,7 +204,7 @@ import {
|
|
|
204
204
|
resetProviderRegistry,
|
|
205
205
|
resolveProvider,
|
|
206
206
|
tryResolveProvider
|
|
207
|
-
} from "../chunk-
|
|
207
|
+
} from "../chunk-AXKUA57G.js";
|
|
208
208
|
import {
|
|
209
209
|
AuthRequiredError,
|
|
210
210
|
_resetKeyCacheForTests,
|
|
@@ -281,7 +281,7 @@ import {
|
|
|
281
281
|
tool,
|
|
282
282
|
uiMessageStreamResponse,
|
|
283
283
|
websocket
|
|
284
|
-
} from "../chunk-
|
|
284
|
+
} from "../chunk-YXG2SGQ3.js";
|
|
285
285
|
import {
|
|
286
286
|
HEALTH_PATH,
|
|
287
287
|
READY_PATH,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as PluginRunner } from '../../plugin-runner-
|
|
2
|
-
export { D as DuplicateDecorationError, a as DuplicatePluginError } from '../../plugin-runner-
|
|
3
|
-
import '../../plugin-types-
|
|
1
|
+
import { P as PluginRunner } from '../../plugin-runner-DHVr1cC5.js';
|
|
2
|
+
export { D as DuplicateDecorationError, a as DuplicatePluginError } from '../../plugin-runner-DHVr1cC5.js';
|
|
3
|
+
import '../../plugin-types-4VN1GMqV.js';
|
|
4
4
|
import 'node:http';
|
|
5
5
|
|
|
6
6
|
declare class InvalidPluginShapeError extends Error {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "tsx/esm";
|
|
3
3
|
import {
|
|
4
4
|
generateTypedClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WSXNGF7X.js";
|
|
6
6
|
|
|
7
7
|
// src/vite-plugin/services-typed-client.ts
|
|
8
8
|
import { resolve } from "path";
|
|
@@ -44,4 +44,4 @@ function servicesTypedClientPlugin(opts) {
|
|
|
44
44
|
export {
|
|
45
45
|
servicesTypedClientPlugin
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=services-typed-client-
|
|
47
|
+
//# sourceMappingURL=services-typed-client-P4JERLBL.js.map
|
|
@@ -18,19 +18,19 @@ import {
|
|
|
18
18
|
resolveTransformer,
|
|
19
19
|
serveAgentAuxRoute,
|
|
20
20
|
writeWebResponseToServerResponse
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-NTWNO24W.js";
|
|
22
22
|
import "./chunk-2CVV6CNN.js";
|
|
23
23
|
import {
|
|
24
24
|
findRootDiv
|
|
25
25
|
} from "./chunk-3PWQQWT6.js";
|
|
26
26
|
import {
|
|
27
27
|
loadConfig
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-AATSV4UV.js";
|
|
29
29
|
import {
|
|
30
30
|
loadEnv
|
|
31
31
|
} from "./chunk-HBU2GIMZ.js";
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-CMYSHZFT.js";
|
|
33
|
+
import "./chunk-WSXNGF7X.js";
|
|
34
34
|
import {
|
|
35
35
|
InMemoryStore,
|
|
36
36
|
buildSecurityHeaders,
|
|
@@ -41,11 +41,11 @@ import {
|
|
|
41
41
|
findSuggestion,
|
|
42
42
|
generateNonce,
|
|
43
43
|
mountAgent
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-WYHYOYRH.js";
|
|
45
45
|
import {
|
|
46
46
|
getApprovalRegistry,
|
|
47
47
|
resolveProvider
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-DQIPV7L5.js";
|
|
49
49
|
import {
|
|
50
50
|
dispatchControllerRequest,
|
|
51
51
|
incomingMessageToWebRequest,
|
|
@@ -69,9 +69,102 @@ import "./chunk-A7JBF5FO.js";
|
|
|
69
69
|
import "./chunk-VQIUTCK2.js";
|
|
70
70
|
|
|
71
71
|
// src/cli/commands/start/index.ts
|
|
72
|
-
import { existsSync as
|
|
72
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
73
73
|
import { createServer } from "http";
|
|
74
|
-
import { join as join2, resolve as
|
|
74
|
+
import { join as join2, resolve as resolve4 } from "path";
|
|
75
|
+
|
|
76
|
+
// src/server/cron/cron-runtime-node.ts
|
|
77
|
+
import { CronExpressionParser } from "cron-parser";
|
|
78
|
+
|
|
79
|
+
// src/server/observability/trace-context-propagation.ts
|
|
80
|
+
function generateNewTraceContext() {
|
|
81
|
+
return {
|
|
82
|
+
trace_id: randomHex(16),
|
|
83
|
+
// 16 bytes = 32 hex chars
|
|
84
|
+
span_id: randomHex(8),
|
|
85
|
+
// 8 bytes = 16 hex chars
|
|
86
|
+
flags: "01"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function randomHex(bytes) {
|
|
90
|
+
for (; ; ) {
|
|
91
|
+
const buf = new Uint8Array(bytes);
|
|
92
|
+
globalThis.crypto.getRandomValues(buf);
|
|
93
|
+
let hex = "";
|
|
94
|
+
for (const b of buf) hex += b.toString(16).padStart(2, "0");
|
|
95
|
+
if (!/^0+$/.test(hex)) return hex;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/server/cron/cron-runtime-node.ts
|
|
100
|
+
function createCronScheduler(definitions) {
|
|
101
|
+
const states = definitions.map((def) => ({
|
|
102
|
+
def,
|
|
103
|
+
inFlight: false,
|
|
104
|
+
timer: null,
|
|
105
|
+
abortController: null
|
|
106
|
+
}));
|
|
107
|
+
let started = false;
|
|
108
|
+
const fireAndReschedule = (state, scheduledAt) => {
|
|
109
|
+
state.timer = null;
|
|
110
|
+
if (state.inFlight && state.def.concurrency === "forbid") {
|
|
111
|
+
console.warn(
|
|
112
|
+
`[theokit:cron] "${state.def.name}" skipped tick at ${scheduledAt.toISOString()} \u2014 previous handler still running (concurrency: forbid).`
|
|
113
|
+
);
|
|
114
|
+
scheduleNext(state);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
state.inFlight = true;
|
|
118
|
+
state.abortController = new AbortController();
|
|
119
|
+
const traceCtx = generateNewTraceContext();
|
|
120
|
+
const ctx = {
|
|
121
|
+
traceId: traceCtx.trace_id,
|
|
122
|
+
scheduledAt,
|
|
123
|
+
signal: state.abortController.signal
|
|
124
|
+
};
|
|
125
|
+
void Promise.resolve().then(() => state.def.handler(ctx)).catch((err) => {
|
|
126
|
+
console.error(
|
|
127
|
+
`[theokit:cron] "${state.def.name}" handler error:`,
|
|
128
|
+
err instanceof Error ? err.message : err
|
|
129
|
+
);
|
|
130
|
+
}).finally(() => {
|
|
131
|
+
state.inFlight = false;
|
|
132
|
+
});
|
|
133
|
+
scheduleNext(state);
|
|
134
|
+
};
|
|
135
|
+
const scheduleNext = (state) => {
|
|
136
|
+
if (!started) return;
|
|
137
|
+
const interval = CronExpressionParser.parse(state.def.schedule, {
|
|
138
|
+
tz: "UTC",
|
|
139
|
+
currentDate: /* @__PURE__ */ new Date()
|
|
140
|
+
});
|
|
141
|
+
const next = interval.next().toDate();
|
|
142
|
+
const delayMs = Math.max(0, next.getTime() - Date.now());
|
|
143
|
+
state.timer = setTimeout(() => {
|
|
144
|
+
fireAndReschedule(state, next);
|
|
145
|
+
}, delayMs);
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
start() {
|
|
149
|
+
if (started) return;
|
|
150
|
+
started = true;
|
|
151
|
+
for (const state of states) {
|
|
152
|
+
scheduleNext(state);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
stop() {
|
|
156
|
+
started = false;
|
|
157
|
+
for (const state of states) {
|
|
158
|
+
if (state.timer) {
|
|
159
|
+
clearTimeout(state.timer);
|
|
160
|
+
state.timer = null;
|
|
161
|
+
}
|
|
162
|
+
state.abortController?.abort();
|
|
163
|
+
state.abortController = null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
75
168
|
|
|
76
169
|
// src/server/define/health-route.ts
|
|
77
170
|
var HEALTH_PATH = "/__theo/health";
|
|
@@ -330,7 +423,7 @@ async function configureStorageManagerFromConfig(storageConfig) {
|
|
|
330
423
|
if (storageConfig === void 0 || storageConfig === null) return;
|
|
331
424
|
try {
|
|
332
425
|
const { getStorageManager } = await import("./storage-manager-3O5PDO6O.js");
|
|
333
|
-
const { storageSchema } = await import("./schema-
|
|
426
|
+
const { storageSchema } = await import("./schema-DNIT7JQX.js");
|
|
334
427
|
const parsed = storageSchema.parse(storageConfig);
|
|
335
428
|
getStorageManager().configure(parsed);
|
|
336
429
|
} catch (err) {
|
|
@@ -350,6 +443,32 @@ function resolveSsrEntry(distDir) {
|
|
|
350
443
|
return null;
|
|
351
444
|
}
|
|
352
445
|
|
|
446
|
+
// src/cli/commands/start/cron-bootstrap.ts
|
|
447
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
448
|
+
import { resolve as resolve2 } from "path";
|
|
449
|
+
async function loadCronDefinitions(manifestPath, projectRoot, loadModule) {
|
|
450
|
+
if (!existsSync2(manifestPath)) return [];
|
|
451
|
+
const manifest = JSON.parse(readFileSync2(manifestPath, "utf-8"));
|
|
452
|
+
const definitions = [];
|
|
453
|
+
for (const entry of manifest.crons) {
|
|
454
|
+
const filePath = resolve2(projectRoot, entry.filePath);
|
|
455
|
+
const mod = await loadModule(filePath);
|
|
456
|
+
const exported = mod.default;
|
|
457
|
+
if (!isCronDefinition(exported)) {
|
|
458
|
+
throw new Error(
|
|
459
|
+
`Cron "${entry.name}" declared in "${entry.filePath}" is missing a valid default export. Expected \`export default defineCron(name, { schedule, handler })\`. Re-run \`theokit build\` if the file changed since the last build.`
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
definitions.push(exported);
|
|
463
|
+
}
|
|
464
|
+
return definitions;
|
|
465
|
+
}
|
|
466
|
+
function isCronDefinition(value) {
|
|
467
|
+
if (typeof value !== "object" || value === null) return false;
|
|
468
|
+
const candidate = value;
|
|
469
|
+
return typeof candidate.name === "string" && typeof candidate.schedule === "string" && typeof candidate.handler === "function";
|
|
470
|
+
}
|
|
471
|
+
|
|
353
472
|
// src/cli/commands/start/graceful-shutdown.ts
|
|
354
473
|
function installGracefulShutdown(server) {
|
|
355
474
|
let shuttingDown = false;
|
|
@@ -404,12 +523,12 @@ function installGracefulShutdown(server) {
|
|
|
404
523
|
}
|
|
405
524
|
|
|
406
525
|
// src/cli/commands/start/manifest-loader.ts
|
|
407
|
-
import { existsSync as
|
|
526
|
+
import { existsSync as existsSync3 } from "fs";
|
|
408
527
|
import { join } from "path";
|
|
409
528
|
import { dirname } from "path";
|
|
410
529
|
function loadRoutesAndActions(distDir, serverDir, agentsDir = "agents") {
|
|
411
530
|
const manifestPath = join(distDir, "manifest.json");
|
|
412
|
-
if (
|
|
531
|
+
if (existsSync3(manifestPath)) {
|
|
413
532
|
const manifest = loadManifest(distDir, serverDir);
|
|
414
533
|
return {
|
|
415
534
|
routes: manifest.routes,
|
|
@@ -440,8 +559,8 @@ import { extname as extname2 } from "path";
|
|
|
440
559
|
import { pathToFileURL } from "url";
|
|
441
560
|
|
|
442
561
|
// src/server/http/static.ts
|
|
443
|
-
import { existsSync as
|
|
444
|
-
import { resolve as
|
|
562
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, statSync } from "fs";
|
|
563
|
+
import { resolve as resolve3, extname } from "path";
|
|
445
564
|
var MIME_TYPES = {
|
|
446
565
|
".html": "text/html",
|
|
447
566
|
".js": "application/javascript",
|
|
@@ -462,18 +581,18 @@ var MIME_TYPES = {
|
|
|
462
581
|
};
|
|
463
582
|
function serveStaticFile(req, res, clientDir) {
|
|
464
583
|
const urlPath = (req.url ?? "/").split("?")[0];
|
|
465
|
-
const filePath =
|
|
584
|
+
const filePath = resolve3(clientDir, "." + urlPath);
|
|
466
585
|
if (!filePath.startsWith(clientDir)) {
|
|
467
586
|
res.writeHead(403);
|
|
468
587
|
res.end("Forbidden");
|
|
469
588
|
return true;
|
|
470
589
|
}
|
|
471
|
-
if (!
|
|
590
|
+
if (!existsSync4(filePath)) return false;
|
|
472
591
|
const stat = statSync(filePath);
|
|
473
592
|
if (!stat.isFile()) return false;
|
|
474
593
|
const ext = extname(filePath);
|
|
475
594
|
const contentType = MIME_TYPES[ext] ?? "application/octet-stream";
|
|
476
|
-
const content =
|
|
595
|
+
const content = readFileSync3(filePath);
|
|
477
596
|
res.writeHead(200, {
|
|
478
597
|
"Content-Type": contentType,
|
|
479
598
|
"Content-Length": content.length
|
|
@@ -577,7 +696,8 @@ async function tryServeAgentAux(c) {
|
|
|
577
696
|
// M34 (#97) — the MCP aux route drives the agent (spends tokens); enforce CSRF like the run route.
|
|
578
697
|
csrfMode: c.csrfMode,
|
|
579
698
|
// M39 — the thread follow-up route drives the agent; resolve the key on demand.
|
|
580
|
-
|
|
699
|
+
// theokit#328 — the thread route drives an agent, so its key follows the model too.
|
|
700
|
+
resolveApiKey: (model) => resolveProvider(model).apiKey
|
|
581
701
|
});
|
|
582
702
|
if (response === null) return false;
|
|
583
703
|
c.res.setHeader(X_REQUEST_ID, c.requestId);
|
|
@@ -667,10 +787,50 @@ async function tryServeAgent(c) {
|
|
|
667
787
|
});
|
|
668
788
|
return true;
|
|
669
789
|
}
|
|
790
|
+
await serveAgentTurn(c, agent, method);
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
async function serveAgentTurn(c, agent, method) {
|
|
794
|
+
let pluginCtx;
|
|
795
|
+
let request;
|
|
796
|
+
try {
|
|
797
|
+
request = incomingMessageToWebRequest(c.req);
|
|
798
|
+
pluginCtx = { request, response: c.res, ctx: {}, requestId: c.requestId };
|
|
799
|
+
} catch (err) {
|
|
800
|
+
sendError(
|
|
801
|
+
c.res,
|
|
802
|
+
"INTERNAL",
|
|
803
|
+
err instanceof Error ? err.message : "Agent handler failed",
|
|
804
|
+
500,
|
|
805
|
+
void 0,
|
|
806
|
+
c.requestId
|
|
807
|
+
);
|
|
808
|
+
logRequest({
|
|
809
|
+
method,
|
|
810
|
+
url: c.url,
|
|
811
|
+
status: c.res.statusCode,
|
|
812
|
+
duration: Date.now() - c.startTime,
|
|
813
|
+
requestId: c.requestId
|
|
814
|
+
});
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
if (c.pluginRunner) {
|
|
818
|
+
c.pluginRunner.applyDecorations(pluginCtx.ctx);
|
|
819
|
+
const onRequest = await c.pluginRunner.runOnRequest(pluginCtx);
|
|
820
|
+
if (onRequest.shortCircuited) {
|
|
821
|
+
logRequest({
|
|
822
|
+
method,
|
|
823
|
+
url: c.url,
|
|
824
|
+
status: c.res.statusCode,
|
|
825
|
+
duration: Date.now() - c.startTime,
|
|
826
|
+
requestId: c.requestId
|
|
827
|
+
});
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
670
831
|
try {
|
|
671
832
|
const mod = await c.loadModule(agent.filePath);
|
|
672
|
-
const apiKey = resolveProvider().apiKey;
|
|
673
|
-
const request = incomingMessageToWebRequest(c.req);
|
|
833
|
+
const apiKey = (model) => resolveProvider(model).apiKey;
|
|
674
834
|
const response = await mountAgent(mod, request, apiKey, {
|
|
675
835
|
source: agent.filePath,
|
|
676
836
|
csrfMode: c.csrfMode,
|
|
@@ -678,6 +838,7 @@ async function tryServeAgent(c) {
|
|
|
678
838
|
});
|
|
679
839
|
await writeWebResponseToServerResponse(response, c.res);
|
|
680
840
|
} catch (err) {
|
|
841
|
+
if (c.pluginRunner) await c.pluginRunner.runOnError(pluginCtx, err);
|
|
681
842
|
sendError(
|
|
682
843
|
c.res,
|
|
683
844
|
"INTERNAL",
|
|
@@ -687,6 +848,7 @@ async function tryServeAgent(c) {
|
|
|
687
848
|
c.requestId
|
|
688
849
|
);
|
|
689
850
|
}
|
|
851
|
+
if (c.pluginRunner) await c.pluginRunner.runOnResponse(pluginCtx);
|
|
690
852
|
logRequest({
|
|
691
853
|
method,
|
|
692
854
|
url: c.url,
|
|
@@ -694,7 +856,6 @@ async function tryServeAgent(c) {
|
|
|
694
856
|
duration: Date.now() - c.startTime,
|
|
695
857
|
requestId: c.requestId
|
|
696
858
|
});
|
|
697
|
-
return true;
|
|
698
859
|
}
|
|
699
860
|
async function tryServeApiRoute(c) {
|
|
700
861
|
if (!c.url.startsWith("/api/")) return false;
|
|
@@ -988,22 +1149,22 @@ async function startCommand(options) {
|
|
|
988
1149
|
assertSdkCompatible();
|
|
989
1150
|
await configureAgentRegistryFromConfig(config.agents?.registry);
|
|
990
1151
|
await configureStorageManagerFromConfig(config.storage);
|
|
991
|
-
const distDir =
|
|
992
|
-
const clientDir =
|
|
993
|
-
const controllersDistDir =
|
|
994
|
-
const serverDir =
|
|
995
|
-
if (!
|
|
1152
|
+
const distDir = resolve4(cwd, ".theokit");
|
|
1153
|
+
const clientDir = resolve4(distDir, "client");
|
|
1154
|
+
const controllersDistDir = existsSync5(resolve4(distDir, CONTROLLER_MANIFEST_FILE)) ? resolve4(distDir, "controllers") : void 0;
|
|
1155
|
+
const serverDir = resolve4(cwd, config.serverDir);
|
|
1156
|
+
if (!existsSync5(clientDir)) {
|
|
996
1157
|
throw new Error("No build found. Run `theo build` first.");
|
|
997
1158
|
}
|
|
998
|
-
const indexHtml =
|
|
1159
|
+
const indexHtml = readFileSync4(join2(clientDir, "index.html"), "utf-8");
|
|
999
1160
|
const loadModule = createProductionLoader();
|
|
1000
1161
|
const port = options.port ?? config.port;
|
|
1001
1162
|
const pluginRunner = await createPluginRunnerFromConfig(config.plugins);
|
|
1002
1163
|
const transformer = resolveTransformer(config.serialization);
|
|
1003
1164
|
const custom404Path = join2(clientDir, "404.html");
|
|
1004
1165
|
const custom500Path = join2(clientDir, "500.html");
|
|
1005
|
-
const custom404Html =
|
|
1006
|
-
const custom500Html =
|
|
1166
|
+
const custom404Html = existsSync5(custom404Path) ? readFileSync4(custom404Path, "utf-8") : null;
|
|
1167
|
+
const custom500Html = existsSync5(custom500Path) ? readFileSync4(custom500Path, "utf-8") : null;
|
|
1007
1168
|
const {
|
|
1008
1169
|
routes: cachedRoutes,
|
|
1009
1170
|
actions: cachedActions,
|
|
@@ -1055,11 +1216,19 @@ async function startCommand(options) {
|
|
|
1055
1216
|
})
|
|
1056
1217
|
);
|
|
1057
1218
|
await attachWebSocketHandler(server, cachedWsRoutes, loadModule);
|
|
1219
|
+
const cronDefinitions = await loadCronDefinitions(resolve4(distDir, "crons.json"), cwd, loadModule);
|
|
1220
|
+
if (cronDefinitions.length > 0) {
|
|
1221
|
+
createCronScheduler(cronDefinitions).start();
|
|
1222
|
+
}
|
|
1058
1223
|
server.listen(port, () => {
|
|
1059
1224
|
console.log(`
|
|
1060
1225
|
Theo production server`);
|
|
1061
1226
|
console.log(` \u2192 http://localhost:${String(port)}
|
|
1062
1227
|
`);
|
|
1228
|
+
if (cronDefinitions.length > 0) {
|
|
1229
|
+
console.log(` Crons: ${String(cronDefinitions.length)} scheduled in-process
|
|
1230
|
+
`);
|
|
1231
|
+
}
|
|
1063
1232
|
});
|
|
1064
1233
|
installGracefulShutdown(server);
|
|
1065
1234
|
}
|
|
@@ -1067,4 +1236,4 @@ export {
|
|
|
1067
1236
|
resolveSsrEntry,
|
|
1068
1237
|
startCommand
|
|
1069
1238
|
};
|
|
1070
|
-
//# sourceMappingURL=start-
|
|
1239
|
+
//# sourceMappingURL=start-25OV2CAK.js.map
|