@cloudflare/think 0.8.5 → 0.8.7
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 +32 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +650 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/codegen-CauNNguA.js +140 -0
- package/dist/codegen-CauNNguA.js.map +1 -0
- package/dist/config-D512sQYg.d.ts +71 -0
- package/dist/framework/index.d.ts +215 -0
- package/dist/framework/index.js +58 -0
- package/dist/framework/index.js.map +1 -0
- package/dist/manifest-CpB-xngB.d.ts +143 -0
- package/dist/messengers/index.d.ts +54 -54
- package/dist/messengers/telegram.d.ts +4 -4
- package/dist/project-D1o1-3dN.js +685 -0
- package/dist/project-D1o1-3dN.js.map +1 -0
- package/dist/server-entry.d.ts +118 -0
- package/dist/server-entry.js +265 -0
- package/dist/server-entry.js.map +1 -0
- package/dist/{index-BzPfnYMr.d.ts → think-8jik2oZ5.d.ts} +1296 -1296
- package/dist/think.d.ts +2 -123
- package/dist/types-codegen-B6c5KpYH.js +125 -0
- package/dist/types-codegen-B6c5KpYH.js.map +1 -0
- package/dist/vite.d.ts +39 -0
- package/dist/vite.js +121 -0
- package/dist/vite.js.map +1 -0
- package/dist/workflows.d.ts +1 -1
- package/package.json +31 -4
package/dist/think.d.ts
CHANGED
|
@@ -1,124 +1,3 @@
|
|
|
1
1
|
import { h as WorkspaceLike } from "./workspace-BZXdZcuw.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
At as StepResult,
|
|
5
|
-
Bt as ThinkScheduledTaskContext,
|
|
6
|
-
Ct as SaveMessagesOptions,
|
|
7
|
-
Dt as SkillSource,
|
|
8
|
-
Et as SkillRunContext,
|
|
9
|
-
Ft as SubmitMessagesResult,
|
|
10
|
-
Gt as ThinkTime,
|
|
11
|
-
Ht as ThinkScheduledTasks,
|
|
12
|
-
It as TextStreamPart,
|
|
13
|
-
Jt as ToolCallDecision,
|
|
14
|
-
Kt as ThinkWallClockSchedule,
|
|
15
|
-
Lt as Think,
|
|
16
|
-
Mt as StreamCallback,
|
|
17
|
-
Nt as StreamableResult,
|
|
18
|
-
Ot as StepConfig,
|
|
19
|
-
Pt as SubmitMessagesOptions,
|
|
20
|
-
Qt as TurnInput,
|
|
21
|
-
Rt as ThinkIntervalSchedule,
|
|
22
|
-
St as ResolvedChatRecoveryConfig,
|
|
23
|
-
Tt as Session,
|
|
24
|
-
Ut as ThinkSubmissionInspection,
|
|
25
|
-
Vt as ThinkScheduledTaskSchedule,
|
|
26
|
-
Wt as ThinkSubmissionStatus,
|
|
27
|
-
Xt as TurnConfig,
|
|
28
|
-
Yt as ToolCallResultContext,
|
|
29
|
-
Zt as TurnContext,
|
|
30
|
-
_t as ListSubmissionsOptions,
|
|
31
|
-
at as ChatRecoveryExhaustedContext,
|
|
32
|
-
bt as PrepareStepFunction,
|
|
33
|
-
ct as ChatResponseResult,
|
|
34
|
-
dt as ChunkPart,
|
|
35
|
-
en as TypedToolResult,
|
|
36
|
-
et as ChatErrorClassification,
|
|
37
|
-
ft as ContextOverflowConfig,
|
|
38
|
-
gt as FiberRecoveryContext,
|
|
39
|
-
ht as FiberContext,
|
|
40
|
-
in as skills,
|
|
41
|
-
it as ChatRecoveryContext,
|
|
42
|
-
jt as StopCondition,
|
|
43
|
-
kt as StepContext,
|
|
44
|
-
lt as ChatStartEvent,
|
|
45
|
-
mt as ExtensionConfig,
|
|
46
|
-
nn as defaultContextOverflowClassifier,
|
|
47
|
-
nt as ChatOptions,
|
|
48
|
-
ot as ChatRecoveryOptions,
|
|
49
|
-
pt as DeleteSubmissionsOptions,
|
|
50
|
-
qt as ToolCallContext,
|
|
51
|
-
rn as defineScheduledTasks,
|
|
52
|
-
rt as ChatRecoveryConfig,
|
|
53
|
-
st as ChatRecoveryProgressContext,
|
|
54
|
-
tn as Workspace,
|
|
55
|
-
tt as ChatErrorContext,
|
|
56
|
-
ut as ChunkContext,
|
|
57
|
-
vt as MessageConcurrency,
|
|
58
|
-
wt as SaveMessagesResult,
|
|
59
|
-
xt as PrepareStepResult,
|
|
60
|
-
yt as PrepareStepContext,
|
|
61
|
-
zt as ThinkScheduledTask
|
|
62
|
-
} from "./index-BzPfnYMr.js";
|
|
63
|
-
export {
|
|
64
|
-
ChatErrorClassification,
|
|
65
|
-
ChatErrorContext,
|
|
66
|
-
ChatOptions,
|
|
67
|
-
type ChatRecoveryConfig,
|
|
68
|
-
type ChatRecoveryContext,
|
|
69
|
-
type ChatRecoveryExhaustedContext,
|
|
70
|
-
type ChatRecoveryOptions,
|
|
71
|
-
type ChatRecoveryProgressContext,
|
|
72
|
-
type ChatResponseResult,
|
|
73
|
-
ChatStartEvent,
|
|
74
|
-
ChunkContext,
|
|
75
|
-
ChunkPart,
|
|
76
|
-
ContextOverflowConfig,
|
|
77
|
-
DeleteSubmissionsOptions,
|
|
78
|
-
ExtensionConfig,
|
|
79
|
-
type FiberContext,
|
|
80
|
-
type FiberRecoveryContext,
|
|
81
|
-
ListSubmissionsOptions,
|
|
82
|
-
type MessageConcurrency,
|
|
83
|
-
PrepareStepContext,
|
|
84
|
-
type PrepareStepFunction,
|
|
85
|
-
type PrepareStepResult,
|
|
86
|
-
type ResolvedChatRecoveryConfig,
|
|
87
|
-
type SaveMessagesOptions,
|
|
88
|
-
type SaveMessagesResult,
|
|
89
|
-
Session,
|
|
90
|
-
type SkillRunContext,
|
|
91
|
-
type SkillSource,
|
|
92
|
-
StepConfig,
|
|
93
|
-
StepContext,
|
|
94
|
-
type StepResult,
|
|
95
|
-
type StopCondition,
|
|
96
|
-
StreamCallback,
|
|
97
|
-
StreamableResult,
|
|
98
|
-
SubmitMessagesOptions,
|
|
99
|
-
SubmitMessagesResult,
|
|
100
|
-
type TextStreamPart,
|
|
101
|
-
Think,
|
|
102
|
-
ThinkIntervalSchedule,
|
|
103
|
-
ThinkScheduledTask,
|
|
104
|
-
ThinkScheduledTaskContext,
|
|
105
|
-
ThinkScheduledTaskSchedule,
|
|
106
|
-
ThinkScheduledTasks,
|
|
107
|
-
ThinkSubmissionInspection,
|
|
108
|
-
ThinkSubmissionStatus,
|
|
109
|
-
ThinkTime,
|
|
110
|
-
ThinkWallClockSchedule,
|
|
111
|
-
ToolCallContext,
|
|
112
|
-
ToolCallDecision,
|
|
113
|
-
ToolCallResultContext,
|
|
114
|
-
TurnConfig,
|
|
115
|
-
TurnContext,
|
|
116
|
-
TurnInput,
|
|
117
|
-
type TypedToolCall,
|
|
118
|
-
type TypedToolResult,
|
|
119
|
-
Workspace,
|
|
120
|
-
type WorkspaceLike,
|
|
121
|
-
defaultContextOverflowClassifier,
|
|
122
|
-
defineScheduledTasks,
|
|
123
|
-
skills
|
|
124
|
-
};
|
|
2
|
+
import { $ as TurnInput, A as StepContext, B as ThinkScheduledTask, C as ResolvedChatRecoveryConfig, D as SkillRunContext, E as Session, F as SubmitMessagesOptions, G as ThinkSubmissionStatus, H as ThinkScheduledTaskSchedule, I as SubmitMessagesResult, J as ToolCallContext, K as ThinkTime, L as TextStreamPart, M as StopCondition, N as StreamCallback, O as SkillSource, P as StreamableResult, Q as TurnContext, R as Think, S as PrepareStepResult, T as SaveMessagesResult, U as ThinkScheduledTasks, V as ThinkScheduledTaskContext, W as ThinkSubmissionInspection, X as ToolCallResultContext, Y as ToolCallDecision, Z as TurnConfig, _ as FiberRecoveryContext, a as ChatRecoveryContext, at as skills, b as PrepareStepContext, c as ChatRecoveryProgressContext, d as ChunkContext, et as TypedToolCall, f as ChunkPart, g as FiberContext, h as ExtensionConfig, i as ChatRecoveryConfig, it as defineScheduledTasks, j as StepResult, k as StepConfig, l as ChatResponseResult, m as DeleteSubmissionsOptions, n as ChatErrorContext, nt as Workspace, o as ChatRecoveryExhaustedContext, p as ContextOverflowConfig, q as ThinkWallClockSchedule, r as ChatOptions, rt as defaultContextOverflowClassifier, s as ChatRecoveryOptions, t as ChatErrorClassification, tt as TypedToolResult, u as ChatStartEvent, v as ListSubmissionsOptions, w as SaveMessagesOptions, x as PrepareStepFunction, y as MessageConcurrency, z as ThinkIntervalSchedule } from "./think-8jik2oZ5.js";
|
|
3
|
+
export { ChatErrorClassification, ChatErrorContext, ChatOptions, type ChatRecoveryConfig, type ChatRecoveryContext, type ChatRecoveryExhaustedContext, type ChatRecoveryOptions, type ChatRecoveryProgressContext, type ChatResponseResult, ChatStartEvent, ChunkContext, ChunkPart, ContextOverflowConfig, DeleteSubmissionsOptions, ExtensionConfig, type FiberContext, type FiberRecoveryContext, ListSubmissionsOptions, type MessageConcurrency, PrepareStepContext, type PrepareStepFunction, type PrepareStepResult, type ResolvedChatRecoveryConfig, type SaveMessagesOptions, type SaveMessagesResult, Session, type SkillRunContext, type SkillSource, StepConfig, StepContext, type StepResult, type StopCondition, StreamCallback, StreamableResult, SubmitMessagesOptions, SubmitMessagesResult, type TextStreamPart, Think, ThinkIntervalSchedule, ThinkScheduledTask, ThinkScheduledTaskContext, ThinkScheduledTaskSchedule, ThinkScheduledTasks, ThinkSubmissionInspection, ThinkSubmissionStatus, ThinkTime, ThinkWallClockSchedule, ToolCallContext, ToolCallDecision, ToolCallResultContext, TurnConfig, TurnContext, TurnInput, type TypedToolCall, type TypedToolResult, Workspace, type WorkspaceLike, defaultContextOverflowClassifier, defineScheduledTasks, skills };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
//#region src/framework/types-codegen.ts
|
|
3
|
+
const THINK_TYPES_BEGIN = "// <think-generated>";
|
|
4
|
+
const THINK_TYPES_END = "// </think-generated>";
|
|
5
|
+
const GENERATED_FILE_HEADER = ["// Generated by `think types`. Do not edit this file directly.", "// Re-run `think types` after changing Think agents or Wrangler bindings."].join("\n");
|
|
6
|
+
function generateThinkTypes(manifest, options = {}) {
|
|
7
|
+
const typesFile = normalizePath(options.typesFile ?? "think.d.ts");
|
|
8
|
+
return [{
|
|
9
|
+
path: typesFile,
|
|
10
|
+
content: generateThinkEnvBlock(manifest, {
|
|
11
|
+
...options,
|
|
12
|
+
typesFile
|
|
13
|
+
})
|
|
14
|
+
}];
|
|
15
|
+
}
|
|
16
|
+
function isThinkGeneratedFile(source) {
|
|
17
|
+
return source.startsWith(GENERATED_FILE_HEADER);
|
|
18
|
+
}
|
|
19
|
+
function generateThinkEnvBlock(manifest, options) {
|
|
20
|
+
const sourceFile = options.typesFile;
|
|
21
|
+
const entryExports = manifest.agents.map((agent) => {
|
|
22
|
+
return ` export const ${agent.className}: ${agentConstructorType(agent, sourceFile, options.files)};`;
|
|
23
|
+
});
|
|
24
|
+
const bindingExports = topLevelAgents(manifest).map((agent) => {
|
|
25
|
+
return [
|
|
26
|
+
` ${agent.bindingName ?? agent.className}: DurableObjectNamespace<`,
|
|
27
|
+
` ${agentInstanceType(agent, sourceFile, options.files)}`,
|
|
28
|
+
` >;`
|
|
29
|
+
].join("\n");
|
|
30
|
+
});
|
|
31
|
+
return [
|
|
32
|
+
GENERATED_FILE_HEADER,
|
|
33
|
+
"",
|
|
34
|
+
THINK_TYPES_BEGIN,
|
|
35
|
+
`declare module "virtual:think/entry" {`,
|
|
36
|
+
` const entry: ExportedHandler<Cloudflare.Env>;`,
|
|
37
|
+
` export default entry;`,
|
|
38
|
+
...entryExports,
|
|
39
|
+
`}`,
|
|
40
|
+
``,
|
|
41
|
+
`declare module "virtual:think/router" {`,
|
|
42
|
+
` export const thinkRouter: import("@cloudflare/think/server-entry").ThinkRouter;`,
|
|
43
|
+
`}`,
|
|
44
|
+
bindingExports.length ? [
|
|
45
|
+
``,
|
|
46
|
+
`declare namespace Cloudflare {`,
|
|
47
|
+
` interface Env {`,
|
|
48
|
+
...bindingExports,
|
|
49
|
+
` }`,
|
|
50
|
+
`}`
|
|
51
|
+
].join("\n") : "",
|
|
52
|
+
THINK_TYPES_END,
|
|
53
|
+
""
|
|
54
|
+
].filter((line) => line.length > 0).join("\n") + "\n";
|
|
55
|
+
}
|
|
56
|
+
function agentConstructorType(agent, fromFile, files) {
|
|
57
|
+
const exportInfo = inferAgentExport(agent, files);
|
|
58
|
+
if (exportInfo.kind === "class") {
|
|
59
|
+
const specifier = relativeModuleSpecifier(fromFile, agent.sourcePath);
|
|
60
|
+
return `(typeof import(${JSON.stringify(specifier)}))${exportAccessor(exportInfo.exportName)}`;
|
|
61
|
+
}
|
|
62
|
+
return `typeof import("@cloudflare/think").Think<Cloudflare.Env>`;
|
|
63
|
+
}
|
|
64
|
+
function agentInstanceType(agent, fromFile, files) {
|
|
65
|
+
const exportInfo = inferAgentExport(agent, files);
|
|
66
|
+
if (exportInfo.kind === "class") {
|
|
67
|
+
const specifier = relativeModuleSpecifier(fromFile, agent.sourcePath);
|
|
68
|
+
return `InstanceType<(typeof import(${JSON.stringify(specifier)}))${exportAccessor(exportInfo.exportName)}>`;
|
|
69
|
+
}
|
|
70
|
+
return `import("@cloudflare/think").Think<Cloudflare.Env>`;
|
|
71
|
+
}
|
|
72
|
+
function inferAgentExport(agent, files) {
|
|
73
|
+
const source = files?.[agent.sourcePath];
|
|
74
|
+
if (!source) return agent.exportName ? {
|
|
75
|
+
kind: "class",
|
|
76
|
+
exportName: agent.exportName
|
|
77
|
+
} : { kind: "declarative" };
|
|
78
|
+
if (/export\s+default\s+agent\s*\(/.test(source)) return { kind: "declarative" };
|
|
79
|
+
if (/export\s+default\s+class\b/.test(source)) return {
|
|
80
|
+
kind: "class",
|
|
81
|
+
exportName: "default"
|
|
82
|
+
};
|
|
83
|
+
const namedClass = source.match(/export\s+(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/);
|
|
84
|
+
if (namedClass?.[1]) return {
|
|
85
|
+
kind: "class",
|
|
86
|
+
exportName: namedClass[1]
|
|
87
|
+
};
|
|
88
|
+
if (source.match(/export\s+const\s+([A-Za-z_$][\w$]*)\s*=\s*agent\s*\(/)) return { kind: "declarative" };
|
|
89
|
+
if (source.match(/export\s*\{\s*([A-Za-z_$][\w$]*)\s+as\s+default\s*\}/)?.[1]) return {
|
|
90
|
+
kind: "class",
|
|
91
|
+
exportName: "default"
|
|
92
|
+
};
|
|
93
|
+
return agent.exportName ? {
|
|
94
|
+
kind: "class",
|
|
95
|
+
exportName: agent.exportName
|
|
96
|
+
} : { kind: "declarative" };
|
|
97
|
+
}
|
|
98
|
+
function exportAccessor(exportName) {
|
|
99
|
+
return exportName === "default" ? ".default" : `[${JSON.stringify(exportName)}]`;
|
|
100
|
+
}
|
|
101
|
+
function topLevelAgents(manifest) {
|
|
102
|
+
return manifest.agents.filter((agent) => agent.kind === "top-level");
|
|
103
|
+
}
|
|
104
|
+
function relativeModuleSpecifier(fromFile, targetFile) {
|
|
105
|
+
const fromDirectory = dirname(fromFile);
|
|
106
|
+
const withoutExtension = stripExtension(targetFile);
|
|
107
|
+
let relative = path.posix.relative(fromDirectory, withoutExtension);
|
|
108
|
+
if (!relative.startsWith(".")) relative = `./${relative}`;
|
|
109
|
+
return relative;
|
|
110
|
+
}
|
|
111
|
+
function stripExtension(file) {
|
|
112
|
+
return file.replace(/\.(?:d\.)?(?:ts|tsx|js|mjs)$/, "");
|
|
113
|
+
}
|
|
114
|
+
function dirname(file) {
|
|
115
|
+
const normalized = normalizePath(file);
|
|
116
|
+
const directory = path.posix.dirname(normalized);
|
|
117
|
+
return directory === "." ? "." : directory;
|
|
118
|
+
}
|
|
119
|
+
function normalizePath(file) {
|
|
120
|
+
return file.replace(/\\/g, "/").replace(/^\.?\//, "");
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { isThinkGeneratedFile as n, generateThinkTypes as t };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=types-codegen-B6c5KpYH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-codegen-B6c5KpYH.js","names":[],"sources":["../src/framework/types-codegen.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { ThinkFrameworkAgent, ThinkFrameworkManifest } from \"./manifest\";\n\nexport const THINK_TYPES_BEGIN = \"// <think-generated>\";\nexport const THINK_TYPES_END = \"// </think-generated>\";\n\nconst GENERATED_FILE_HEADER = [\n \"// Generated by `think types`. Do not edit this file directly.\",\n \"// Re-run `think types` after changing Think agents or Wrangler bindings.\"\n].join(\"\\n\");\n\nexport interface ThinkTypesCodegenOptions {\n files?: Record<string, string>;\n typesFile?: string;\n}\n\nexport interface ThinkGeneratedFile {\n path: string;\n content: string;\n}\n\nexport function generateThinkTypes(\n manifest: ThinkFrameworkManifest,\n options: ThinkTypesCodegenOptions = {}\n): ThinkGeneratedFile[] {\n const typesFile = normalizePath(options.typesFile ?? \"think.d.ts\");\n return [\n {\n path: typesFile,\n content: generateThinkEnvBlock(manifest, {\n ...options,\n typesFile\n })\n }\n ];\n}\n\nexport function isThinkGeneratedFile(source: string): boolean {\n return source.startsWith(GENERATED_FILE_HEADER);\n}\n\nfunction generateThinkEnvBlock(\n manifest: ThinkFrameworkManifest,\n options: Required<Pick<ThinkTypesCodegenOptions, \"typesFile\">> &\n ThinkTypesCodegenOptions\n): string {\n const sourceFile = options.typesFile;\n const entryExports = manifest.agents.map((agent) => {\n return ` export const ${agent.className}: ${agentConstructorType(agent, sourceFile, options.files)};`;\n });\n const bindingExports = topLevelAgents(manifest).map((agent) => {\n const binding = agent.bindingName ?? agent.className;\n return [\n ` ${binding}: DurableObjectNamespace<`,\n ` ${agentInstanceType(agent, sourceFile, options.files)}`,\n ` >;`\n ].join(\"\\n\");\n });\n\n return (\n [\n GENERATED_FILE_HEADER,\n \"\",\n THINK_TYPES_BEGIN,\n `declare module \"virtual:think/entry\" {`,\n ` const entry: ExportedHandler<Cloudflare.Env>;`,\n ` export default entry;`,\n ...entryExports,\n `}`,\n ``,\n `declare module \"virtual:think/router\" {`,\n ` export const thinkRouter: import(\"@cloudflare/think/server-entry\").ThinkRouter;`,\n `}`,\n bindingExports.length\n ? [\n ``,\n `declare namespace Cloudflare {`,\n ` interface Env {`,\n ...bindingExports,\n ` }`,\n `}`\n ].join(\"\\n\")\n : \"\",\n THINK_TYPES_END,\n \"\"\n ]\n .filter((line) => line.length > 0)\n .join(\"\\n\") + \"\\n\"\n );\n}\n\nfunction agentConstructorType(\n agent: ThinkFrameworkAgent,\n fromFile: string,\n files: Record<string, string> | undefined\n): string {\n const exportInfo = inferAgentExport(agent, files);\n if (exportInfo.kind === \"class\") {\n const specifier = relativeModuleSpecifier(fromFile, agent.sourcePath);\n return `(typeof import(${JSON.stringify(specifier)}))${exportAccessor(exportInfo.exportName)}`;\n }\n return `typeof import(\"@cloudflare/think\").Think<Cloudflare.Env>`;\n}\n\nfunction agentInstanceType(\n agent: ThinkFrameworkAgent,\n fromFile: string,\n files: Record<string, string> | undefined\n): string {\n const exportInfo = inferAgentExport(agent, files);\n if (exportInfo.kind === \"class\") {\n const specifier = relativeModuleSpecifier(fromFile, agent.sourcePath);\n return `InstanceType<(typeof import(${JSON.stringify(specifier)}))${exportAccessor(exportInfo.exportName)}>`;\n }\n return `import(\"@cloudflare/think\").Think<Cloudflare.Env>`;\n}\n\nfunction inferAgentExport(\n agent: ThinkFrameworkAgent,\n files: Record<string, string> | undefined\n): { kind: \"class\"; exportName: string } | { kind: \"declarative\" } {\n const source = files?.[agent.sourcePath];\n if (!source) {\n return agent.exportName\n ? { kind: \"class\", exportName: agent.exportName }\n : { kind: \"declarative\" };\n }\n\n if (/export\\s+default\\s+agent\\s*\\(/.test(source)) {\n return { kind: \"declarative\" };\n }\n if (/export\\s+default\\s+class\\b/.test(source)) {\n return { kind: \"class\", exportName: \"default\" };\n }\n const namedClass = source.match(\n /export\\s+(?:abstract\\s+)?class\\s+([A-Za-z_$][\\w$]*)/\n );\n if (namedClass?.[1]) {\n return { kind: \"class\", exportName: namedClass[1] };\n }\n const namedDeclarative = source.match(\n /export\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*agent\\s*\\(/\n );\n if (namedDeclarative) {\n return { kind: \"declarative\" };\n }\n const reexportDefault = source.match(\n /export\\s*\\{\\s*([A-Za-z_$][\\w$]*)\\s+as\\s+default\\s*\\}/\n );\n if (reexportDefault?.[1]) {\n return { kind: \"class\", exportName: \"default\" };\n }\n\n return agent.exportName\n ? { kind: \"class\", exportName: agent.exportName }\n : { kind: \"declarative\" };\n}\n\nfunction exportAccessor(exportName: string): string {\n return exportName === \"default\"\n ? \".default\"\n : `[${JSON.stringify(exportName)}]`;\n}\n\nfunction topLevelAgents(\n manifest: ThinkFrameworkManifest\n): ThinkFrameworkAgent[] {\n return manifest.agents.filter((agent) => agent.kind === \"top-level\");\n}\n\nfunction relativeModuleSpecifier(fromFile: string, targetFile: string): string {\n const fromDirectory = dirname(fromFile);\n const withoutExtension = stripExtension(targetFile);\n let relative = path.posix.relative(fromDirectory, withoutExtension);\n if (!relative.startsWith(\".\")) relative = `./${relative}`;\n return relative;\n}\n\nfunction stripExtension(file: string): string {\n return file.replace(/\\.(?:d\\.)?(?:ts|tsx|js|mjs)$/, \"\");\n}\n\nfunction dirname(file: string): string {\n const normalized = normalizePath(file);\n const directory = path.posix.dirname(normalized);\n return directory === \".\" ? \".\" : directory;\n}\n\nfunction normalizePath(file: string): string {\n return file.replace(/\\\\/g, \"/\").replace(/^\\.?\\//, \"\");\n}\n"],"mappings":";;AAGA,MAAa,oBAAoB;AACjC,MAAa,kBAAkB;AAE/B,MAAM,wBAAwB,CAC5B,kEACA,2EACF,CAAC,CAAC,KAAK,IAAI;AAYX,SAAgB,mBACd,UACA,UAAoC,CAAC,GACf;CACtB,MAAM,YAAY,cAAc,QAAQ,aAAa,YAAY;CACjE,OAAO,CACL;EACE,MAAM;EACN,SAAS,sBAAsB,UAAU;GACvC,GAAG;GACH;EACF,CAAC;CACH,CACF;AACF;AAEA,SAAgB,qBAAqB,QAAyB;CAC5D,OAAO,OAAO,WAAW,qBAAqB;AAChD;AAEA,SAAS,sBACP,UACA,SAEQ;CACR,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,SAAS,OAAO,KAAK,UAAU;EAClD,OAAO,kBAAkB,MAAM,UAAU,IAAI,qBAAqB,OAAO,YAAY,QAA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
+
o as ThinkFrameworkManifest
|
|
5
|
+
} from "./manifest-CpB-xngB.js";
|
|
6
|
+
import { n as ThinkConfigMergeResult } from "./config-D512sQYg.js";
|
|
7
|
+
import { PluginOption } from "vite";
|
|
8
|
+
|
|
9
|
+
//#region src/vite.d.ts
|
|
10
|
+
interface ThinkVitePluginOptions extends ThinkWorkerConfigOptions {
|
|
11
|
+
files?: Record<string, string>;
|
|
12
|
+
manifest?: ThinkFrameworkManifest;
|
|
13
|
+
allowNonVirtualMain?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const THINK_EXPERIMENTAL_NOTICE: string;
|
|
16
|
+
declare function think(options?: ThinkVitePluginOptions): PluginOption[];
|
|
17
|
+
declare function createThinkViteManifest(
|
|
18
|
+
options?: ThinkVitePluginOptions,
|
|
19
|
+
root?: string
|
|
20
|
+
): Promise<ThinkFrameworkManifest>;
|
|
21
|
+
declare function createThinkViteWorkerConfig(
|
|
22
|
+
options?: ThinkVitePluginOptions,
|
|
23
|
+
root?: string
|
|
24
|
+
): Promise<ThinkWorkerConfig>;
|
|
25
|
+
declare function createThinkViteWorkerConfigResult(
|
|
26
|
+
options?: ThinkVitePluginOptions,
|
|
27
|
+
root?: string
|
|
28
|
+
): Promise<ThinkConfigMergeResult>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export {
|
|
31
|
+
THINK_EXPERIMENTAL_NOTICE,
|
|
32
|
+
ThinkVitePluginOptions,
|
|
33
|
+
createThinkViteManifest,
|
|
34
|
+
createThinkViteWorkerConfig,
|
|
35
|
+
createThinkViteWorkerConfigResult,
|
|
36
|
+
think as default,
|
|
37
|
+
think
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=vite.d.ts.map
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { a as readWranglerConfig, c as createThinkWorkerConfig, d as diagnoseThinkWorkerConfig, l as createThinkWorkerDefaults, m as summarizeThinkManifest, o as resolveThinkManifest, p as mergeThinkWorkerConfig, s as watchWranglerConfigFiles, t as applyUserBindingNames } from "./project-D1o1-3dN.js";
|
|
2
|
+
import { a as generateThinkRouterModule, i as generateThinkManifestModule, n as generateThinkConfigModule, o as generateThinkServerEntryModule, r as generateThinkEntry, t as generateThinkAgentsModule } from "./codegen-CauNNguA.js";
|
|
3
|
+
import agents from "agents/vite";
|
|
4
|
+
//#region src/framework/virtual.ts
|
|
5
|
+
function createVirtualModule(id) {
|
|
6
|
+
const resolvedId = `\0${id}`;
|
|
7
|
+
return {
|
|
8
|
+
id,
|
|
9
|
+
resolvedId,
|
|
10
|
+
matches(candidate) {
|
|
11
|
+
return candidate === resolvedId;
|
|
12
|
+
},
|
|
13
|
+
resolve(candidate) {
|
|
14
|
+
return candidate === id ? resolvedId : null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/vite.ts
|
|
20
|
+
const virtualModules = {
|
|
21
|
+
agents: createVirtualModule("virtual:think/agents"),
|
|
22
|
+
config: createVirtualModule("virtual:think/config"),
|
|
23
|
+
entry: createVirtualModule("virtual:think/entry"),
|
|
24
|
+
manifest: createVirtualModule("virtual:think/manifest"),
|
|
25
|
+
router: createVirtualModule("virtual:think/router"),
|
|
26
|
+
serverEntry: createVirtualModule("virtual:think/server-entry")
|
|
27
|
+
};
|
|
28
|
+
const THINK_EXPERIMENTAL_NOTICE = "The @cloudflare/think framework layer (Vite plugin and `think` CLI) is experimental and may change or be removed in any release.";
|
|
29
|
+
function think(options = {}) {
|
|
30
|
+
let config = null;
|
|
31
|
+
let manifest = options.manifest ?? null;
|
|
32
|
+
let warnedExperimental = false;
|
|
33
|
+
const frameworkPlugin = {
|
|
34
|
+
name: "@cloudflare/think",
|
|
35
|
+
enforce: "pre",
|
|
36
|
+
configResolved(resolved) {
|
|
37
|
+
config = resolved;
|
|
38
|
+
},
|
|
39
|
+
async buildStart() {
|
|
40
|
+
if (!warnedExperimental) {
|
|
41
|
+
warnedExperimental = true;
|
|
42
|
+
this.warn(THINK_EXPERIMENTAL_NOTICE);
|
|
43
|
+
}
|
|
44
|
+
const root = config?.root ?? process.cwd();
|
|
45
|
+
manifest = await resolveThinkManifest(options, root, (file) => this.addWatchFile(file));
|
|
46
|
+
watchWranglerConfigFiles(root, (file) => this.addWatchFile(file));
|
|
47
|
+
if (manifest.agents.length === 0) this.warn("No Think agents discovered. Add an agent file such as \"agents/support.ts\" exporting a Think subclass or \"export default agent(...)\".");
|
|
48
|
+
else this.info(["Think framework manifest:", ...summarizeThinkManifest(manifest)].join("\n"));
|
|
49
|
+
const userConfigResult = await readWranglerConfig(root);
|
|
50
|
+
if (userConfigResult.error) this.warn(userConfigResult.error);
|
|
51
|
+
if (userConfigResult.config) {
|
|
52
|
+
applyUserBindingNames(manifest, userConfigResult.config);
|
|
53
|
+
const mergeResult = mergeThinkWorkerConfig(userConfigResult.config, createThinkWorkerDefaults(manifest, options));
|
|
54
|
+
for (const diagnostic of diagnoseThinkWorkerConfig(manifest, mergeResult.config, {
|
|
55
|
+
allowNonVirtualMain: options.allowNonVirtualMain,
|
|
56
|
+
routeConfig: userConfigResult.config
|
|
57
|
+
}).concat(mergeResult.diagnostics)) reportDiagnostic(diagnostic, (message) => this.error(message), (message) => this.info(message), (message) => this.warn(message));
|
|
58
|
+
} else for (const diagnostic of diagnoseThinkWorkerConfig(manifest, createThinkWorkerDefaults(manifest, options), { allowNonVirtualMain: options.allowNonVirtualMain })) reportDiagnostic(diagnostic, (message) => this.error(message), (message) => this.info(message), (message) => this.warn(message));
|
|
59
|
+
},
|
|
60
|
+
resolveId(id) {
|
|
61
|
+
for (const virtualModule of Object.values(virtualModules)) {
|
|
62
|
+
const resolved = virtualModule.resolve(id);
|
|
63
|
+
if (resolved) return resolved;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
},
|
|
67
|
+
async load(id) {
|
|
68
|
+
const current = manifest ?? await resolveThinkManifest(options, config?.root ?? process.cwd());
|
|
69
|
+
if (virtualModules.agents.matches(id)) return generateThinkAgentsModule(current);
|
|
70
|
+
if (virtualModules.config.matches(id)) return generateThinkConfigModule(current);
|
|
71
|
+
if (virtualModules.entry.matches(id)) return generateThinkEntry(current);
|
|
72
|
+
if (virtualModules.manifest.matches(id)) return generateThinkManifestModule(current);
|
|
73
|
+
if (virtualModules.router.matches(id)) return generateThinkRouterModule(current);
|
|
74
|
+
if (virtualModules.serverEntry.matches(id)) return generateThinkServerEntryModule();
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return [...agents(), frameworkPlugin];
|
|
79
|
+
}
|
|
80
|
+
async function createThinkViteManifest(options = {}, root = process.cwd()) {
|
|
81
|
+
return resolveThinkManifest(options, root);
|
|
82
|
+
}
|
|
83
|
+
async function createThinkViteWorkerConfig(options = {}, root = process.cwd()) {
|
|
84
|
+
return (await createThinkViteWorkerConfigResult(options, root)).config;
|
|
85
|
+
}
|
|
86
|
+
async function createThinkViteWorkerConfigResult(options = {}, root = process.cwd()) {
|
|
87
|
+
const manifest = await resolveThinkManifest(options, root);
|
|
88
|
+
const userConfig = await readWranglerConfig(root);
|
|
89
|
+
if (!userConfig.config) {
|
|
90
|
+
const config = createThinkWorkerConfig(manifest, options);
|
|
91
|
+
return {
|
|
92
|
+
config,
|
|
93
|
+
diagnostics: diagnoseThinkWorkerConfig(manifest, config, { allowNonVirtualMain: options.allowNonVirtualMain })
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
applyUserBindingNames(manifest, userConfig.config);
|
|
97
|
+
const result = mergeThinkWorkerConfig(userConfig.config, createThinkWorkerDefaults(manifest, options));
|
|
98
|
+
return {
|
|
99
|
+
config: result.config,
|
|
100
|
+
diagnostics: [...result.diagnostics, ...diagnoseThinkWorkerConfig(manifest, result.config, {
|
|
101
|
+
allowNonVirtualMain: options.allowNonVirtualMain,
|
|
102
|
+
routeConfig: userConfig.config
|
|
103
|
+
})]
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function reportDiagnostic(diagnostic, error, info, warn) {
|
|
107
|
+
const message = `[${diagnostic.code}] ${diagnostic.message}`;
|
|
108
|
+
if (diagnostic.severity === "error") {
|
|
109
|
+
error(message);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (diagnostic.severity === "info") {
|
|
113
|
+
info(message);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
warn(message);
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { THINK_EXPERIMENTAL_NOTICE, createThinkViteManifest, createThinkViteWorkerConfig, createThinkViteWorkerConfigResult, think as default, think };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","names":[],"sources":["../src/framework/virtual.ts","../src/vite.ts"],"sourcesContent":["export interface ThinkVirtualModule {\n id: string;\n resolvedId: string;\n matches(id: string): boolean;\n resolve(id: string): string | null;\n}\n\nexport function createVirtualModule(\n id: `virtual:think/${string}`\n): ThinkVirtualModule {\n const resolvedId = `\\0${id}`;\n return {\n id,\n resolvedId,\n matches(candidate) {\n return candidate === resolvedId;\n },\n resolve(candidate) {\n return candidate === id ? resolvedId : null;\n }\n };\n}\n","import agents from \"agents/vite\";\nimport type { Plugin, PluginOption, ResolvedConfig } from \"vite\";\nimport {\n createThinkWorkerConfig,\n diagnoseThinkWorkerConfig,\n mergeThinkWorkerConfig,\n createThinkWorkerDefaults,\n summarizeThinkManifest,\n type ThinkConfigMergeResult,\n type ThinkWorkerConfigDiagnostic\n} from \"./framework/config\";\nimport {\n generateThinkAgentsModule,\n generateThinkConfigModule,\n generateThinkEntry,\n generateThinkManifestModule,\n generateThinkRouterModule,\n generateThinkServerEntryModule\n} from \"./framework/codegen\";\nimport { createVirtualModule } from \"./framework/virtual\";\nimport type {\n ThinkFrameworkManifest,\n ThinkWorkerConfig,\n ThinkWorkerConfigOptions\n} from \"./framework/manifest\";\nimport {\n applyUserBindingNames,\n readWranglerConfig,\n resolveThinkManifest,\n watchWranglerConfigFiles\n} from \"./framework/project\";\n\nexport interface ThinkVitePluginOptions extends ThinkWorkerConfigOptions {\n files?: Record<string, string>;\n manifest?: ThinkFrameworkManifest;\n allowNonVirtualMain?: boolean;\n}\n\nconst virtualModules = {\n agents: createVirtualModule(\"virtual:think/agents\"),\n config: createVirtualModule(\"virtual:think/config\"),\n entry: createVirtualModule(\"virtual:think/entry\"),\n manifest: createVirtualModule(\"virtual:think/manifest\"),\n router: createVirtualModule(\"virtual:think/router\"),\n serverEntry: createVirtualModule(\"virtual:think/server-entry\")\n};\n\nexport const THINK_EXPERIMENTAL_NOTICE =\n \"The @cloudflare/think framework layer (Vite plugin and `think` CLI) is \" +\n \"experimental and may change or be removed in any release.\";\n\nexport function think(options: ThinkVitePluginOptions = {}): PluginOption[] {\n let config: ResolvedConfig | null = null;\n let manifest: ThinkFrameworkManifest | null = options.manifest ?? null;\n let warnedExperimental = false;\n\n const frameworkPlugin: Plugin = {\n name: \"@cloudflare/think\",\n enforce: \"pre\",\n configResolved(resolved) {\n config = resolved;\n },\n async buildStart() {\n if (!warnedExperimental) {\n warnedExperimental = true;\n this.warn(THINK_EXPERIMENTAL_NOTICE);\n }\n const root = config?.root ?? process.cwd();\n manifest = await resolveThinkManifest(options, root, (file) =>\n this.addWatchFile(file)\n );\n watchWranglerConfigFiles(root, (file) => this.addWatchFile(file));\n if (manifest.agents.length === 0) {\n this.warn(\n 'No Think agents discovered. Add an agent file such as \"agents/support.ts\" exporting a Think subclass or \"export default agent(...)\".'\n );\n } else {\n this.info(\n [\n \"Think framework manifest:\",\n ...summarizeThinkManifest(manifest)\n ].join(\"\\n\")\n );\n }\n const userConfigResult = await readWranglerConfig(root);\n if (userConfigResult.error) {\n this.warn(userConfigResult.error);\n }\n if (userConfigResult.config) {\n applyUserBindingNames(manifest, userConfigResult.config);\n const mergeResult = mergeThinkWorkerConfig(\n userConfigResult.config,\n createThinkWorkerDefaults(manifest, options)\n );\n for (const diagnostic of diagnoseThinkWorkerConfig(\n manifest,\n mergeResult.config,\n {\n allowNonVirtualMain: options.allowNonVirtualMain,\n routeConfig: userConfigResult.config\n }\n ).concat(mergeResult.diagnostics)) {\n reportDiagnostic(\n diagnostic,\n (message) => this.error(message),\n (message) => this.info(message),\n (message) => this.warn(message)\n );\n }\n } else {\n for (const diagnostic of diagnoseThinkWorkerConfig(\n manifest,\n createThinkWorkerDefaults(manifest, options),\n { allowNonVirtualMain: options.allowNonVirtualMain }\n )) {\n reportDiagnostic(\n diagnostic,\n (message) => this.error(message),\n (message) => this.info(message),\n (message) => this.warn(message)\n );\n }\n }\n },\n resolveId(id) {\n for (const virtualModule of Object.values(virtualModules)) {\n const resolved = virtualModule.resolve(id);\n if (resolved) return resolved;\n }\n return null;\n },\n async load(id) {\n const current =\n manifest ??\n (await resolveThinkManifest(options, config?.root ?? process.cwd()));\n if (virtualModules.agents.matches(id)) {\n return generateThinkAgentsModule(current);\n }\n if (virtualModules.config.matches(id)) {\n return generateThinkConfigModule(current);\n }\n if (virtualModules.entry.matches(id)) {\n return generateThinkEntry(current);\n }\n if (virtualModules.manifest.matches(id)) {\n return generateThinkManifestModule(current);\n }\n if (virtualModules.router.matches(id)) {\n return generateThinkRouterModule(current);\n }\n if (virtualModules.serverEntry.matches(id)) {\n return generateThinkServerEntryModule();\n }\n return null;\n }\n };\n\n return [...agents(), frameworkPlugin];\n}\n\nexport default think;\n\nexport async function createThinkViteManifest(\n options: ThinkVitePluginOptions = {},\n root = process.cwd()\n): Promise<ThinkFrameworkManifest> {\n return resolveThinkManifest(options, root);\n}\n\nexport async function createThinkViteWorkerConfig(\n options: ThinkVitePluginOptions = {},\n root = process.cwd()\n): Promise<ThinkWorkerConfig> {\n return (await createThinkViteWorkerConfigResult(options, root)).config;\n}\n\nexport async function createThinkViteWorkerConfigResult(\n options: ThinkVitePluginOptions = {},\n root = process.cwd()\n): Promise<ThinkConfigMergeResult> {\n const manifest = await resolveThinkManifest(options, root);\n const userConfig = await readWranglerConfig(root);\n if (!userConfig.config) {\n const config = createThinkWorkerConfig(manifest, options);\n return {\n config,\n diagnostics: diagnoseThinkWorkerConfig(manifest, config, {\n allowNonVirtualMain: options.allowNonVirtualMain\n })\n };\n }\n applyUserBindingNames(manifest, userConfig.config);\n const result = mergeThinkWorkerConfig(\n userConfig.config,\n createThinkWorkerDefaults(manifest, options)\n );\n return {\n config: result.config,\n diagnostics: [\n ...result.diagnostics,\n ...diagnoseThinkWorkerConfig(manifest, result.config, {\n allowNonVirtualMain: options.allowNonVirtualMain,\n routeConfig: userConfig.config\n })\n ]\n };\n}\n\nfunction reportDiagnostic(\n diagnostic: ThinkWorkerConfigDiagnostic,\n error: (message: string) => void,\n info: (message: string) => void,\n warn: (message: string) => void\n): void {\n const message = `[${diagnostic.code}] ${diagnostic.message}`;\n if (diagnostic.severity === \"error\") {\n error(message);\n return;\n }\n if (diagnostic.severity === \"info\") {\n info(message);\n return;\n }\n warn(message);\n}\n"],"mappings":";;;;AAOA,SAAgB,oBACd,IACoB;CACpB,MAAM,aAAa,KAAK;CACxB,OAAO;EACL;EACA;EACA,QAAQ,WAAW;GACjB,OAAO,cAAc;EACvB;EACA,QAAQ,WAAW;GACjB,OAAO,cAAc,KAAK,aAAa;EACzC;CACF;AACF;;;ACiBA,MAAM,iBAAiB;CACrB,QAAQ,oBAAoB,sBAAsB;CAClD,QAAQ,oBAAoB,sBAAsB;CAClD,OAAO,oBAAoB,qBAAqB;CAChD,UAAU,oBAAoB,wBAAwB;CACtD,QAAQ,oBAAoB,sBAAsB;CAClD,aAAa,oBAAoB,4BAA4B;AAC/D;AAEA,MAAa,4BACX;AAGF,SAAgB,MAAM,UAAkC,CAAC,GAAmB;CAC1E,IAAI,SAAgC;CACpC,IAAI,WAA0C,QAAQ,YAAY;CAClE,IAAI,qBAAqB;CAEzB,MAAM,kBAA0B;EAC9B,MAAM;EACN,SAAS;EACT,e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O;EACf,aAAa,CACX,GAAG,OAAO,aACV,GAAG,0BAA0B,UAAU,OAAO,QAAQ;GACpD,qBAAqB,QAAQ;GAC7B,aAAa,WAAW;EAC1B,CAAC,CACH;CACF;AACF;AAEA,SAAS,iBACP,YACA,OACA,MACA,MACM;CACN,MAAM,UAAU,IAAI,WAAW,KAAK,IAAI,WAAW;CACnD,IAAI,WAAW,aAAa,SAAS;EACnC,MAAM,OAAO;EACb;CACF;CACA,IAAI,WAAW,aAAa,QAAQ;EAClC,KAAK,OAAO;EACZ;CACF;CACA,KAAK,OAAO;AACd"}
|
package/dist/workflows.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as ThinkSubmissionStatus, R as Think } from "./think-8jik2oZ5.js";
|
|
2
2
|
import { ZodObject, z } from "zod";
|
|
3
3
|
import { WorkflowEvent, WorkflowSleepDuration } from "cloudflare:workers";
|
|
4
4
|
import {
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"tools"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
|
-
"version": "0.8.
|
|
12
|
+
"version": "0.8.7",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
15
15
|
"directory": "packages/think",
|
|
@@ -20,16 +20,24 @@
|
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/cloudflare/agents/issues"
|
|
22
22
|
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"think": "dist/cli/index.js"
|
|
25
|
+
},
|
|
23
26
|
"dependencies": {
|
|
24
27
|
"@cloudflare/codemode": "^0.3.8",
|
|
25
|
-
"@cloudflare/shell": "^0.3.
|
|
28
|
+
"@cloudflare/shell": "^0.3.9",
|
|
29
|
+
"aywson": "^0.0.16",
|
|
26
30
|
"chat": "^4.30.0",
|
|
27
|
-
"
|
|
31
|
+
"create-think": "^0.0.3",
|
|
32
|
+
"just-bash": "^3.0.1",
|
|
33
|
+
"smol-toml": "^1.6.1",
|
|
34
|
+
"yargs": "^18.0.0"
|
|
28
35
|
},
|
|
29
36
|
"devDependencies": {
|
|
30
37
|
"@ai-sdk/anthropic": "^3.0.81",
|
|
31
38
|
"@ai-sdk/openai": "^3.0.67",
|
|
32
39
|
"@chat-adapter/telegram": "^4.30.0",
|
|
40
|
+
"@types/yargs": "^17.0.35",
|
|
33
41
|
"ai": "^6.0.196",
|
|
34
42
|
"zod": "^4.4.3"
|
|
35
43
|
},
|
|
@@ -37,11 +45,15 @@
|
|
|
37
45
|
"@chat-adapter/telegram": "^4.29.0",
|
|
38
46
|
"agents": ">=0.14.0 <1.0.0",
|
|
39
47
|
"ai": "^6.0.182",
|
|
48
|
+
"vite": ">=6 <9",
|
|
40
49
|
"zod": "^4.0.0"
|
|
41
50
|
},
|
|
42
51
|
"peerDependenciesMeta": {
|
|
43
52
|
"@chat-adapter/telegram": {
|
|
44
53
|
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"vite": {
|
|
56
|
+
"optional": true
|
|
45
57
|
}
|
|
46
58
|
},
|
|
47
59
|
"exports": {
|
|
@@ -57,6 +69,14 @@
|
|
|
57
69
|
"types": "./dist/workflows.d.ts",
|
|
58
70
|
"import": "./dist/workflows.js"
|
|
59
71
|
},
|
|
72
|
+
"./framework": {
|
|
73
|
+
"types": "./dist/framework/index.d.ts",
|
|
74
|
+
"import": "./dist/framework/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./server-entry": {
|
|
77
|
+
"types": "./dist/server-entry.d.ts",
|
|
78
|
+
"import": "./dist/server-entry.js"
|
|
79
|
+
},
|
|
60
80
|
"./messengers": {
|
|
61
81
|
"types": "./dist/messengers/index.d.ts",
|
|
62
82
|
"import": "./dist/messengers/index.js"
|
|
@@ -84,6 +104,10 @@
|
|
|
84
104
|
"./tools/sandbox": {
|
|
85
105
|
"types": "./dist/tools/sandbox.d.ts",
|
|
86
106
|
"import": "./dist/tools/sandbox.js"
|
|
107
|
+
},
|
|
108
|
+
"./vite": {
|
|
109
|
+
"types": "./dist/vite.d.ts",
|
|
110
|
+
"import": "./dist/vite.js"
|
|
87
111
|
}
|
|
88
112
|
},
|
|
89
113
|
"files": [
|
|
@@ -92,8 +116,11 @@
|
|
|
92
116
|
],
|
|
93
117
|
"scripts": {
|
|
94
118
|
"build": "tsx ./scripts/build.ts",
|
|
95
|
-
"test": "
|
|
119
|
+
"test": "npm run test:workers && npm run test:generated-entry && npm run test:vite && npm run test:cli",
|
|
120
|
+
"test:cli": "vitest --run -c src/cli-tests/vitest.config.ts",
|
|
96
121
|
"test:workers": "vitest --run -c src/tests/vitest.config.ts",
|
|
122
|
+
"test:generated-entry": "vitest --run -c src/tests/generated-entry/vitest.config.ts",
|
|
123
|
+
"test:vite": "vitest --run src/vite-tests",
|
|
97
124
|
"test:e2e": "vitest --run -c src/e2e-tests/vitest.config.ts"
|
|
98
125
|
}
|
|
99
126
|
}
|