@struktoai/mirage-browser 0.0.1-alpha.1
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 +230 -0
- package/dist/box-Y2SJWAAO.js +8 -0
- package/dist/box-Y2SJWAAO.js.map +1 -0
- package/dist/chunk-27UVUTJH.js +126 -0
- package/dist/chunk-27UVUTJH.js.map +1 -0
- package/dist/chunk-33SBWNB4.js +103 -0
- package/dist/chunk-33SBWNB4.js.map +1 -0
- package/dist/chunk-3PWPFOPS.js +88 -0
- package/dist/chunk-3PWPFOPS.js.map +1 -0
- package/dist/chunk-5Q5GJUAF.js +88 -0
- package/dist/chunk-5Q5GJUAF.js.map +1 -0
- package/dist/chunk-7GZXXXAS.js +24 -0
- package/dist/chunk-7GZXXXAS.js.map +1 -0
- package/dist/chunk-B4SYG2FD.js +24 -0
- package/dist/chunk-B4SYG2FD.js.map +1 -0
- package/dist/chunk-BIZONEJC.js +24 -0
- package/dist/chunk-BIZONEJC.js.map +1 -0
- package/dist/chunk-CQJTW45B.js +92 -0
- package/dist/chunk-CQJTW45B.js.map +1 -0
- package/dist/chunk-CZOTICOC.js +93 -0
- package/dist/chunk-CZOTICOC.js.map +1 -0
- package/dist/chunk-DDM2Z7YA.js +94 -0
- package/dist/chunk-DDM2Z7YA.js.map +1 -0
- package/dist/chunk-DPC7QRYO.js +99 -0
- package/dist/chunk-DPC7QRYO.js.map +1 -0
- package/dist/chunk-FL7YLP7D.js +107 -0
- package/dist/chunk-FL7YLP7D.js.map +1 -0
- package/dist/chunk-GFWWDQUZ.js +24 -0
- package/dist/chunk-GFWWDQUZ.js.map +1 -0
- package/dist/chunk-LG6GVNOL.js +94 -0
- package/dist/chunk-LG6GVNOL.js.map +1 -0
- package/dist/chunk-LSSB3AEW.js +94 -0
- package/dist/chunk-LSSB3AEW.js.map +1 -0
- package/dist/chunk-LUDXUYIA.js +89 -0
- package/dist/chunk-LUDXUYIA.js.map +1 -0
- package/dist/chunk-LZRPA2P7.js +99 -0
- package/dist/chunk-LZRPA2P7.js.map +1 -0
- package/dist/chunk-ML57VOCK.js +7590 -0
- package/dist/chunk-ML57VOCK.js.map +1 -0
- package/dist/chunk-MSNVGH6T.js +92 -0
- package/dist/chunk-MSNVGH6T.js.map +1 -0
- package/dist/chunk-NBWTZXH2.js +27 -0
- package/dist/chunk-NBWTZXH2.js.map +1 -0
- package/dist/chunk-ONQ5JGPR.js +96 -0
- package/dist/chunk-ONQ5JGPR.js.map +1 -0
- package/dist/chunk-OPROOV6J.js +24 -0
- package/dist/chunk-OPROOV6J.js.map +1 -0
- package/dist/chunk-QARIHW3I.js +23 -0
- package/dist/chunk-QARIHW3I.js.map +1 -0
- package/dist/chunk-QYFCHCGX.js +144 -0
- package/dist/chunk-QYFCHCGX.js.map +1 -0
- package/dist/chunk-SQQI4A6Y.js +94 -0
- package/dist/chunk-SQQI4A6Y.js.map +1 -0
- package/dist/chunk-UFXEZ56G.js +79 -0
- package/dist/chunk-UFXEZ56G.js.map +1 -0
- package/dist/chunk-UW3D2AF6.js +94 -0
- package/dist/chunk-UW3D2AF6.js.map +1 -0
- package/dist/chunk-UZWJ462U.js +93 -0
- package/dist/chunk-UZWJ462U.js.map +1 -0
- package/dist/chunk-VLFE4FGD.js +178 -0
- package/dist/chunk-VLFE4FGD.js.map +1 -0
- package/dist/chunk-XIURBEVZ.js +24 -0
- package/dist/chunk-XIURBEVZ.js.map +1 -0
- package/dist/chunk-ZJ6ROCTP.js +114 -0
- package/dist/chunk-ZJ6ROCTP.js.map +1 -0
- package/dist/config-4FABMWVK.js +9 -0
- package/dist/config-4FABMWVK.js.map +1 -0
- package/dist/config-DGIUMGBB.js +9 -0
- package/dist/config-DGIUMGBB.js.map +1 -0
- package/dist/config-G3TTNXLY.js +9 -0
- package/dist/config-G3TTNXLY.js.map +1 -0
- package/dist/config-GPCEEKCB.js +9 -0
- package/dist/config-GPCEEKCB.js.map +1 -0
- package/dist/config-KQ5VR2KZ.js +9 -0
- package/dist/config-KQ5VR2KZ.js.map +1 -0
- package/dist/config-LPMMVXLS.js +9 -0
- package/dist/config-LPMMVXLS.js.map +1 -0
- package/dist/config-U4UI4OKA.js +9 -0
- package/dist/config-U4UI4OKA.js.map +1 -0
- package/dist/config-VZGK63Z5.js +9 -0
- package/dist/config-VZGK63Z5.js.map +1 -0
- package/dist/discord-RG6URXXS.js +7 -0
- package/dist/discord-RG6URXXS.js.map +1 -0
- package/dist/dropbox-P7SOL7GN.js +8 -0
- package/dist/dropbox-P7SOL7GN.js.map +1 -0
- package/dist/gcs-2QHB4CBT.js +8 -0
- package/dist/gcs-2QHB4CBT.js.map +1 -0
- package/dist/gdocs-JNZTOZ33.js +8 -0
- package/dist/gdocs-JNZTOZ33.js.map +1 -0
- package/dist/gdrive-6MEIVN2F.js +8 -0
- package/dist/gdrive-6MEIVN2F.js.map +1 -0
- package/dist/github-M7WODJR2.js +7 -0
- package/dist/github-M7WODJR2.js.map +1 -0
- package/dist/github_ci-4XELEFSZ.js +8 -0
- package/dist/github_ci-4XELEFSZ.js.map +1 -0
- package/dist/gmail-AO6A3URH.js +8 -0
- package/dist/gmail-AO6A3URH.js.map +1 -0
- package/dist/gsheets-RFOKXMOJ.js +8 -0
- package/dist/gsheets-RFOKXMOJ.js.map +1 -0
- package/dist/gslides-GTVZPLLB.js +8 -0
- package/dist/gslides-GTVZPLLB.js.map +1 -0
- package/dist/index.d.ts +1127 -0
- package/dist/index.js +743 -0
- package/dist/index.js.map +1 -0
- package/dist/langfuse-CDOLELMB.js +7 -0
- package/dist/langfuse-CDOLELMB.js.map +1 -0
- package/dist/linear-SXOQGG6B.js +7 -0
- package/dist/linear-SXOQGG6B.js.map +1 -0
- package/dist/mongodb-HA7FAKDJ.js +7 -0
- package/dist/mongodb-HA7FAKDJ.js.map +1 -0
- package/dist/notion-ANZNMM3L.js +7 -0
- package/dist/notion-ANZNMM3L.js.map +1 -0
- package/dist/oci-ML5ZRVZ2.js +8 -0
- package/dist/oci-ML5ZRVZ2.js.map +1 -0
- package/dist/opfs-57XFMWWE.js +7 -0
- package/dist/opfs-57XFMWWE.js.map +1 -0
- package/dist/postgres-CK4HWZSL.js +7 -0
- package/dist/postgres-CK4HWZSL.js.map +1 -0
- package/dist/r2-56O4Q2J4.js +8 -0
- package/dist/r2-56O4Q2J4.js.map +1 -0
- package/dist/s3-A4XFE6QV.js +9 -0
- package/dist/s3-A4XFE6QV.js.map +1 -0
- package/dist/slack-QA7H7WLM.js +7 -0
- package/dist/slack-QA7H7WLM.js.map +1 -0
- package/dist/supabase-NNK2RWG3.js +8 -0
- package/dist/supabase-NNK2RWG3.js.map +1 -0
- package/dist/trello-H6PZT2IT.js +7 -0
- package/dist/trello-H6PZT2IT.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
S3Resource
|
|
3
|
+
} from "./chunk-VLFE4FGD.js";
|
|
4
|
+
|
|
5
|
+
// src/resource/gcs/gcs.ts
|
|
6
|
+
import { ResourceName } from "@struktoai/mirage-core";
|
|
7
|
+
|
|
8
|
+
// src/resource/gcs/config.ts
|
|
9
|
+
function gcsToS3Config(config) {
|
|
10
|
+
return {
|
|
11
|
+
bucket: config.bucket,
|
|
12
|
+
presignedUrlProvider: config.presignedUrlProvider,
|
|
13
|
+
...config.region !== void 0 ? { region: config.region } : { region: "auto" },
|
|
14
|
+
...config.endpoint !== void 0 ? { endpoint: config.endpoint } : { endpoint: "https://storage.googleapis.com" },
|
|
15
|
+
...config.defaultContentType !== void 0 ? { defaultContentType: config.defaultContentType } : {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function redactGcsConfig(config) {
|
|
19
|
+
return { ...config, presignedUrlProvider: "<REDACTED>" };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/resource/gcs/prompt.ts
|
|
23
|
+
var GCS_BROWSER_PROMPT = `{prefix}
|
|
24
|
+
Remote Google Cloud Storage bucket accessed via presigned URLs (browser runtime).
|
|
25
|
+
Supports the full filesystem command set: ls/tree/cat/grep/find/du/cp/mv/rm/etc.
|
|
26
|
+
Listing operations require the presigner to sign LIST/COPY operations in
|
|
27
|
+
addition to GET/PUT/HEAD/DELETE \u2014 see S3BrowserPresignedUrlProvider docs.`;
|
|
28
|
+
|
|
29
|
+
// src/resource/gcs/gcs.ts
|
|
30
|
+
function remapOpsResource(ops, to) {
|
|
31
|
+
return ops.map((op) => op.resource === ResourceName.S3 ? { ...op, resource: to } : op);
|
|
32
|
+
}
|
|
33
|
+
function remapCommandsResource(commands, to) {
|
|
34
|
+
return commands.map((cmd) => {
|
|
35
|
+
if (cmd.resource !== ResourceName.S3) return cmd;
|
|
36
|
+
const proto = Object.getPrototypeOf(cmd);
|
|
37
|
+
const copy = Object.assign(Object.create(proto), cmd);
|
|
38
|
+
Object.assign(copy, { resource: to });
|
|
39
|
+
return copy;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var GCSResource = class extends S3Resource {
|
|
43
|
+
kind = ResourceName.GCS;
|
|
44
|
+
prompt = GCS_BROWSER_PROMPT;
|
|
45
|
+
gcsConfig;
|
|
46
|
+
gcsOps;
|
|
47
|
+
gcsCommands;
|
|
48
|
+
constructor(config) {
|
|
49
|
+
super(gcsToS3Config(config));
|
|
50
|
+
this.gcsConfig = config;
|
|
51
|
+
this.gcsOps = remapOpsResource(super.ops(), ResourceName.GCS);
|
|
52
|
+
this.gcsCommands = remapCommandsResource(super.commands(), ResourceName.GCS);
|
|
53
|
+
}
|
|
54
|
+
ops() {
|
|
55
|
+
return this.gcsOps;
|
|
56
|
+
}
|
|
57
|
+
commands() {
|
|
58
|
+
return this.gcsCommands;
|
|
59
|
+
}
|
|
60
|
+
getState() {
|
|
61
|
+
return Promise.resolve({
|
|
62
|
+
type: this.kind,
|
|
63
|
+
needsOverride: true,
|
|
64
|
+
redactedFields: ["presignedUrlProvider"],
|
|
65
|
+
config: redactGcsConfig(this.gcsConfig)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
loadState(_state) {
|
|
69
|
+
return Promise.resolve();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
gcsToS3Config,
|
|
75
|
+
redactGcsConfig,
|
|
76
|
+
GCS_BROWSER_PROMPT,
|
|
77
|
+
GCSResource
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=chunk-UFXEZ56G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource/gcs/gcs.ts","../src/resource/gcs/config.ts","../src/resource/gcs/prompt.ts"],"sourcesContent":["// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport { ResourceName, type RegisteredCommand, type RegisteredOp } from '@struktoai/mirage-core'\nimport { S3Resource } from '../s3/s3.ts'\nimport { gcsToS3Config, redactGcsConfig, type GCSConfig, type GCSConfigRedacted } from './config.ts'\nimport { GCS_BROWSER_PROMPT } from './prompt.ts'\n\nexport interface GCSResourceState {\n type: string\n needsOverride: boolean\n redactedFields: readonly string[]\n config: GCSConfigRedacted\n}\n\nfunction remapOpsResource(ops: readonly RegisteredOp[], to: string): RegisteredOp[] {\n return ops.map((op) => (op.resource === ResourceName.S3 ? { ...op, resource: to } : op))\n}\n\nfunction remapCommandsResource(\n commands: readonly RegisteredCommand[],\n to: string,\n): RegisteredCommand[] {\n return commands.map((cmd) => {\n if (cmd.resource !== ResourceName.S3) return cmd\n const proto = Object.getPrototypeOf(cmd) as object\n const copy = Object.assign(Object.create(proto) as RegisteredCommand, cmd)\n Object.assign(copy, { resource: to })\n return copy\n })\n}\n\nexport class GCSResource extends S3Resource {\n override readonly kind: string = ResourceName.GCS\n override readonly prompt: string = GCS_BROWSER_PROMPT\n readonly gcsConfig: GCSConfig\n private readonly gcsOps: readonly RegisteredOp[]\n private readonly gcsCommands: readonly RegisteredCommand[]\n\n constructor(config: GCSConfig) {\n super(gcsToS3Config(config))\n this.gcsConfig = config\n this.gcsOps = remapOpsResource(super.ops(), ResourceName.GCS)\n this.gcsCommands = remapCommandsResource(super.commands(), ResourceName.GCS)\n }\n\n override ops(): readonly RegisteredOp[] {\n return this.gcsOps\n }\n\n override commands(): readonly RegisteredCommand[] {\n return this.gcsCommands\n }\n\n override getState(): Promise<GCSResourceState> {\n return Promise.resolve({\n type: this.kind,\n needsOverride: true,\n redactedFields: ['presignedUrlProvider'],\n config: redactGcsConfig(this.gcsConfig),\n })\n }\n\n override loadState(_state: GCSResourceState): Promise<void> {\n return Promise.resolve()\n }\n}\n","// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport type { S3BrowserPresignedUrlProvider, S3Config } from '../s3/config.ts'\n\nexport interface GCSConfig {\n bucket: string\n presignedUrlProvider: S3BrowserPresignedUrlProvider\n region?: string\n endpoint?: string\n defaultContentType?: string\n}\n\nexport interface GCSConfigRedacted extends Omit<GCSConfig, 'presignedUrlProvider'> {\n presignedUrlProvider: '<REDACTED>'\n}\n\nexport function gcsToS3Config(config: GCSConfig): S3Config {\n return {\n bucket: config.bucket,\n presignedUrlProvider: config.presignedUrlProvider,\n ...(config.region !== undefined ? { region: config.region } : { region: 'auto' }),\n ...(config.endpoint !== undefined\n ? { endpoint: config.endpoint }\n : { endpoint: 'https://storage.googleapis.com' }),\n ...(config.defaultContentType !== undefined\n ? { defaultContentType: config.defaultContentType }\n : {}),\n }\n}\n\nexport function redactGcsConfig(config: GCSConfig): GCSConfigRedacted {\n return { ...config, presignedUrlProvider: '<REDACTED>' }\n}\n","// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nexport const GCS_BROWSER_PROMPT = `{prefix}\n Remote Google Cloud Storage bucket accessed via presigned URLs (browser runtime).\n Supports the full filesystem command set: ls/tree/cat/grep/find/du/cp/mv/rm/etc.\n Listing operations require the presigner to sign LIST/COPY operations in\n addition to GET/PUT/HEAD/DELETE — see S3BrowserPresignedUrlProvider docs.`\n"],"mappings":";;;;;AAcA,SAAS,oBAA+D;;;ACcjE,SAAS,cAAc,QAA6B;AACzD,SAAO;AAAA,IACL,QAAQ,OAAO;AAAA,IACf,sBAAsB,OAAO;AAAA,IAC7B,GAAI,OAAO,WAAW,SAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,EAAE,QAAQ,OAAO;AAAA,IAC/E,GAAI,OAAO,aAAa,SACpB,EAAE,UAAU,OAAO,SAAS,IAC5B,EAAE,UAAU,iCAAiC;AAAA,IACjD,GAAI,OAAO,uBAAuB,SAC9B,EAAE,oBAAoB,OAAO,mBAAmB,IAChD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,QAAQ;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
redactGDocsConfig
|
|
3
|
+
} from "./chunk-GFWWDQUZ.js";
|
|
4
|
+
|
|
5
|
+
// src/resource/gdocs/gdocs.ts
|
|
6
|
+
import {
|
|
7
|
+
GDOCS_COMMANDS,
|
|
8
|
+
GDOCS_PROMPT,
|
|
9
|
+
GDOCS_VFS_OPS,
|
|
10
|
+
GDOCS_WRITE_PROMPT,
|
|
11
|
+
GDocsAccessor,
|
|
12
|
+
PathSpec,
|
|
13
|
+
RAMIndexCacheStore,
|
|
14
|
+
ResourceName,
|
|
15
|
+
TokenManager,
|
|
16
|
+
gdocsRead,
|
|
17
|
+
gdocsReaddir,
|
|
18
|
+
gdocsResolveGlob,
|
|
19
|
+
gdocsStat
|
|
20
|
+
} from "@struktoai/mirage-core";
|
|
21
|
+
var GDocsResource = class {
|
|
22
|
+
kind = ResourceName.GDOCS;
|
|
23
|
+
isRemote = true;
|
|
24
|
+
indexTtl = 86400;
|
|
25
|
+
prompt = GDOCS_PROMPT;
|
|
26
|
+
writePrompt = GDOCS_WRITE_PROMPT;
|
|
27
|
+
config;
|
|
28
|
+
accessor;
|
|
29
|
+
index;
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
const tm = new TokenManager({
|
|
33
|
+
clientId: config.clientId,
|
|
34
|
+
...config.clientSecret !== void 0 ? { clientSecret: config.clientSecret } : {},
|
|
35
|
+
refreshToken: config.refreshToken,
|
|
36
|
+
...config.refreshFn !== void 0 ? { refreshFn: config.refreshFn } : {}
|
|
37
|
+
});
|
|
38
|
+
this.accessor = new GDocsAccessor({ tokenManager: tm });
|
|
39
|
+
this.index = new RAMIndexCacheStore({ ttl: 86400 });
|
|
40
|
+
}
|
|
41
|
+
open() {
|
|
42
|
+
return Promise.resolve();
|
|
43
|
+
}
|
|
44
|
+
close() {
|
|
45
|
+
return Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
commands() {
|
|
48
|
+
return GDOCS_COMMANDS;
|
|
49
|
+
}
|
|
50
|
+
ops() {
|
|
51
|
+
return GDOCS_VFS_OPS;
|
|
52
|
+
}
|
|
53
|
+
readFile(p) {
|
|
54
|
+
return gdocsRead(this.accessor, p, this.index);
|
|
55
|
+
}
|
|
56
|
+
readdir(p) {
|
|
57
|
+
return gdocsReaddir(this.accessor, p, this.index);
|
|
58
|
+
}
|
|
59
|
+
stat(p) {
|
|
60
|
+
return gdocsStat(this.accessor, p, this.index);
|
|
61
|
+
}
|
|
62
|
+
async fingerprint(p) {
|
|
63
|
+
const lookup = await this.index.get(p.original);
|
|
64
|
+
return lookup.entry?.remoteTime ?? null;
|
|
65
|
+
}
|
|
66
|
+
glob(paths, prefix = "") {
|
|
67
|
+
const effective = prefix !== "" ? paths.map(
|
|
68
|
+
(p) => p.prefix !== "" ? p : new PathSpec({
|
|
69
|
+
original: p.original,
|
|
70
|
+
directory: p.directory,
|
|
71
|
+
...p.pattern !== null ? { pattern: p.pattern } : {},
|
|
72
|
+
resolved: p.resolved,
|
|
73
|
+
prefix
|
|
74
|
+
})
|
|
75
|
+
) : paths;
|
|
76
|
+
return gdocsResolveGlob(this.accessor, effective, this.index);
|
|
77
|
+
}
|
|
78
|
+
getState() {
|
|
79
|
+
return Promise.resolve({
|
|
80
|
+
type: this.kind,
|
|
81
|
+
needsOverride: true,
|
|
82
|
+
redactedFields: ["clientSecret", "refreshToken"],
|
|
83
|
+
config: redactGDocsConfig(this.config)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
loadState(_state) {
|
|
87
|
+
return Promise.resolve();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
GDocsResource
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-UW3D2AF6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource/gdocs/gdocs.ts"],"sourcesContent":["// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport {\n type FileStat,\n GDOCS_COMMANDS,\n GDOCS_PROMPT,\n GDOCS_VFS_OPS,\n GDOCS_WRITE_PROMPT,\n GDocsAccessor,\n type IndexCacheStore,\n PathSpec,\n RAMIndexCacheStore,\n type RegisteredCommand,\n type RegisteredOp,\n type Resource,\n ResourceName,\n TokenManager,\n gdocsRead,\n gdocsReaddir,\n gdocsResolveGlob,\n gdocsStat,\n} from '@struktoai/mirage-core'\nimport { redactGDocsConfig, type GDocsConfig, type GDocsConfigRedacted } from './config.ts'\n\nexport interface GDocsResourceState {\n type: string\n needsOverride: boolean\n redactedFields: readonly string[]\n config: GDocsConfigRedacted\n}\n\nexport class GDocsResource implements Resource {\n readonly kind: string = ResourceName.GDOCS\n readonly isRemote: boolean = true\n readonly indexTtl: number = 86_400\n readonly prompt: string = GDOCS_PROMPT\n readonly writePrompt: string = GDOCS_WRITE_PROMPT\n readonly config: GDocsConfig\n readonly accessor: GDocsAccessor\n readonly index: IndexCacheStore\n\n constructor(config: GDocsConfig) {\n this.config = config\n const tm = new TokenManager({\n clientId: config.clientId,\n ...(config.clientSecret !== undefined ? { clientSecret: config.clientSecret } : {}),\n refreshToken: config.refreshToken,\n ...(config.refreshFn !== undefined ? { refreshFn: config.refreshFn } : {}),\n })\n this.accessor = new GDocsAccessor({ tokenManager: tm })\n this.index = new RAMIndexCacheStore({ ttl: 86_400 })\n }\n\n open(): Promise<void> {\n return Promise.resolve()\n }\n\n close(): Promise<void> {\n return Promise.resolve()\n }\n\n commands(): readonly RegisteredCommand[] {\n return GDOCS_COMMANDS\n }\n\n ops(): readonly RegisteredOp[] {\n return GDOCS_VFS_OPS\n }\n\n readFile(p: PathSpec): Promise<Uint8Array> {\n return gdocsRead(this.accessor, p, this.index)\n }\n\n readdir(p: PathSpec): Promise<string[]> {\n return gdocsReaddir(this.accessor, p, this.index)\n }\n\n stat(p: PathSpec): Promise<FileStat> {\n return gdocsStat(this.accessor, p, this.index)\n }\n\n async fingerprint(p: PathSpec): Promise<string | null> {\n const lookup = await this.index.get(p.original)\n return lookup.entry?.remoteTime ?? null\n }\n\n glob(paths: readonly PathSpec[], prefix = ''): Promise<PathSpec[]> {\n const effective =\n prefix !== ''\n ? paths.map((p) =>\n p.prefix !== ''\n ? p\n : new PathSpec({\n original: p.original,\n directory: p.directory,\n ...(p.pattern !== null ? { pattern: p.pattern } : {}),\n resolved: p.resolved,\n prefix,\n }),\n )\n : paths\n return gdocsResolveGlob(this.accessor, effective, this.index)\n }\n\n getState(): Promise<GDocsResourceState> {\n return Promise.resolve({\n type: this.kind,\n needsOverride: true,\n redactedFields: ['clientSecret', 'refreshToken'],\n config: redactGDocsConfig(this.config),\n })\n }\n\n loadState(_state: GDocsResourceState): Promise<void> {\n return Promise.resolve()\n }\n}\n"],"mappings":";;;;;AAcA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUA,IAAM,gBAAN,MAAwC;AAAA,EACpC,OAAe,aAAa;AAAA,EAC5B,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB,SAAiB;AAAA,EACjB,cAAsB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,QAAqB;AAC/B,SAAK,SAAS;AACd,UAAM,KAAK,IAA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,CAAC;AAAA,IACP,IACA;AACN,WAAO,iBAAiB,KAAK,UAAU,WAAW,KAAK,KAAK;AAAA,EAC9D;AAAA,EAEA,WAAwC;AACtC,WAAO,QAAQ,QAAQ;AAAA,MACrB,MAAM,KAAK;AAAA,MACX,eAAe;AAAA,MACf,gBAAgB,CAAC,gBAAgB,cAAc;AAAA,MAC/C,QAAQ,kBAAkB,KAAK,MAAM;AAAA,IACvC,CAAC;AAAA,EACH;AAAA,EAEA,UAAU,QAA2C;AACnD,WAAO,QAAQ,QAAQ;AAAA,EACzB;AACF;","names":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/resource/postgres/postgres.ts
|
|
2
|
+
import {
|
|
3
|
+
PathSpec,
|
|
4
|
+
POSTGRES_COMMANDS,
|
|
5
|
+
POSTGRES_OPS,
|
|
6
|
+
POSTGRES_PROMPT,
|
|
7
|
+
PostgresAccessor,
|
|
8
|
+
postgresRead,
|
|
9
|
+
postgresReaddir,
|
|
10
|
+
postgresStat,
|
|
11
|
+
RAMIndexCacheStore,
|
|
12
|
+
ResourceName,
|
|
13
|
+
resolvePostgresConfig,
|
|
14
|
+
resolvePostgresGlob
|
|
15
|
+
} from "@struktoai/mirage-core";
|
|
16
|
+
|
|
17
|
+
// src/resource/postgres/neon_driver.ts
|
|
18
|
+
import { neon } from "@neondatabase/serverless";
|
|
19
|
+
var NeonPgDriver = class {
|
|
20
|
+
sql;
|
|
21
|
+
constructor(dsn) {
|
|
22
|
+
this.sql = neon(dsn, { fullResults: true });
|
|
23
|
+
}
|
|
24
|
+
async query(text, params) {
|
|
25
|
+
const result = await this.sql.query(
|
|
26
|
+
text,
|
|
27
|
+
params
|
|
28
|
+
);
|
|
29
|
+
return { rows: result.rows, rowCount: result.rowCount ?? result.rows.length };
|
|
30
|
+
}
|
|
31
|
+
close() {
|
|
32
|
+
return Promise.resolve();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// src/resource/postgres/postgres.ts
|
|
37
|
+
var PostgresResource = class {
|
|
38
|
+
kind = ResourceName.POSTGRES;
|
|
39
|
+
isRemote = true;
|
|
40
|
+
indexTtl = 0;
|
|
41
|
+
prompt;
|
|
42
|
+
config;
|
|
43
|
+
driver;
|
|
44
|
+
accessor;
|
|
45
|
+
index;
|
|
46
|
+
constructor(options) {
|
|
47
|
+
const { config, prefix, driver } = "config" in options ? options : { config: options, prefix: void 0, driver: void 0 };
|
|
48
|
+
this.config = resolvePostgresConfig(config);
|
|
49
|
+
this.driver = driver ?? new NeonPgDriver(this.config.dsn);
|
|
50
|
+
this.accessor = new PostgresAccessor(this.driver, this.config);
|
|
51
|
+
this.index = new RAMIndexCacheStore({ ttl: this.indexTtl });
|
|
52
|
+
this.prompt = POSTGRES_PROMPT.replace("{prefix}", prefix ?? "");
|
|
53
|
+
}
|
|
54
|
+
open() {
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
async close() {
|
|
58
|
+
await this.driver.close();
|
|
59
|
+
}
|
|
60
|
+
ops() {
|
|
61
|
+
return POSTGRES_OPS;
|
|
62
|
+
}
|
|
63
|
+
commands() {
|
|
64
|
+
return POSTGRES_COMMANDS;
|
|
65
|
+
}
|
|
66
|
+
readFile(p) {
|
|
67
|
+
return postgresRead(this.accessor, p, this.index);
|
|
68
|
+
}
|
|
69
|
+
readdir(p) {
|
|
70
|
+
return postgresReaddir(this.accessor, p, this.index);
|
|
71
|
+
}
|
|
72
|
+
stat(p) {
|
|
73
|
+
return postgresStat(this.accessor, p, this.index);
|
|
74
|
+
}
|
|
75
|
+
glob(paths, prefix = "") {
|
|
76
|
+
const effective = prefix !== "" ? paths.map(
|
|
77
|
+
(p) => p.prefix !== "" ? p : new PathSpec({
|
|
78
|
+
original: p.original,
|
|
79
|
+
directory: p.directory,
|
|
80
|
+
...p.pattern !== null ? { pattern: p.pattern } : {},
|
|
81
|
+
resolved: p.resolved,
|
|
82
|
+
prefix
|
|
83
|
+
})
|
|
84
|
+
) : paths;
|
|
85
|
+
return resolvePostgresGlob(this.accessor, effective, this.index);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
NeonPgDriver,
|
|
91
|
+
PostgresResource
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=chunk-UZWJ462U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource/postgres/postgres.ts","../src/resource/postgres/neon_driver.ts"],"sourcesContent":["// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport {\n type FileStat,\n type IndexCacheStore,\n PathSpec,\n type PgDriver,\n POSTGRES_COMMANDS,\n POSTGRES_OPS,\n POSTGRES_PROMPT,\n PostgresAccessor,\n type PostgresConfig,\n type PostgresConfigResolved,\n postgresRead,\n postgresReaddir,\n postgresStat,\n RAMIndexCacheStore,\n type RegisteredCommand,\n type RegisteredOp,\n type Resource,\n ResourceName,\n resolvePostgresConfig,\n resolvePostgresGlob,\n} from '@struktoai/mirage-core'\nimport { NeonPgDriver } from './neon_driver.ts'\n\nexport interface PostgresResourceOptions {\n config: PostgresConfig\n prefix?: string\n driver?: PgDriver\n}\n\nexport class PostgresResource implements Resource {\n readonly kind: string = ResourceName.POSTGRES\n readonly isRemote: boolean = true\n readonly indexTtl: number = 0\n readonly prompt: string\n readonly config: PostgresConfigResolved\n readonly driver: PgDriver\n readonly accessor: PostgresAccessor\n readonly index: IndexCacheStore\n\n constructor(options: PostgresResourceOptions | PostgresConfig) {\n const { config, prefix, driver } =\n 'config' in options ? options : { config: options, prefix: undefined, driver: undefined }\n this.config = resolvePostgresConfig(config)\n this.driver = driver ?? new NeonPgDriver(this.config.dsn)\n this.accessor = new PostgresAccessor(this.driver, this.config)\n this.index = new RAMIndexCacheStore({ ttl: this.indexTtl })\n this.prompt = POSTGRES_PROMPT.replace('{prefix}', prefix ?? '')\n }\n\n open(): Promise<void> {\n return Promise.resolve()\n }\n\n async close(): Promise<void> {\n await this.driver.close()\n }\n\n ops(): readonly RegisteredOp[] {\n return POSTGRES_OPS\n }\n\n commands(): readonly RegisteredCommand[] {\n return POSTGRES_COMMANDS\n }\n\n readFile(p: PathSpec): Promise<Uint8Array> {\n return postgresRead(this.accessor, p, this.index)\n }\n\n readdir(p: PathSpec): Promise<string[]> {\n return postgresReaddir(this.accessor, p, this.index)\n }\n\n stat(p: PathSpec): Promise<FileStat> {\n return postgresStat(this.accessor, p, this.index)\n }\n\n glob(paths: readonly PathSpec[], prefix = ''): Promise<PathSpec[]> {\n const effective =\n prefix !== ''\n ? paths.map((p) =>\n p.prefix !== ''\n ? p\n : new PathSpec({\n original: p.original,\n directory: p.directory,\n ...(p.pattern !== null ? { pattern: p.pattern } : {}),\n resolved: p.resolved,\n prefix,\n }),\n )\n : paths\n return resolvePostgresGlob(this.accessor, effective, this.index)\n }\n}\n","// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport { neon, type NeonQueryFunction } from '@neondatabase/serverless'\nimport type { PgDriver, PgQueryResult } from '@struktoai/mirage-core'\n\ninterface FullResultsRow<R> {\n rows: R[]\n rowCount: number | null\n}\n\nexport class NeonPgDriver implements PgDriver {\n private readonly sql: NeonQueryFunction<false, true>\n\n constructor(dsn: string) {\n this.sql = neon(dsn, { fullResults: true })\n }\n\n async query<R = Record<string, unknown>>(\n text: string,\n params?: readonly unknown[],\n ): Promise<PgQueryResult<R>> {\n const result = (await this.sql.query(\n text,\n params as unknown[] | undefined,\n )) as unknown as FullResultsRow<R>\n return { rows: result.rows, rowCount: result.rowCount ?? result.rows.length }\n }\n\n close(): Promise<void> {\n return Promise.resolve()\n }\n}\n"],"mappings":";AAcA;AAAA,EAGE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACrBP,SAAS,YAAoC;AAQtC,IAAM,eAAN,MAAuC;AAAA,EAC3B;AAAA,EAEjB,YAAY,KAAa;AACvB,SAAK,MAAM,KAAK,KAAK,EAAE,aAAa,KAAK,CAAC;AAAA,EAC5C;AAAA,EAEA,MAAM,MACJ,MACA,QAC2B;AAC3B,UAAM,SAAU,MAAM,KAAK,IAAI;AAAA,MAC7B;AAAA,MACA;AAAA,IACF;AACA,WAAO,EAAE,MAAM,OAAO,MAAM,UAAU,OAAO,YAAY,OAAO,KAAK,OAAO;AAAA,EAC9E;AAAA,EAEA,QAAuB;AACrB,WAAO,QAAQ,QAAQ;AAAA,EACzB;AACF;;;ADCO,IAAM,mBAAN,MAA2C;AAAA,EACvC,OAAe,aAAa;AAAA,EAC5B,WAAoB;AAAA,EACpB,WAAmB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAAmD;AAC7D,UAAM,EAAE,QAAQ,QAAQ,OAAO,IAC7B,YAAY,UAAU,UAAU,EAAE,QAAQ,SAAS,QAAQ,QAAW,QAAQ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
copy as copyCore,
|
|
4
|
+
create as createCore,
|
|
5
|
+
du as duCore,
|
|
6
|
+
duAll as duAllCore,
|
|
7
|
+
exists as existsCore,
|
|
8
|
+
find as findCore,
|
|
9
|
+
mkdir as mkdirCore,
|
|
10
|
+
PathSpec,
|
|
11
|
+
RAMIndexCacheStore,
|
|
12
|
+
rangeRead as rangeReadCore,
|
|
13
|
+
S3_COMMANDS,
|
|
14
|
+
read as readCore,
|
|
15
|
+
readdir as readdirCore,
|
|
16
|
+
rename as renameCore,
|
|
17
|
+
ResourceName,
|
|
18
|
+
resolveS3Glob as globCore,
|
|
19
|
+
rmR as rmRCore,
|
|
20
|
+
rmdir as rmdirCore,
|
|
21
|
+
S3_OPS,
|
|
22
|
+
S3Accessor,
|
|
23
|
+
stat as statCore,
|
|
24
|
+
stream as streamCore,
|
|
25
|
+
truncate as truncateCore,
|
|
26
|
+
unlink as unlinkCore,
|
|
27
|
+
write as writeCore
|
|
28
|
+
} from "@struktoai/mirage-core";
|
|
29
|
+
|
|
30
|
+
// src/resource/s3/config.ts
|
|
31
|
+
import {
|
|
32
|
+
redactS3Config
|
|
33
|
+
} from "@struktoai/mirage-core";
|
|
34
|
+
|
|
35
|
+
// src/resource/s3/s3.ts
|
|
36
|
+
var S3_BROWSER_PROMPT = `{prefix}
|
|
37
|
+
Remote S3 bucket accessed via presigned URLs (browser runtime).
|
|
38
|
+
Supports the full filesystem command set: ls/tree/cat/grep/find/du/cp/mv/rm/etc.
|
|
39
|
+
Listing operations require the presigner to sign LIST/COPY operations in
|
|
40
|
+
addition to GET/PUT/HEAD/DELETE \u2014 see S3BrowserPresignedUrlProvider docs.`;
|
|
41
|
+
var S3Resource = class {
|
|
42
|
+
kind = ResourceName.S3;
|
|
43
|
+
isRemote = true;
|
|
44
|
+
indexTtl = 600;
|
|
45
|
+
prompt = S3_BROWSER_PROMPT;
|
|
46
|
+
config;
|
|
47
|
+
accessor;
|
|
48
|
+
index;
|
|
49
|
+
constructor(config) {
|
|
50
|
+
this.config = config;
|
|
51
|
+
this.accessor = new S3Accessor(this.config);
|
|
52
|
+
this.index = new RAMIndexCacheStore({ ttl: this.indexTtl });
|
|
53
|
+
}
|
|
54
|
+
open() {
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
close() {
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
}
|
|
60
|
+
commands() {
|
|
61
|
+
return S3_COMMANDS;
|
|
62
|
+
}
|
|
63
|
+
ops() {
|
|
64
|
+
return S3_OPS;
|
|
65
|
+
}
|
|
66
|
+
streamPath(p) {
|
|
67
|
+
return streamCore(this.accessor, p);
|
|
68
|
+
}
|
|
69
|
+
readFile(p) {
|
|
70
|
+
return readCore(this.accessor, p);
|
|
71
|
+
}
|
|
72
|
+
writeFile(p, data) {
|
|
73
|
+
return writeCore(this.accessor, p, data);
|
|
74
|
+
}
|
|
75
|
+
async appendFile(p, data) {
|
|
76
|
+
let existing;
|
|
77
|
+
try {
|
|
78
|
+
existing = await readCore(this.accessor, p);
|
|
79
|
+
} catch (err) {
|
|
80
|
+
if (err?.code === "ENOENT") {
|
|
81
|
+
existing = new Uint8Array();
|
|
82
|
+
} else {
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const merged = new Uint8Array(existing.byteLength + data.byteLength);
|
|
87
|
+
merged.set(existing, 0);
|
|
88
|
+
merged.set(data, existing.byteLength);
|
|
89
|
+
await writeCore(this.accessor, p, merged);
|
|
90
|
+
}
|
|
91
|
+
readdir(p) {
|
|
92
|
+
return readdirCore(this.accessor, p, this.index);
|
|
93
|
+
}
|
|
94
|
+
stat(p) {
|
|
95
|
+
return statCore(this.accessor, p, this.index);
|
|
96
|
+
}
|
|
97
|
+
exists(p) {
|
|
98
|
+
return existsCore(this.accessor, p);
|
|
99
|
+
}
|
|
100
|
+
mkdir(p) {
|
|
101
|
+
return mkdirCore(this.accessor, p);
|
|
102
|
+
}
|
|
103
|
+
rmdir(p) {
|
|
104
|
+
return rmdirCore(this.accessor, p);
|
|
105
|
+
}
|
|
106
|
+
unlink(p) {
|
|
107
|
+
return unlinkCore(this.accessor, p);
|
|
108
|
+
}
|
|
109
|
+
rename(src, dst) {
|
|
110
|
+
return renameCore(this.accessor, src, dst);
|
|
111
|
+
}
|
|
112
|
+
truncate(p, length) {
|
|
113
|
+
return truncateCore(this.accessor, p, length);
|
|
114
|
+
}
|
|
115
|
+
copy(src, dst) {
|
|
116
|
+
return copyCore(this.accessor, src, dst);
|
|
117
|
+
}
|
|
118
|
+
rmR(p) {
|
|
119
|
+
return rmRCore(this.accessor, p);
|
|
120
|
+
}
|
|
121
|
+
du(p) {
|
|
122
|
+
return duCore(this.accessor, p);
|
|
123
|
+
}
|
|
124
|
+
find(p, options = {}) {
|
|
125
|
+
return findCore(this.accessor, p, options);
|
|
126
|
+
}
|
|
127
|
+
glob(paths, prefix = "") {
|
|
128
|
+
const effective = prefix ? paths.map(
|
|
129
|
+
(p) => p.prefix ? p : new PathSpec({
|
|
130
|
+
original: p.original,
|
|
131
|
+
directory: p.directory,
|
|
132
|
+
...p.pattern !== null ? { pattern: p.pattern } : {},
|
|
133
|
+
resolved: p.resolved,
|
|
134
|
+
prefix
|
|
135
|
+
})
|
|
136
|
+
) : paths;
|
|
137
|
+
return globCore(this.accessor, effective, this.index);
|
|
138
|
+
}
|
|
139
|
+
async fingerprint(p) {
|
|
140
|
+
try {
|
|
141
|
+
const s = await statCore(this.accessor, p, this.index);
|
|
142
|
+
const etag = s.extra.etag;
|
|
143
|
+
return typeof etag === "string" && etag !== "" ? etag : null;
|
|
144
|
+
} catch (err) {
|
|
145
|
+
if (err?.code === "ENOENT") return null;
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
getState() {
|
|
150
|
+
return Promise.resolve({
|
|
151
|
+
type: this.kind,
|
|
152
|
+
needsOverride: true,
|
|
153
|
+
redactedFields: ["presignedUrlProvider"],
|
|
154
|
+
config: redactS3Config(this.config)
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
loadState(_state) {
|
|
158
|
+
return Promise.resolve();
|
|
159
|
+
}
|
|
160
|
+
// Ignored — duAll is not yet on the public Resource interface, but keeping
|
|
161
|
+
// it around matches the node-side S3Resource.opsMap hook for completeness.
|
|
162
|
+
_duAll(p) {
|
|
163
|
+
return duAllCore(this.accessor, p);
|
|
164
|
+
}
|
|
165
|
+
_rangeRead(p, offset, size) {
|
|
166
|
+
return rangeReadCore(this.accessor, p, offset, size);
|
|
167
|
+
}
|
|
168
|
+
_create(p) {
|
|
169
|
+
return createCore(this.accessor, p);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
redactS3Config,
|
|
175
|
+
S3_BROWSER_PROMPT,
|
|
176
|
+
S3Resource
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=chunk-VLFE4FGD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource/s3/s3.ts","../src/resource/s3/config.ts"],"sourcesContent":["// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport {\n copy as copyCore,\n create as createCore,\n du as duCore,\n duAll as duAllCore,\n exists as existsCore,\n type FileStat,\n type FindOptions,\n find as findCore,\n type IndexCacheStore,\n mkdir as mkdirCore,\n PathSpec,\n RAMIndexCacheStore,\n rangeRead as rangeReadCore,\n S3_COMMANDS,\n read as readCore,\n readdir as readdirCore,\n type RegisteredCommand,\n type RegisteredOp,\n rename as renameCore,\n type Resource,\n ResourceName,\n resolveS3Glob as globCore,\n rmR as rmRCore,\n rmdir as rmdirCore,\n S3_OPS,\n S3Accessor,\n stat as statCore,\n stream as streamCore,\n truncate as truncateCore,\n unlink as unlinkCore,\n write as writeCore,\n} from '@struktoai/mirage-core'\nimport { redactConfig, type S3Config, type S3ConfigRedacted } from './config.ts'\n\nexport const S3_BROWSER_PROMPT = `{prefix}\n Remote S3 bucket accessed via presigned URLs (browser runtime).\n Supports the full filesystem command set: ls/tree/cat/grep/find/du/cp/mv/rm/etc.\n Listing operations require the presigner to sign LIST/COPY operations in\n addition to GET/PUT/HEAD/DELETE — see S3BrowserPresignedUrlProvider docs.`\n\nexport interface S3ResourceState {\n type: string\n needsOverride: boolean\n redactedFields: readonly string[]\n config: S3ConfigRedacted\n}\n\nexport class S3Resource implements Resource {\n readonly kind: string = ResourceName.S3\n readonly isRemote: boolean = true\n readonly indexTtl: number = 600\n readonly prompt: string = S3_BROWSER_PROMPT\n readonly config: S3Config\n readonly accessor: S3Accessor\n readonly index: IndexCacheStore\n\n constructor(config: S3Config) {\n this.config = config\n this.accessor = new S3Accessor(this.config)\n this.index = new RAMIndexCacheStore({ ttl: this.indexTtl })\n }\n\n open(): Promise<void> {\n return Promise.resolve()\n }\n\n close(): Promise<void> {\n return Promise.resolve()\n }\n\n commands(): readonly RegisteredCommand[] {\n return S3_COMMANDS\n }\n\n ops(): readonly RegisteredOp[] {\n return S3_OPS\n }\n\n streamPath(p: PathSpec): AsyncIterable<Uint8Array> {\n return streamCore(this.accessor, p)\n }\n\n readFile(p: PathSpec): Promise<Uint8Array> {\n return readCore(this.accessor, p)\n }\n\n writeFile(p: PathSpec, data: Uint8Array): Promise<void> {\n return writeCore(this.accessor, p, data)\n }\n\n async appendFile(p: PathSpec, data: Uint8Array): Promise<void> {\n let existing: Uint8Array\n try {\n existing = await readCore(this.accessor, p)\n } catch (err) {\n if ((err as { code?: string } | null)?.code === 'ENOENT') {\n existing = new Uint8Array()\n } else {\n throw err\n }\n }\n const merged = new Uint8Array(existing.byteLength + data.byteLength)\n merged.set(existing, 0)\n merged.set(data, existing.byteLength)\n await writeCore(this.accessor, p, merged)\n }\n\n readdir(p: PathSpec): Promise<string[]> {\n return readdirCore(this.accessor, p, this.index)\n }\n\n stat(p: PathSpec): Promise<FileStat> {\n return statCore(this.accessor, p, this.index)\n }\n\n exists(p: PathSpec): Promise<boolean> {\n return existsCore(this.accessor, p)\n }\n\n mkdir(p: PathSpec): Promise<void> {\n return mkdirCore(this.accessor, p)\n }\n\n rmdir(p: PathSpec): Promise<void> {\n return rmdirCore(this.accessor, p)\n }\n\n unlink(p: PathSpec): Promise<void> {\n return unlinkCore(this.accessor, p)\n }\n\n rename(src: PathSpec, dst: PathSpec): Promise<void> {\n return renameCore(this.accessor, src, dst)\n }\n\n truncate(p: PathSpec, length: number): Promise<void> {\n return truncateCore(this.accessor, p, length)\n }\n\n copy(src: PathSpec, dst: PathSpec): Promise<void> {\n return copyCore(this.accessor, src, dst)\n }\n\n rmR(p: PathSpec): Promise<void> {\n return rmRCore(this.accessor, p)\n }\n\n du(p: PathSpec): Promise<number> {\n return duCore(this.accessor, p)\n }\n\n find(p: PathSpec, options: FindOptions = {}): Promise<string[]> {\n return findCore(this.accessor, p, options)\n }\n\n glob(paths: readonly PathSpec[], prefix = ''): Promise<PathSpec[]> {\n const effective = prefix\n ? paths.map((p) =>\n p.prefix\n ? p\n : new PathSpec({\n original: p.original,\n directory: p.directory,\n ...(p.pattern !== null ? { pattern: p.pattern } : {}),\n resolved: p.resolved,\n prefix,\n }),\n )\n : paths\n return globCore(this.accessor, effective, this.index)\n }\n\n async fingerprint(p: PathSpec): Promise<string | null> {\n try {\n const s = await statCore(this.accessor, p, this.index)\n const etag = (s.extra as { etag?: unknown }).etag\n return typeof etag === 'string' && etag !== '' ? etag : null\n } catch (err) {\n if ((err as { code?: string } | null)?.code === 'ENOENT') return null\n throw err\n }\n }\n\n getState(): Promise<S3ResourceState> {\n return Promise.resolve({\n type: this.kind,\n needsOverride: true,\n redactedFields: ['presignedUrlProvider'],\n config: redactConfig(this.config),\n })\n }\n\n loadState(_state: S3ResourceState): Promise<void> {\n return Promise.resolve()\n }\n\n // Ignored — duAll is not yet on the public Resource interface, but keeping\n // it around matches the node-side S3Resource.opsMap hook for completeness.\n _duAll(p: PathSpec): Promise<[string, number][]> {\n return duAllCore(this.accessor, p)\n }\n\n _rangeRead(p: PathSpec, offset: number, size: number): Promise<Uint8Array> {\n return rangeReadCore(this.accessor, p, offset, size)\n }\n\n _create(p: PathSpec): Promise<void> {\n return createCore(this.accessor, p)\n }\n}\n","// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nexport {\n redactS3Config as redactConfig,\n type S3BrowserOperation,\n type S3BrowserPresignedUrlProvider,\n type S3BrowserSignOptions,\n type S3Config,\n type S3ConfigRedacted,\n} from '@struktoai/mirage-core'\n"],"mappings":";AAcA;AAAA,EACE,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EAGV,QAAQ;AAAA,EAER,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EAGX,UAAU;AAAA,EAEV;AAAA,EACA,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU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AY,OAAO,EAAE,SAAS,EAAE,QAAQ,IAAI,CAAC;AAAA,QACnD,UAAU,EAAE;AAAA,QACZ;AAAA,MACF,CAAC;AAAA,IACP,IACA;AACJ,WAAO,SAAS,KAAK,UAAU,WAAW,KAAK,KAAK;AAAA,EACtD;AAAA,EAEA,MAAM,YAAY,GAAqC;AACrD,QAAI;AACF,YAAM,IAAI,MAAM,SAAS,KAAK,UAAU,GAAG,KAAK,KAAK;AACrD,YAAM,OAAQ,EAAE,MAA6B;AAC7C,aAAO,OAAO,SAAS,YAAY,SAAS,KAAK,OAAO;AAAA,IAC1D,SAAS,KAAK;AACZ,UAAK,KAAkC,SAAS,SAAU,QAAO;AACjE,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,WAAqC;AACnC,WAAO,QAAQ,QAAQ;AAAA,MACrB,MAAM,KAAK;AAAA,MACX,eAAe;AAAA,MACf,gBAAgB,CAAC,sBAAsB;AAAA,MACvC,QAAQ,eAAa,KAAK,MAAM;AAAA,IAClC,CAAC;AAAA,EACH;AAAA,EAEA,UAAU,QAAwC;AAChD,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA;AAAA;AAAA,EAIA,OAAO,GAA0C;AAC/C,WAAO,UAAU,KAAK,UAAU,CAAC;AAAA,EACnC;AAAA,EAEA,WAAW,GAAa,QAAgB,MAAmC;AACzE,WAAO,cAAc,KAAK,UAAU,GAAG,QAAQ,IAAI;AAAA,EACrD;AAAA,EAEA,QAAQ,GAA4B;AAClC,WAAO,WAAW,KAAK,UAAU,CAAC;AAAA,EACpC;AACF;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/resource/gdrive/config.ts
|
|
2
|
+
import { normalizeFields } from "@struktoai/mirage-core";
|
|
3
|
+
function redactGDriveConfig(config) {
|
|
4
|
+
return {
|
|
5
|
+
clientId: config.clientId,
|
|
6
|
+
...config.clientSecret !== void 0 ? { clientSecret: "<REDACTED>" } : {},
|
|
7
|
+
refreshToken: "<REDACTED>"
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function normalizeGDriveConfig(input) {
|
|
11
|
+
return normalizeFields(input, {
|
|
12
|
+
rename: {
|
|
13
|
+
client_id: "clientId",
|
|
14
|
+
client_secret: "clientSecret",
|
|
15
|
+
refresh_token: "refreshToken"
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
redactGDriveConfig,
|
|
22
|
+
normalizeGDriveConfig
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=chunk-XIURBEVZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource/gdrive/config.ts"],"sourcesContent":["// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n// ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========\n\nimport { normalizeFields } from '@struktoai/mirage-core'\n\nexport interface GDriveConfig {\n clientId: string\n clientSecret?: string\n refreshToken: string\n refreshFn?: (refreshToken: string) => Promise<{ accessToken: string; expiresIn: number }>\n}\n\nexport interface GDriveConfigRedacted {\n clientId: string\n clientSecret?: '<REDACTED>'\n refreshToken: '<REDACTED>'\n}\n\nexport function redactGDriveConfig(config: GDriveConfig): GDriveConfigRedacted {\n return {\n clientId: config.clientId,\n ...(config.clientSecret !== undefined ? { clientSecret: '<REDACTED>' as const } : {}),\n refreshToken: '<REDACTED>',\n }\n}\n\nexport function normalizeGDriveConfig(input: Record<string, unknown>): GDriveConfig {\n return normalizeFields(input, {\n rename: {\n client_id: 'clientId',\n client_secret: 'clientSecret',\n refresh_token: 'refreshToken',\n },\n }) as unknown as GDriveConfig\n}\n"],"mappings":";AAcA,SAAS,uBAAuB;AAezB,SAAS,mBAAmB,QAA4C;AAC7E,SAAO;AAAA,IACL,UAAU,OAAO;AAAA,IACjB,GAAI,OAAO,iBAAiB,SAAY,EAAE,cAAc,aAAsB,IAAI,CAAC;AAAA,IACnF,cAAc;AAAA,EAChB;AACF;AAEO,SAAS,sBAAsB,OAA8C;AAClF,SAAO,gBAAgB,OAAO;AAAA,IAC5B,QAAQ;AAAA,MACN,WAAW;AAAA,MACX,eAAe;AAAA,MACf,eAAe;AAAA,IACjB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// src/resource/langfuse/langfuse.ts
|
|
2
|
+
import {
|
|
3
|
+
HttpLangfuseTransport,
|
|
4
|
+
LANGFUSE_COMMANDS,
|
|
5
|
+
LANGFUSE_PROMPT,
|
|
6
|
+
LANGFUSE_VFS_OPS,
|
|
7
|
+
LangfuseAccessor,
|
|
8
|
+
langfuseRead,
|
|
9
|
+
langfuseReaddir,
|
|
10
|
+
langfuseStat,
|
|
11
|
+
PathSpec,
|
|
12
|
+
RAMIndexCacheStore,
|
|
13
|
+
ResourceName,
|
|
14
|
+
resolveLangfuseGlob
|
|
15
|
+
} from "@struktoai/mirage-core";
|
|
16
|
+
|
|
17
|
+
// src/resource/langfuse/config.ts
|
|
18
|
+
function redactLangfuseConfig(config) {
|
|
19
|
+
const out = {
|
|
20
|
+
publicKey: config.publicKey,
|
|
21
|
+
secretKey: "<REDACTED>"
|
|
22
|
+
};
|
|
23
|
+
if (config.host !== void 0) out.host = config.host;
|
|
24
|
+
if (config.defaultTraceLimit !== void 0) out.defaultTraceLimit = config.defaultTraceLimit;
|
|
25
|
+
if (config.defaultSearchLimit !== void 0) out.defaultSearchLimit = config.defaultSearchLimit;
|
|
26
|
+
if (config.defaultFromTimestamp !== void 0) {
|
|
27
|
+
out.defaultFromTimestamp = config.defaultFromTimestamp;
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/resource/langfuse/langfuse.ts
|
|
33
|
+
var LangfuseResource = class {
|
|
34
|
+
kind = ResourceName.LANGFUSE;
|
|
35
|
+
isRemote = true;
|
|
36
|
+
indexTtl = 600;
|
|
37
|
+
prompt = LANGFUSE_PROMPT;
|
|
38
|
+
config;
|
|
39
|
+
accessor;
|
|
40
|
+
index;
|
|
41
|
+
constructor(config) {
|
|
42
|
+
this.config = config;
|
|
43
|
+
const transportOpts = {
|
|
44
|
+
publicKey: config.publicKey,
|
|
45
|
+
secretKey: config.secretKey
|
|
46
|
+
};
|
|
47
|
+
if (config.host !== void 0) transportOpts.host = config.host;
|
|
48
|
+
const accessorConfig = {};
|
|
49
|
+
if (config.defaultTraceLimit !== void 0) {
|
|
50
|
+
accessorConfig.defaultTraceLimit = config.defaultTraceLimit;
|
|
51
|
+
}
|
|
52
|
+
if (config.defaultSearchLimit !== void 0) {
|
|
53
|
+
accessorConfig.defaultSearchLimit = config.defaultSearchLimit;
|
|
54
|
+
}
|
|
55
|
+
if (config.defaultFromTimestamp !== void 0) {
|
|
56
|
+
accessorConfig.defaultFromTimestamp = config.defaultFromTimestamp;
|
|
57
|
+
}
|
|
58
|
+
this.accessor = new LangfuseAccessor(new HttpLangfuseTransport(transportOpts), accessorConfig);
|
|
59
|
+
this.index = new RAMIndexCacheStore({ ttl: this.indexTtl });
|
|
60
|
+
}
|
|
61
|
+
open() {
|
|
62
|
+
return Promise.resolve();
|
|
63
|
+
}
|
|
64
|
+
close() {
|
|
65
|
+
return Promise.resolve();
|
|
66
|
+
}
|
|
67
|
+
commands() {
|
|
68
|
+
return LANGFUSE_COMMANDS;
|
|
69
|
+
}
|
|
70
|
+
ops() {
|
|
71
|
+
return LANGFUSE_VFS_OPS;
|
|
72
|
+
}
|
|
73
|
+
readFile(p) {
|
|
74
|
+
return langfuseRead(this.accessor, p, this.index);
|
|
75
|
+
}
|
|
76
|
+
readdir(p) {
|
|
77
|
+
return langfuseReaddir(this.accessor, p, this.index);
|
|
78
|
+
}
|
|
79
|
+
stat(p) {
|
|
80
|
+
return langfuseStat(this.accessor, p, this.index);
|
|
81
|
+
}
|
|
82
|
+
fingerprint(_p) {
|
|
83
|
+
return Promise.resolve(null);
|
|
84
|
+
}
|
|
85
|
+
glob(paths, prefix = "") {
|
|
86
|
+
const effective = prefix !== "" ? paths.map(
|
|
87
|
+
(p) => p.prefix !== "" ? p : new PathSpec({
|
|
88
|
+
original: p.original,
|
|
89
|
+
directory: p.directory,
|
|
90
|
+
...p.pattern !== null ? { pattern: p.pattern } : {},
|
|
91
|
+
resolved: p.resolved,
|
|
92
|
+
prefix
|
|
93
|
+
})
|
|
94
|
+
) : paths;
|
|
95
|
+
return resolveLangfuseGlob(this.accessor, effective, this.index);
|
|
96
|
+
}
|
|
97
|
+
getState() {
|
|
98
|
+
return Promise.resolve({
|
|
99
|
+
type: this.kind,
|
|
100
|
+
needsOverride: true,
|
|
101
|
+
redactedFields: ["secretKey"],
|
|
102
|
+
config: redactLangfuseConfig(this.config)
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
loadState(_state) {
|
|
106
|
+
return Promise.resolve();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
redactLangfuseConfig,
|
|
112
|
+
LangfuseResource
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=chunk-ZJ6ROCTP.js.map
|