@getjack/jack 0.1.33 → 0.1.35
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 +6 -6
- package/package.json +1 -1
- package/src/commands/down.ts +39 -7
- package/src/commands/link.ts +2 -4
- package/src/commands/logs.ts +2 -4
- package/src/commands/mcp.ts +12 -10
- package/src/commands/secrets.ts +3 -1
- package/src/commands/services.ts +4 -2
- package/src/commands/sync.ts +5 -6
- package/src/lib/auth/client.ts +5 -2
- package/src/lib/binding-validator.ts +39 -3
- package/src/lib/build-helper.ts +18 -19
- package/src/lib/control-plane.ts +1 -0
- package/src/lib/crypto.ts +84 -0
- package/src/lib/deploy-upload.ts +7 -3
- package/src/lib/do-config.ts +110 -0
- package/src/lib/do-export-validator.ts +26 -0
- package/src/lib/hooks.ts +1 -2
- package/src/lib/jsonc-edit.ts +292 -0
- package/src/lib/managed-deploy.ts +36 -1
- package/src/lib/project-link.ts +37 -0
- package/src/lib/project-operations.ts +37 -46
- package/src/lib/prompts.ts +2 -2
- package/src/lib/resources.ts +4 -5
- package/src/lib/schema.ts +8 -12
- package/src/lib/services/db-create.ts +2 -2
- package/src/lib/services/db-execute.ts +9 -6
- package/src/lib/services/db-list.ts +6 -4
- package/src/lib/services/endpoint-test.ts +275 -0
- package/src/lib/services/project-delete.ts +190 -0
- package/src/lib/services/project-environment.ts +457 -0
- package/src/lib/services/storage-config.ts +7 -309
- package/src/lib/services/storage-create.ts +2 -1
- package/src/lib/services/storage-delete.ts +3 -2
- package/src/lib/services/storage-info.ts +2 -1
- package/src/lib/services/storage-list.ts +6 -3
- package/src/lib/services/vectorize-config.ts +7 -264
- package/src/lib/services/vectorize-create.ts +2 -1
- package/src/lib/services/vectorize-delete.ts +6 -4
- package/src/lib/services/vectorize-list.ts +6 -3
- package/src/lib/storage/index.ts +21 -23
- package/src/lib/telemetry.ts +1 -0
- package/src/lib/wrangler-config.ts +43 -312
- package/src/lib/zip-packager.ts +28 -0
- package/src/mcp/test-utils.ts +31 -0
- package/src/mcp/tools/index.ts +271 -0
- package/src/templates/index.ts +5 -0
- package/src/templates/types.ts +4 -0
- package/templates/AI-BINDINGS.md +34 -76
- package/templates/CLAUDE.md +22 -1
- package/templates/ai-chat/src/index.ts +7 -14
- package/templates/ai-chat/src/jack-ai.ts +0 -6
- package/templates/chat/.jack.json +45 -0
- package/templates/chat/bun.lock +1588 -0
- package/templates/chat/components.json +23 -0
- package/templates/chat/index.html +12 -0
- package/templates/chat/package.json +41 -0
- package/templates/chat/src/chat-agent.ts +61 -0
- package/templates/chat/src/client/app.tsx +189 -0
- package/templates/chat/src/client/chat.tsx +222 -0
- package/templates/chat/src/client/components/prompt-kit/chat-container.tsx +47 -0
- package/templates/chat/src/client/components/prompt-kit/loader.tsx +33 -0
- package/templates/chat/src/client/components/prompt-kit/markdown.tsx +84 -0
- package/templates/chat/src/client/components/prompt-kit/message.tsx +54 -0
- package/templates/chat/src/client/components/prompt-kit/prompt-suggestion.tsx +20 -0
- package/templates/chat/src/client/components/prompt-kit/reasoning.tsx +134 -0
- package/templates/chat/src/client/components/prompt-kit/scroll-button.tsx +28 -0
- package/templates/chat/src/client/components/ui/button.tsx +38 -0
- package/templates/chat/src/client/lib/utils.ts +6 -0
- package/templates/chat/src/client/main.tsx +11 -0
- package/templates/chat/src/client/styles.css +125 -0
- package/templates/chat/src/index.ts +25 -0
- package/templates/chat/src/jack-ai.ts +94 -0
- package/templates/chat/tsconfig.json +18 -0
- package/templates/chat/vite.config.ts +14 -0
- package/templates/chat/wrangler.jsonc +18 -0
- package/templates/cron/.jack.json +18 -28
- package/templates/cron/schema.sql +10 -20
- package/templates/cron/src/admin.ts +321 -0
- package/templates/cron/src/index.ts +151 -81
- package/templates/cron/src/monitor.ts +124 -0
- package/templates/nextjs-clerk/app/layout.tsx +2 -0
- package/templates/semantic-search/src/index.ts +5 -43
- package/templates/semantic-search/src/jack-ai.ts +0 -6
- package/templates/telegram-bot/.jack.json +56 -0
- package/templates/telegram-bot/bun.lock +41 -0
- package/templates/telegram-bot/package.json +16 -0
- package/templates/telegram-bot/src/index.ts +236 -0
- package/templates/telegram-bot/src/jack-ai.ts +100 -0
- package/templates/telegram-bot/tsconfig.json +11 -0
- package/templates/telegram-bot/wrangler.jsonc +8 -0
- package/templates/cron/src/jobs.ts +0 -139
- package/templates/cron/src/webhooks.ts +0 -95
- package/templates/semantic-search/src/jack-vectorize.ts +0 -169
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Jack Vectorize Client - Drop-in replacement for Cloudflare Vectorize binding.
|
|
3
|
-
*
|
|
4
|
-
* This wrapper provides the same interface as env.VECTORS but routes calls
|
|
5
|
-
* through jack's binding proxy for metering and quota enforcement.
|
|
6
|
-
*
|
|
7
|
-
* Usage in templates:
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { createJackVectorize } from "./jack-vectorize";
|
|
10
|
-
*
|
|
11
|
-
* interface Env {
|
|
12
|
-
* __VECTORIZE_PROXY: Fetcher; // Service binding to binding-proxy worker
|
|
13
|
-
* __JACK_PROJECT_ID: string; // Injected by control plane
|
|
14
|
-
* __JACK_ORG_ID: string; // Injected by control plane
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* export default {
|
|
18
|
-
* async fetch(request: Request, env: Env) {
|
|
19
|
-
* const VECTORS = createJackVectorize(env, "my-index");
|
|
20
|
-
* const results = await VECTORS.query(vector, { topK: 10 });
|
|
21
|
-
* // Works exactly like env.VECTORS.query()
|
|
22
|
-
* }
|
|
23
|
-
* };
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* The wrapper is transparent - it accepts the same parameters as the native
|
|
27
|
-
* VectorizeIndex and returns the same response types.
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
interface JackVectorizeEnv {
|
|
31
|
-
__VECTORIZE_PROXY: Fetcher;
|
|
32
|
-
__JACK_PROJECT_ID: string;
|
|
33
|
-
__JACK_ORG_ID: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface VectorizeQueryOptions {
|
|
37
|
-
topK?: number;
|
|
38
|
-
filter?: Record<string, unknown>;
|
|
39
|
-
returnValues?: boolean;
|
|
40
|
-
returnMetadata?: "none" | "indexed" | "all";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface VectorizeVector {
|
|
44
|
-
id: string;
|
|
45
|
-
values: number[];
|
|
46
|
-
metadata?: Record<string, unknown>;
|
|
47
|
-
namespace?: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
interface VectorizeMatch {
|
|
51
|
-
id: string;
|
|
52
|
-
score: number;
|
|
53
|
-
values?: number[];
|
|
54
|
-
metadata?: Record<string, unknown>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface VectorizeQueryResult {
|
|
58
|
-
matches: VectorizeMatch[];
|
|
59
|
-
count: number;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface VectorizeMutationResult {
|
|
63
|
-
mutationId: string;
|
|
64
|
-
count: number;
|
|
65
|
-
ids: string[];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
interface VectorizeIndexDetails {
|
|
69
|
-
dimensions: number;
|
|
70
|
-
metric: "cosine" | "euclidean" | "dot-product";
|
|
71
|
-
vectorCount: number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Creates a Jack Vectorize client that mirrors the Cloudflare VectorizeIndex interface.
|
|
76
|
-
*
|
|
77
|
-
* @param env - Worker environment with jack proxy bindings
|
|
78
|
-
* @param indexName - Name of the Vectorize index
|
|
79
|
-
* @returns VectorizeIndex-compatible object
|
|
80
|
-
*/
|
|
81
|
-
export function createJackVectorize(
|
|
82
|
-
env: JackVectorizeEnv,
|
|
83
|
-
indexName: string,
|
|
84
|
-
): {
|
|
85
|
-
query: (vector: number[], options?: VectorizeQueryOptions) => Promise<VectorizeQueryResult>;
|
|
86
|
-
upsert: (vectors: VectorizeVector[]) => Promise<VectorizeMutationResult>;
|
|
87
|
-
insert: (vectors: VectorizeVector[]) => Promise<VectorizeMutationResult>;
|
|
88
|
-
deleteByIds: (ids: string[]) => Promise<VectorizeMutationResult>;
|
|
89
|
-
getByIds: (ids: string[]) => Promise<VectorizeVector[]>;
|
|
90
|
-
describe: () => Promise<VectorizeIndexDetails>;
|
|
91
|
-
} {
|
|
92
|
-
async function proxyRequest<T>(operation: string, params: unknown): Promise<T> {
|
|
93
|
-
const response = await env.__VECTORIZE_PROXY.fetch("http://internal/vectorize", {
|
|
94
|
-
method: "POST",
|
|
95
|
-
headers: {
|
|
96
|
-
"Content-Type": "application/json",
|
|
97
|
-
"X-Jack-Project-ID": env.__JACK_PROJECT_ID,
|
|
98
|
-
"X-Jack-Org-ID": env.__JACK_ORG_ID,
|
|
99
|
-
},
|
|
100
|
-
body: JSON.stringify({
|
|
101
|
-
operation,
|
|
102
|
-
index_name: indexName,
|
|
103
|
-
params,
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Handle quota exceeded
|
|
108
|
-
if (response.status === 429) {
|
|
109
|
-
const error = (await response.json()) as {
|
|
110
|
-
message?: string;
|
|
111
|
-
code?: string;
|
|
112
|
-
resetIn?: number;
|
|
113
|
-
};
|
|
114
|
-
const quotaError = new Error(error.message || "Vectorize quota exceeded");
|
|
115
|
-
(quotaError as Error & { code: string }).code = error.code || "VECTORIZE_QUOTA_EXCEEDED";
|
|
116
|
-
(quotaError as Error & { resetIn?: number }).resetIn = error.resetIn;
|
|
117
|
-
throw quotaError;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Handle rate limit
|
|
121
|
-
if (response.status === 429) {
|
|
122
|
-
const error = (await response.json()) as { message?: string };
|
|
123
|
-
throw new Error(error.message || "Rate limit exceeded");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Handle other errors
|
|
127
|
-
if (!response.ok) {
|
|
128
|
-
const error = (await response.json()) as { error?: string };
|
|
129
|
-
throw new Error(error.error || `Vectorize ${operation} failed`);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return response.json() as Promise<T>;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
async query(vector: number[], options?: VectorizeQueryOptions): Promise<VectorizeQueryResult> {
|
|
137
|
-
return proxyRequest<VectorizeQueryResult>("query", {
|
|
138
|
-
vector,
|
|
139
|
-
...options,
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
async upsert(vectors: VectorizeVector[]): Promise<VectorizeMutationResult> {
|
|
144
|
-
return proxyRequest<VectorizeMutationResult>("upsert", { vectors });
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
async insert(vectors: VectorizeVector[]): Promise<VectorizeMutationResult> {
|
|
148
|
-
// insert is typically an alias for upsert in Vectorize
|
|
149
|
-
return proxyRequest<VectorizeMutationResult>("upsert", { vectors });
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
async deleteByIds(ids: string[]): Promise<VectorizeMutationResult> {
|
|
153
|
-
return proxyRequest<VectorizeMutationResult>("deleteByIds", { ids });
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
async getByIds(ids: string[]): Promise<VectorizeVector[]> {
|
|
157
|
-
return proxyRequest<VectorizeVector[]>("getByIds", { ids });
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
async describe(): Promise<VectorizeIndexDetails> {
|
|
161
|
-
return proxyRequest<VectorizeIndexDetails>("describe", {});
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Type alias for the Jack Vectorize client
|
|
168
|
-
*/
|
|
169
|
-
export type JackVectorize = ReturnType<typeof createJackVectorize>;
|