@agent-native/core 0.32.18 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/context-xray/actions/context-evict.d.ts +3 -0
- package/dist/agent/context-xray/actions/context-evict.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/context-evict.js +35 -0
- package/dist/agent/context-xray/actions/context-evict.js.map +1 -0
- package/dist/agent/context-xray/actions/context-manifest-get.d.ts +3 -0
- package/dist/agent/context-xray/actions/context-manifest-get.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/context-manifest-get.js +67 -0
- package/dist/agent/context-xray/actions/context-manifest-get.js.map +1 -0
- package/dist/agent/context-xray/actions/context-pin.d.ts +3 -0
- package/dist/agent/context-xray/actions/context-pin.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/context-pin.js +35 -0
- package/dist/agent/context-xray/actions/context-pin.js.map +1 -0
- package/dist/agent/context-xray/actions/context-report.d.ts +3 -0
- package/dist/agent/context-xray/actions/context-report.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/context-report.js +59 -0
- package/dist/agent/context-xray/actions/context-report.js.map +1 -0
- package/dist/agent/context-xray/actions/context-restore.d.ts +3 -0
- package/dist/agent/context-xray/actions/context-restore.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/context-restore.js +33 -0
- package/dist/agent/context-xray/actions/context-restore.js.map +1 -0
- package/dist/agent/context-xray/actions/errors.d.ts +7 -0
- package/dist/agent/context-xray/actions/errors.d.ts.map +1 -0
- package/dist/agent/context-xray/actions/errors.js +15 -0
- package/dist/agent/context-xray/actions/errors.js.map +1 -0
- package/dist/agent/context-xray/apply-directives.d.ts +10 -0
- package/dist/agent/context-xray/apply-directives.d.ts.map +1 -0
- package/dist/agent/context-xray/apply-directives.js +100 -0
- package/dist/agent/context-xray/apply-directives.js.map +1 -0
- package/dist/agent/context-xray/directives-store.d.ts +26 -0
- package/dist/agent/context-xray/directives-store.d.ts.map +1 -0
- package/dist/agent/context-xray/directives-store.js +131 -0
- package/dist/agent/context-xray/directives-store.js.map +1 -0
- package/dist/agent/context-xray/identity.d.ts +5 -0
- package/dist/agent/context-xray/identity.d.ts.map +1 -0
- package/dist/agent/context-xray/identity.js +33 -0
- package/dist/agent/context-xray/identity.js.map +1 -0
- package/dist/agent/context-xray/manifest.d.ts +19 -0
- package/dist/agent/context-xray/manifest.d.ts.map +1 -0
- package/dist/agent/context-xray/manifest.js +115 -0
- package/dist/agent/context-xray/manifest.js.map +1 -0
- package/dist/agent/context-xray/migrations.d.ts +3 -0
- package/dist/agent/context-xray/migrations.d.ts.map +1 -0
- package/dist/agent/context-xray/migrations.js +31 -0
- package/dist/agent/context-xray/migrations.js.map +1 -0
- package/dist/agent/context-xray/plugin.d.ts +5 -0
- package/dist/agent/context-xray/plugin.d.ts.map +1 -0
- package/dist/agent/context-xray/plugin.js +15 -0
- package/dist/agent/context-xray/plugin.js.map +1 -0
- package/dist/agent/context-xray/schema.d.ts +249 -0
- package/dist/agent/context-xray/schema.d.ts.map +1 -0
- package/dist/agent/context-xray/schema.js +17 -0
- package/dist/agent/context-xray/schema.js.map +1 -0
- package/dist/agent/context-xray/segments.d.ts +19 -0
- package/dist/agent/context-xray/segments.d.ts.map +1 -0
- package/dist/agent/context-xray/segments.js +154 -0
- package/dist/agent/context-xray/segments.js.map +1 -0
- package/dist/agent/context-xray/tokenize.d.ts +10 -0
- package/dist/agent/context-xray/tokenize.d.ts.map +1 -0
- package/dist/agent/context-xray/tokenize.js +70 -0
- package/dist/agent/context-xray/tokenize.js.map +1 -0
- package/dist/agent/production-agent.d.ts +2 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +45 -5
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/context-xray-local.d.ts +16 -0
- package/dist/cli/context-xray-local.d.ts.map +1 -0
- package/dist/cli/context-xray-local.js +738 -0
- package/dist/cli/context-xray-local.js.map +1 -0
- package/dist/cli/skills.d.ts +3 -0
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +200 -73
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/templates-meta.js +5 -5
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +2 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/components/ui/sheet.d.ts +16 -0
- package/dist/client/components/ui/sheet.d.ts.map +1 -0
- package/dist/client/components/ui/sheet.js +23 -0
- package/dist/client/components/ui/sheet.js.map +1 -0
- package/dist/client/context-xray/ContextMeter.d.ts +4 -0
- package/dist/client/context-xray/ContextMeter.d.ts.map +1 -0
- package/dist/client/context-xray/ContextMeter.js +76 -0
- package/dist/client/context-xray/ContextMeter.js.map +1 -0
- package/dist/client/context-xray/ContextSegmentRow.d.ts +9 -0
- package/dist/client/context-xray/ContextSegmentRow.d.ts.map +1 -0
- package/dist/client/context-xray/ContextSegmentRow.js +22 -0
- package/dist/client/context-xray/ContextSegmentRow.js.map +1 -0
- package/dist/client/context-xray/ContextTreemap.d.ts +6 -0
- package/dist/client/context-xray/ContextTreemap.d.ts.map +1 -0
- package/dist/client/context-xray/ContextTreemap.js +49 -0
- package/dist/client/context-xray/ContextTreemap.js.map +1 -0
- package/dist/client/context-xray/ContextXRayPanel.d.ts +11 -0
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -0
- package/dist/client/context-xray/ContextXRayPanel.js +87 -0
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -0
- package/dist/client/context-xray/SegmentProvenancePopover.d.ts +7 -0
- package/dist/client/context-xray/SegmentProvenancePopover.d.ts.map +1 -0
- package/dist/client/context-xray/SegmentProvenancePopover.js +7 -0
- package/dist/client/context-xray/SegmentProvenancePopover.js.map +1 -0
- package/dist/client/context-xray/format.d.ts +7 -0
- package/dist/client/context-xray/format.d.ts.map +1 -0
- package/dist/client/context-xray/format.js +47 -0
- package/dist/client/context-xray/format.js.map +1 -0
- package/dist/deploy/route-discovery.d.ts.map +1 -1
- package/dist/deploy/route-discovery.js +1 -0
- package/dist/deploy/route-discovery.js.map +1 -1
- package/dist/deploy/workspace-core.d.ts +1 -1
- package/dist/deploy/workspace-core.d.ts.map +1 -1
- package/dist/deploy/workspace-core.js +1 -0
- package/dist/deploy/workspace-core.js.map +1 -1
- package/dist/provider-api/index.d.ts +237 -0
- package/dist/provider-api/index.d.ts.map +1 -0
- package/dist/provider-api/index.js +1533 -0
- package/dist/provider-api/index.js.map +1 -0
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +20 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +2 -0
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -0
- package/dist/server/index.js.map +1 -1
- package/dist/shared/context-xray.d.ts +58 -0
- package/dist/shared/context-xray.d.ts.map +1 -0
- package/dist/shared/context-xray.js +17 -0
- package/dist/shared/context-xray.js.map +1 -0
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +20 -0
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/package.json +10 -1
|
@@ -123,6 +123,7 @@ function isRuntimeSourceFile(filename) {
|
|
|
123
123
|
export const DEFAULT_PLUGIN_REGISTRY = {
|
|
124
124
|
"agent-chat": "defaultAgentChatPlugin",
|
|
125
125
|
auth: "defaultAuthPlugin",
|
|
126
|
+
"context-xray": "defaultContextXrayPlugin",
|
|
126
127
|
"core-routes": "defaultCoreRoutesPlugin",
|
|
127
128
|
integrations: "defaultIntegrationsPlugin",
|
|
128
129
|
onboarding: "defaultOnboardingPlugin",
|
|
@@ -1 +1 @@
|
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AAG,IAAI,GAAG,CACrB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YACvB,CAAC,CAAC,EAAE;iBACC,WAAW,CAAC,UAAU,CAAC;iBACvB,MAAM,CAAC,mBAAmB,CAAC;iBAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC,CAAC,EAAE,CACP,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,mDAAmD;IAChF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAChD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC","sourcesContent":["import path from \"path\";\n\n// Lazy fs — loaded via dynamic import() on first use.\n// Avoids require() which bundlers convert to createRequire() that crashes on CF Workers.\nlet _fs: typeof import(\"fs\") | undefined;\nasync function getFs(): Promise<typeof import(\"fs\")> {\n if (!_fs) {\n _fs = await import(\"node:fs\");\n }\n return _fs;\n}\n\n/**\n * Map a Nitro-style route file path to { method, route }.\n *\n * Examples:\n * api/emails/index.get.ts → GET /api/emails\n * api/emails/[id].get.ts → GET /api/emails/:id\n * api/emails/[id]/star.patch.ts→ PATCH /api/emails/:id/star\n * api/events.get.ts → GET /api/events\n */\nexport function parseRouteFile(relPath: string): {\n method: string;\n route: string;\n} | null {\n // Strip .ts/.js extension\n const withoutExt = relPath.replace(/\\.[tj]s$/, \"\");\n\n // Extract HTTP method from the last segment (e.g. \"status.get\" → method=\"get\")\n const dotIdx = withoutExt.lastIndexOf(\".\");\n if (dotIdx === -1) return null;\n\n const method = withoutExt.slice(dotIdx + 1).toLowerCase();\n const validMethods = [\"get\", \"post\", \"put\", \"patch\", \"delete\", \"options\"];\n if (!validMethods.includes(method)) return null;\n\n let routePath = withoutExt.slice(0, dotIdx);\n\n // Replace [param] with :param\n routePath = routePath.replace(/\\[([^\\]]+)\\]/g, \":$1\");\n\n // Replace [...catchall] with ** (H3 catch-all syntax, value in params._)\n routePath = routePath.replace(/:\\.\\.\\.([^/]+)/g, \"**\");\n\n // Remove trailing /index\n routePath = routePath.replace(/\\/index$/, \"\");\n\n // Ensure leading slash\n if (!routePath.startsWith(\"/\")) routePath = \"/\" + routePath;\n\n return { method, route: routePath };\n}\n\n/**\n * Recursively discover all .ts files under a directory.\n */\nexport async function discoverFiles(\n dir: string,\n prefix = \"\",\n): Promise<string[]> {\n try {\n const fs = await getFs();\n if (!fs.existsSync(dir)) return [];\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const rel = prefix ? `${prefix}/${entry.name}` : entry.name;\n if (entry.isDirectory()) {\n files.push(...(await discoverFiles(path.join(dir, entry.name), rel)));\n } else if (entry.name.endsWith(\".ts\") || entry.name.endsWith(\".js\")) {\n files.push(rel);\n }\n }\n return files;\n } catch {\n return []; // Edge runtime — no filesystem\n }\n}\n\nexport interface DiscoveredRoute {\n method: string;\n route: string;\n /** Relative path from server/routes/ */\n filePath: string;\n /** Absolute path on disk */\n absPath: string;\n}\n\n/**\n * Discover all API routes in a project's server/routes/ directory.\n */\nexport async function discoverApiRoutes(\n cwd: string,\n): Promise<DiscoveredRoute[]> {\n const apiDir = path.join(cwd, \"server/routes/api\");\n const agentNativeDir = path.join(cwd, \"server/routes/_agent-native\");\n const routeFiles = [\n ...(await discoverFiles(apiDir, \"api\")),\n ...(await discoverFiles(agentNativeDir, \"_agent-native\")),\n ];\n const routes: DiscoveredRoute[] = [];\n\n for (const relFile of routeFiles) {\n const parsed = parseRouteFile(relFile);\n if (!parsed) continue;\n routes.push({\n ...parsed,\n filePath: relFile,\n absPath: path.join(cwd, \"server/routes\", relFile),\n });\n }\n\n return routes;\n}\n\n/**\n * Discover all server plugins in a project's server/plugins/ directory.\n */\nexport async function discoverPlugins(cwd: string): Promise<string[]> {\n try {\n const fs = await getFs();\n const pluginsDir = path.join(cwd, \"server/plugins\");\n if (!fs.existsSync(pluginsDir)) return [];\n return fs\n .readdirSync(pluginsDir)\n .filter(isRuntimeSourceFile)\n .sort()\n .map((f) => path.join(pluginsDir, f));\n } catch {\n return []; // Edge runtime — no filesystem\n }\n}\n\nfunction isRuntimeSourceFile(filename: string): boolean {\n if (!/\\.(ts|js)$/.test(filename)) return false;\n if (/\\.d\\.ts$/.test(filename)) return false;\n if (/\\.(test|spec)\\.(ts|js)$/.test(filename)) return false;\n return true;\n}\n\n/**\n * Default plugins that auto-mount when not provided by the template.\n * Key = filename stem, value = export name from @agent-native/core/server.\n */\nexport const DEFAULT_PLUGIN_REGISTRY: Record<string, string> = {\n \"agent-chat\": \"defaultAgentChatPlugin\",\n auth: \"defaultAuthPlugin\",\n \"core-routes\": \"defaultCoreRoutesPlugin\",\n integrations: \"defaultIntegrationsPlugin\",\n onboarding: \"defaultOnboardingPlugin\",\n org: \"defaultOrgPlugin\",\n resources: \"defaultResourcesPlugin\",\n sentry: \"defaultSentryPlugin\",\n terminal: \"defaultTerminalPlugin\",\n};\n\n/** Files to skip during action discovery (mirrors action-discovery.ts). */\nconst SKIP_ACTION_FILES = new Set([\n \"helpers\",\n \"run\",\n \"db-connect\",\n \"db-status\",\n \"registry\",\n]);\n\nexport interface DiscoveredAction {\n /** Action name (filename without extension) */\n name: string;\n /** Absolute path to the action file */\n absPath: string;\n /** HTTP method (from defineAction's http config, default POST) */\n method: string;\n}\n\n/**\n * Scan a single actions directory for defineAction-backed files. Shared\n * between the template-actions path and the workspace-core actions layer.\n */\nasync function scanActionsDir(actionsDir: string): Promise<DiscoveredAction[]> {\n const fs = await getFs();\n if (!fs.existsSync(actionsDir)) return [];\n\n const files = fs.readdirSync(actionsDir).filter((f) => {\n if (!isRuntimeSourceFile(f)) return false;\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (name.startsWith(\"_\")) return false;\n if (SKIP_ACTION_FILES.has(name)) return false;\n return true;\n });\n\n const out: DiscoveredAction[] = [];\n for (const file of files) {\n const name = file.replace(/\\.(ts|js)$/, \"\");\n const absPath = path.join(actionsDir, file);\n\n // Only mount actions that use defineAction. CLI-style scripts\n // (export default async function()) often use Node-only APIs\n // (fs, path) that can't run on edge runtimes — they're meant\n // to be invoked via `pnpm action <name>`, not as HTTP endpoints.\n let method = \"post\"; // default\n try {\n const content = fs.readFileSync(absPath, \"utf-8\");\n if (!content.includes(\"defineAction\")) continue;\n if (content.includes(\"http: false\")) continue;\n if (\n content.includes('method: \"GET\"') ||\n content.includes(\"method: 'GET'\")\n ) {\n method = \"get\";\n }\n } catch {\n continue;\n }\n\n out.push({ name, absPath, method });\n }\n\n return out;\n}\n\n/**\n * Discover action files in the actions/ directory.\n *\n * When a workspace core is present in the ancestor chain, its actions/\n * directory is also scanned and its actions are merged in after the\n * template's — with template actions winning on name collision.\n *\n * These become `/_agent-native/actions/:name` HTTP endpoints.\n */\nexport async function discoverActionFiles(\n cwd: string,\n): Promise<DiscoveredAction[]> {\n const templateActions = await scanActionsDir(path.join(cwd, \"actions\"));\n const byName = new Map<string, DiscoveredAction>();\n for (const a of templateActions) byName.set(a.name, a);\n\n // Merge workspace-core actions (template wins on collision).\n try {\n const { getWorkspaceCoreExports } = await import(\"./workspace-core.js\");\n const ws = await getWorkspaceCoreExports(cwd);\n if (ws && ws.actionsDir) {\n const wsActions = await scanActionsDir(ws.actionsDir);\n for (const a of wsActions) {\n if (!byName.has(a.name)) byName.set(a.name, a);\n }\n }\n } catch {\n // Edge runtime / no fs — skip workspace-core merge.\n }\n\n return Array.from(byName.values());\n}\n\n/**\n * Returns the stems of default plugins that are missing from the project.\n */\nexport async function getMissingDefaultPlugins(cwd: string): Promise<string[]> {\n let existingStems: Set<string>;\n try {\n const fs = await getFs();\n const pluginsDir = path.join(cwd, \"server/plugins\");\n existingStems = new Set(\n fs.existsSync(pluginsDir)\n ? fs\n .readdirSync(pluginsDir)\n .filter(isRuntimeSourceFile)\n .map((f) => path.basename(f, path.extname(f)))\n : [],\n );\n } catch {\n existingStems = new Set(); // Edge runtime — all defaults will be auto-mounted\n }\n return Object.keys(DEFAULT_PLUGIN_REGISTRY).filter(\n (stem) => !existingStems.has(stem),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"route-discovery.js","sourceRoot":"","sources":["../../src/deploy/route-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,sDAAsD;AACtD,yFAAyF;AACzF,IAAI,GAAoC,CAAC;AACzC,KAAK,UAAU,KAAK;IAClB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAI5C,0BAA0B;IAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAEnD,+EAA+E;IAC/E,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,MAAM,KAAK,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/B,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC1E,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAEhD,IAAI,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAE5C,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ACrC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,GAAW;IACxD,IAAI,aAA0B,CAAC;IAC/B,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,KAAK,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QACpD,aAAa,GAAG,IAAI,GAAG,CACrB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YACvB,CAAC,CAAC,EAAE;iBACC,WAAW,CAAC,UAAU,CAAC;iBACvB,MAAM,CAAC,mBAAmB,CAAC;iBAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YAClD,CAAC,CAAC,EAAE,CACP,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,mDAAmD;IAChF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAChD,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CACnC,CAAC;AACJ,CAAC","sourcesContent":["import path from \"path\";\n\n// Lazy fs — loaded via dynamic import() on first use.\n// Avoids require() which bundlers convert to createRequire() that crashes on CF Workers.\nlet _fs: typeof import(\"fs\") | undefined;\nasync function getFs(): Promise<typeof import(\"fs\")> {\n if (!_fs) {\n _fs = await import(\"node:fs\");\n }\n return _fs;\n}\n\n/**\n * Map a Nitro-style route file path to { method, route }.\n *\n * Examples:\n * api/emails/index.get.ts → GET /api/emails\n * api/emails/[id].get.ts → GET /api/emails/:id\n * api/emails/[id]/star.patch.ts→ PATCH /api/emails/:id/star\n * api/events.get.ts → GET /api/events\n */\nexport function parseRouteFile(relPath: string): {\n method: string;\n route: string;\n} | null {\n // Strip .ts/.js extension\n const withoutExt = relPath.replace(/\\.[tj]s$/, \"\");\n\n // Extract HTTP method from the last segment (e.g. \"status.get\" → method=\"get\")\n const dotIdx = withoutExt.lastIndexOf(\".\");\n if (dotIdx === -1) return null;\n\n const method = withoutExt.slice(dotIdx + 1).toLowerCase();\n const validMethods = [\"get\", \"post\", \"put\", \"patch\", \"delete\", \"options\"];\n if (!validMethods.includes(method)) return null;\n\n let routePath = withoutExt.slice(0, dotIdx);\n\n // Replace [param] with :param\n routePath = routePath.replace(/\\[([^\\]]+)\\]/g, \":$1\");\n\n // Replace [...catchall] with ** (H3 catch-all syntax, value in params._)\n routePath = routePath.replace(/:\\.\\.\\.([^/]+)/g, \"**\");\n\n // Remove trailing /index\n routePath = routePath.replace(/\\/index$/, \"\");\n\n // Ensure leading slash\n if (!routePath.startsWith(\"/\")) routePath = \"/\" + routePath;\n\n return { method, route: routePath };\n}\n\n/**\n * Recursively discover all .ts files under a directory.\n */\nexport async function discoverFiles(\n dir: string,\n prefix = \"\",\n): Promise<string[]> {\n try {\n const fs = await getFs();\n if (!fs.existsSync(dir)) return [];\n const entries = fs.readdirSync(dir, { withFileTypes: true });\n const files: string[] = [];\n for (const entry of entries) {\n const rel = prefix ? `${prefix}/${entry.name}` : entry.name;\n if (entry.isDirectory()) {\n files.push(...(await discoverFiles(path.join(dir, entry.name), rel)));\n } else if (entry.name.endsWith(\".ts\") || entry.name.endsWith(\".js\")) {\n files.push(rel);\n }\n }\n return files;\n } catch {\n return []; // Edge runtime — no filesystem\n }\n}\n\nexport interface DiscoveredRoute {\n method: string;\n route: string;\n /** Relative path from server/routes/ */\n filePath: string;\n /** Absolute path on disk */\n absPath: string;\n}\n\n/**\n * Discover all API routes in a project's server/routes/ directory.\n */\nexport async function discoverApiRoutes(\n cwd: string,\n): Promise<DiscoveredRoute[]> {\n const apiDir = path.join(cwd, \"server/routes/api\");\n const agentNativeDir = path.join(cwd, \"server/routes/_agent-native\");\n const routeFiles = [\n ...(await discoverFiles(apiDir, \"api\")),\n ...(await discoverFiles(agentNativeDir, \"_agent-native\")),\n ];\n const routes: DiscoveredRoute[] = [];\n\n for (const relFile of routeFiles) {\n const parsed = parseRouteFile(relFile);\n if (!parsed) continue;\n routes.push({\n ...parsed,\n filePath: relFile,\n absPath: path.join(cwd, \"server/routes\", relFile),\n });\n }\n\n return routes;\n}\n\n/**\n * Discover all server plugins in a project's server/plugins/ directory.\n */\nexport async function discoverPlugins(cwd: string): Promise<string[]> {\n try {\n const fs = await getFs();\n const pluginsDir = path.join(cwd, \"server/plugins\");\n if (!fs.existsSync(pluginsDir)) return [];\n return fs\n .readdirSync(pluginsDir)\n .filter(isRuntimeSourceFile)\n .sort()\n .map((f) => path.join(pluginsDir, f));\n } catch {\n return []; // Edge runtime — no filesystem\n }\n}\n\nfunction isRuntimeSourceFile(filename: string): boolean {\n if (!/\\.(ts|js)$/.test(filename)) return false;\n if (/\\.d\\.ts$/.test(filename)) return false;\n if (/\\.(test|spec)\\.(ts|js)$/.test(filename)) return false;\n return true;\n}\n\n/**\n * Default plugins that auto-mount when not provided by the template.\n * Key = filename stem, value = export name from @agent-native/core/server.\n */\nexport const DEFAULT_PLUGIN_REGISTRY: Record<string, string> = {\n \"agent-chat\": \"defaultAgentChatPlugin\",\n auth: \"defaultAuthPlugin\",\n \"context-xray\": \"defaultContextXrayPlugin\",\n \"core-routes\": \"defaultCoreRoutesPlugin\",\n integrations: \"defaultIntegrationsPlugin\",\n onboarding: \"defaultOnboardingPlugin\",\n org: \"defaultOrgPlugin\",\n resources: \"defaultResourcesPlugin\",\n sentry: \"defaultSentryPlugin\",\n terminal: \"defaultTerminalPlugin\",\n};\n\n/** Files to skip during action discovery (mirrors action-discovery.ts). */\nconst SKIP_ACTION_FILES = new Set([\n \"helpers\",\n \"run\",\n \"db-connect\",\n \"db-status\",\n \"registry\",\n]);\n\nexport interface DiscoveredAction {\n /** Action name (filename without extension) */\n name: string;\n /** Absolute path to the action file */\n absPath: string;\n /** HTTP method (from defineAction's http config, default POST) */\n method: string;\n}\n\n/**\n * Scan a single actions directory for defineAction-backed files. Shared\n * between the template-actions path and the workspace-core actions layer.\n */\nasync function scanActionsDir(actionsDir: string): Promise<DiscoveredAction[]> {\n const fs = await getFs();\n if (!fs.existsSync(actionsDir)) return [];\n\n const files = fs.readdirSync(actionsDir).filter((f) => {\n if (!isRuntimeSourceFile(f)) return false;\n const name = f.replace(/\\.(ts|js)$/, \"\");\n if (name.startsWith(\"_\")) return false;\n if (SKIP_ACTION_FILES.has(name)) return false;\n return true;\n });\n\n const out: DiscoveredAction[] = [];\n for (const file of files) {\n const name = file.replace(/\\.(ts|js)$/, \"\");\n const absPath = path.join(actionsDir, file);\n\n // Only mount actions that use defineAction. CLI-style scripts\n // (export default async function()) often use Node-only APIs\n // (fs, path) that can't run on edge runtimes — they're meant\n // to be invoked via `pnpm action <name>`, not as HTTP endpoints.\n let method = \"post\"; // default\n try {\n const content = fs.readFileSync(absPath, \"utf-8\");\n if (!content.includes(\"defineAction\")) continue;\n if (content.includes(\"http: false\")) continue;\n if (\n content.includes('method: \"GET\"') ||\n content.includes(\"method: 'GET'\")\n ) {\n method = \"get\";\n }\n } catch {\n continue;\n }\n\n out.push({ name, absPath, method });\n }\n\n return out;\n}\n\n/**\n * Discover action files in the actions/ directory.\n *\n * When a workspace core is present in the ancestor chain, its actions/\n * directory is also scanned and its actions are merged in after the\n * template's — with template actions winning on name collision.\n *\n * These become `/_agent-native/actions/:name` HTTP endpoints.\n */\nexport async function discoverActionFiles(\n cwd: string,\n): Promise<DiscoveredAction[]> {\n const templateActions = await scanActionsDir(path.join(cwd, \"actions\"));\n const byName = new Map<string, DiscoveredAction>();\n for (const a of templateActions) byName.set(a.name, a);\n\n // Merge workspace-core actions (template wins on collision).\n try {\n const { getWorkspaceCoreExports } = await import(\"./workspace-core.js\");\n const ws = await getWorkspaceCoreExports(cwd);\n if (ws && ws.actionsDir) {\n const wsActions = await scanActionsDir(ws.actionsDir);\n for (const a of wsActions) {\n if (!byName.has(a.name)) byName.set(a.name, a);\n }\n }\n } catch {\n // Edge runtime / no fs — skip workspace-core merge.\n }\n\n return Array.from(byName.values());\n}\n\n/**\n * Returns the stems of default plugins that are missing from the project.\n */\nexport async function getMissingDefaultPlugins(cwd: string): Promise<string[]> {\n let existingStems: Set<string>;\n try {\n const fs = await getFs();\n const pluginsDir = path.join(cwd, \"server/plugins\");\n existingStems = new Set(\n fs.existsSync(pluginsDir)\n ? fs\n .readdirSync(pluginsDir)\n .filter(isRuntimeSourceFile)\n .map((f) => path.basename(f, path.extname(f)))\n : [],\n );\n } catch {\n existingStems = new Set(); // Edge runtime — all defaults will be auto-mounted\n }\n return Object.keys(DEFAULT_PLUGIN_REGISTRY).filter(\n (stem) => !existingStems.has(stem),\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Mirrors DEFAULT_PLUGIN_REGISTRY's slot names. */
|
|
2
|
-
export type PluginSlot = "agent-chat" | "auth" | "core-routes" | "integrations" | "org" | "resources" | "sentry" | "terminal";
|
|
2
|
+
export type PluginSlot = "agent-chat" | "auth" | "context-xray" | "core-routes" | "integrations" | "org" | "resources" | "sentry" | "terminal";
|
|
3
3
|
export interface WorkspaceCoreExports {
|
|
4
4
|
/** Absolute path of the monorepo root (the dir containing the root package.json). */
|
|
5
5
|
workspaceRoot: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-core.d.ts","sourceRoot":"","sources":["../../src/deploy/workspace-core.ts"],"names":[],"mappings":"AAkCA,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAClB,YAAY,GACZ,MAAM,GACN,aAAa,GACb,cAAc,GACd,KAAK,GACL,WAAW,GACX,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,aAAa,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,gGAAgG;IAChG,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wEAAwE;IACxE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;
|
|
1
|
+
{"version":3,"file":"workspace-core.d.ts","sourceRoot":"","sources":["../../src/deploy/workspace-core.ts"],"names":[],"mappings":"AAkCA,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAClB,YAAY,GACZ,MAAM,GACN,cAAc,GACd,aAAa,GACb,cAAc,GACd,KAAK,GACL,WAAW,GACX,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,aAAa,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,4FAA4F;IAC5F,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,gGAAgG;IAChG,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wEAAwE;IACxE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAqKD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CA0CtC;AAED,wDAAwD;AACxD,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
|
@@ -153,6 +153,7 @@ async function discoverPluginExports(packageDir) {
|
|
|
153
153
|
const slotExportNames = {
|
|
154
154
|
"agent-chat": ["agentChatPlugin"],
|
|
155
155
|
auth: ["authPlugin"],
|
|
156
|
+
"context-xray": ["contextXrayPlugin"],
|
|
156
157
|
"core-routes": ["coreRoutesPlugin"],
|
|
157
158
|
integrations: ["integrationsPlugin"],
|
|
158
159
|
org: ["orgPlugin"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace-core.js","sourceRoot":"","sources":["../../src/deploy/workspace-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,IAAI,GAAoC,CAAC;AACzC,KAAK,UAAU,KAAK;IAClB,IAAI,CAAC,GAAG;QAAE,GAAG,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC;AACb,CAAC;AA8BD,IAAI,KAAuE,CAAC;AAE5E;;;;GAIG;AACH,KAAK,UAAU,iBAAiB,CAC9B,QAAgB;IAEhB,MAAM,EAAE,GAAG,MAAM,KAAK,EAAE,CAAC;IACzB,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,wDAAwD;IACxD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC1D,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,EAAE,aAAa,CAAC;gBACtD,IAAI,OAAO,QAAQ,KAAK,QAAQ,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AAC;QAChB,KAAK,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAExD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,SAAS,GACb;QACE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;KAChC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC;IAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAExD,MAAM,MAAM,GAAyB;QACnC,aAAa,EAAE,QAAQ,CAAC,aAAa;QACrC,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,UAAU;QACV,OAAO;QACP,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;QACzD,SAAS;QACT,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;KAChE,CAAC;IAEF,KAAK,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,wBAAwB;IACtC,KAAK,GAAG,SAAS,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Workspace-core discovery.\n *\n * An enterprise can sit many agent-native apps in one monorepo alongside a\n * private workspace shared package that can provide shared plugins, skills,\n * actions, and AGENTS.md. Apps inherit everything from\n * the shared package without writing any boilerplate — this is the\n * middle layer of the three-layer inheritance model:\n *\n * 1. app local (highest priority — app's own server/plugins/, actions/, etc.)\n * 2. workspace core (middle — packages/shared/ in the enterprise monorepo)\n * 3. @agent-native/core (lowest — framework defaults)\n *\n * Discovery works by walking up from the build cwd looking for a package.json\n * that declares `\"agent-native\": { \"workspaceCore\": \"@company/shared\" }`.\n * The declared package is then resolved through the monorepo's node_modules,\n * and its directory structure is probed for the standard layout:\n *\n * packages/shared/\n * package.json\n * src/server/index.ts (exports <slot>Plugin for any slot it wants to provide)\n * actions/ (shared agent-callable actions)\n * .agents/skills/ (shared skills)\n * AGENTS.md (enterprise-wide agent instructions)\n * src/client/ (optional shared React code)\n */\nimport path from \"path\";\n\nlet _fs: typeof import(\"fs\") | undefined;\nasync function getFs(): Promise<typeof import(\"fs\")> {\n if (!_fs) _fs = await import(\"node:fs\");\n return _fs;\n}\n\n/** Mirrors DEFAULT_PLUGIN_REGISTRY's slot names. */\nexport type PluginSlot =\n | \"agent-chat\"\n | \"auth\"\n | \"core-routes\"\n | \"integrations\"\n | \"org\"\n | \"resources\"\n | \"sentry\"\n | \"terminal\";\n\nexport interface WorkspaceCoreExports {\n /** Absolute path of the monorepo root (the dir containing the root package.json). */\n workspaceRoot: string;\n /** Resolved package name — e.g. \"@my-company/shared\". */\n packageName: string;\n /** Absolute path to the workspace core package's root directory. */\n packageDir: string;\n /** Plugin slot → export name (if the workspace core declares an override for that slot). */\n plugins: Partial<Record<PluginSlot, string>>;\n /** Absolute path to the workspace core's actions/ directory, or null if it doesn't have one. */\n actionsDir: string | null;\n /** Absolute path to the workspace core's skills/ directory, or null. */\n skillsDir: string | null;\n /** Absolute path to the workspace core's AGENTS.md, or null. */\n agentsMdPath: string | null;\n}\n\nlet cache: { cwd: string; result: WorkspaceCoreExports | null } | undefined;\n\n/**\n * Walk up from startDir looking for a directory whose package.json has an\n * `agent-native.workspaceCore` field. Returns both the root dir and the\n * declared package name, or null if there's no workspace core in the tree.\n */\nasync function findWorkspaceRoot(\n startDir: string,\n): Promise<{ workspaceRoot: string; packageName: string } | null> {\n const fs = await getFs();\n let dir = path.resolve(startDir);\n // Hard stop at filesystem root to avoid infinite loops.\n for (let i = 0; i < 20; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const declared = pkg?.[\"agent-native\"]?.workspaceCore;\n if (typeof declared === \"string\" && declared.length > 0) {\n return { workspaceRoot: dir, packageName: declared };\n }\n } catch {\n // Malformed package.json — keep walking up.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Resolve a workspace package name to its directory inside the monorepo.\n * Tries in order:\n * 1. <workspaceRoot>/node_modules/<packageName>/package.json (pnpm symlink)\n * 2. For each dir under <workspaceRoot>/packages/*, read its package.json\n * and match on `name`.\n * 3. For each dir under <workspaceRoot>/packages/*\\/*, same match.\n *\n * The pnpm symlink approach is fastest when deps are installed; the direct\n * scan is a fallback for pre-install scenarios (e.g. running tests before\n * the first `pnpm install` in a scaffolded workspace).\n */\nasync function resolvePackageDir(\n workspaceRoot: string,\n packageName: string,\n): Promise<string | null> {\n const fs = await getFs();\n\n // 1) pnpm / npm install symlink\n const nmCandidate = path.join(workspaceRoot, \"node_modules\", packageName);\n if (fs.existsSync(path.join(nmCandidate, \"package.json\"))) {\n return nmCandidate;\n }\n\n // 2) scan packages/*\n const packagesDir = path.join(workspaceRoot, \"packages\");\n const candidates: string[] = [];\n if (fs.existsSync(packagesDir)) {\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n candidates.push(path.join(packagesDir, entry.name));\n }\n }\n\n // 3) scan packages/*/* (for scoped layouts like packages/@company/shared)\n if (fs.existsSync(packagesDir)) {\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n const scopeDir = path.join(packagesDir, entry.name);\n for (const sub of fs.readdirSync(scopeDir, { withFileTypes: true })) {\n if (!sub.isDirectory()) continue;\n candidates.push(path.join(scopeDir, sub.name));\n }\n }\n }\n\n for (const candidate of candidates) {\n const pkgPath = path.join(candidate, \"package.json\");\n if (!fs.existsSync(pkgPath)) continue;\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n if (pkg?.name === packageName) return candidate;\n } catch {\n // ignore\n }\n }\n return null;\n}\n\n/**\n * Probe a workspace core package directory to discover which plugin slots it\n * exports. We read its package.json `exports` field + peek at\n * `src/server/index.ts` (or dist/server/index.js) looking for exports of the\n * form `<slot>Plugin` — the same convention the core server index uses.\n */\nasync function discoverPluginExports(\n packageDir: string,\n): Promise<Partial<Record<PluginSlot, string>>> {\n const fs = await getFs();\n const out: Partial<Record<PluginSlot, string>> = {};\n\n const candidates = [\n path.join(packageDir, \"src\", \"server\", \"index.ts\"),\n path.join(packageDir, \"dist\", \"server\", \"index.js\"),\n path.join(packageDir, \"src\", \"server.ts\"),\n path.join(packageDir, \"dist\", \"server.js\"),\n ];\n\n let source = \"\";\n for (const c of candidates) {\n if (fs.existsSync(c)) {\n try {\n source = fs.readFileSync(c, \"utf-8\");\n break;\n } catch {\n // keep trying\n }\n }\n }\n if (!source) return out;\n\n // Map slot name → export name we're looking for. \"agent-chat\" has a hyphen,\n // so we probe both the camelCase and dash-free variants.\n const slotExportNames: Record<PluginSlot, string[]> = {\n \"agent-chat\": [\"agentChatPlugin\"],\n auth: [\"authPlugin\"],\n \"core-routes\": [\"coreRoutesPlugin\"],\n integrations: [\"integrationsPlugin\"],\n org: [\"orgPlugin\"],\n resources: [\"resourcesPlugin\"],\n sentry: [\"sentryPlugin\"],\n terminal: [\"terminalPlugin\"],\n };\n\n for (const [slot, names] of Object.entries(slotExportNames) as [\n PluginSlot,\n string[],\n ][]) {\n for (const name of names) {\n // Match any of:\n // export const <name>\n // export async function <name>\n // export function <name>\n // export { <name>\n // export { foo as <name>\n const patterns = [\n new RegExp(`export\\\\s+const\\\\s+${name}\\\\b`, \"m\"),\n new RegExp(`export\\\\s+(?:async\\\\s+)?function\\\\s+${name}\\\\b`, \"m\"),\n new RegExp(`export\\\\s*\\\\{[^}]*?\\\\b${name}\\\\b[^}]*?\\\\}`, \"m\"),\n ];\n if (patterns.some((re) => re.test(source))) {\n out[slot] = name;\n break;\n }\n }\n }\n return out;\n}\n\n/**\n * Main entry point. Discovers the workspace core for the given cwd (defaults\n * to process.cwd()) and returns its layout. Returns null if there's no\n * workspace core in the ancestor chain. Result is cached per-cwd so repeated\n * calls during a single build are cheap.\n */\nexport async function getWorkspaceCoreExports(\n cwd: string = process.cwd(),\n): Promise<WorkspaceCoreExports | null> {\n if (cache && cache.cwd === cwd) return cache.result;\n\n const fs = await getFs();\n\n const rootInfo = await findWorkspaceRoot(cwd);\n if (!rootInfo) {\n cache = { cwd, result: null };\n return null;\n }\n\n const packageDir = await resolvePackageDir(\n rootInfo.workspaceRoot,\n rootInfo.packageName,\n );\n if (!packageDir) {\n cache = { cwd, result: null };\n return null;\n }\n\n const plugins = await discoverPluginExports(packageDir);\n\n const actionsDir = path.join(packageDir, \"actions\");\n const skillsDir =\n [\n path.join(packageDir, \".agents\", \"skills\"),\n path.join(packageDir, \"skills\"),\n ].find((candidate) => fs.existsSync(candidate)) ?? null;\n const agentsMdPath = path.join(packageDir, \"AGENTS.md\");\n\n const result: WorkspaceCoreExports = {\n workspaceRoot: rootInfo.workspaceRoot,\n packageName: rootInfo.packageName,\n packageDir,\n plugins,\n actionsDir: fs.existsSync(actionsDir) ? actionsDir : null,\n skillsDir,\n agentsMdPath: fs.existsSync(agentsMdPath) ? agentsMdPath : null,\n };\n\n cache = { cwd, result };\n return result;\n}\n\n/** Reset the internal cache. Exposed only for tests. */\nexport function _resetWorkspaceCoreCache(): void {\n cache = undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"workspace-core.js","sourceRo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,EAAE,SAAS,CAAC,CAAC;IACpD,MAAM,SAAS,GACb;QACE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;KAChC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC;IAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAExD,MAAM,MAAM,GAAyB;QACnC,aAAa,EAAE,QAAQ,CAAC,aAAa;QACrC,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,UAAU;QACV,OAAO;QACP,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI;QACzD,SAAS;QACT,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI;KAChE,CAAC;IAEF,KAAK,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,wBAAwB;IACtC,KAAK,GAAG,SAAS,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Workspace-core discovery.\n *\n * An enterprise can sit many agent-native apps in one monorepo alongside a\n * private workspace shared package that can provide shared plugins, skills,\n * actions, and AGENTS.md. Apps inherit everything from\n * the shared package without writing any boilerplate — this is the\n * middle layer of the three-layer inheritance model:\n *\n * 1. app local (highest priority — app's own server/plugins/, actions/, etc.)\n * 2. workspace core (middle — packages/shared/ in the enterprise monorepo)\n * 3. @agent-native/core (lowest — framework defaults)\n *\n * Discovery works by walking up from the build cwd looking for a package.json\n * that declares `\"agent-native\": { \"workspaceCore\": \"@company/shared\" }`.\n * The declared package is then resolved through the monorepo's node_modules,\n * and its directory structure is probed for the standard layout:\n *\n * packages/shared/\n * package.json\n * src/server/index.ts (exports <slot>Plugin for any slot it wants to provide)\n * actions/ (shared agent-callable actions)\n * .agents/skills/ (shared skills)\n * AGENTS.md (enterprise-wide agent instructions)\n * src/client/ (optional shared React code)\n */\nimport path from \"path\";\n\nlet _fs: typeof import(\"fs\") | undefined;\nasync function getFs(): Promise<typeof import(\"fs\")> {\n if (!_fs) _fs = await import(\"node:fs\");\n return _fs;\n}\n\n/** Mirrors DEFAULT_PLUGIN_REGISTRY's slot names. */\nexport type PluginSlot =\n | \"agent-chat\"\n | \"auth\"\n | \"context-xray\"\n | \"core-routes\"\n | \"integrations\"\n | \"org\"\n | \"resources\"\n | \"sentry\"\n | \"terminal\";\n\nexport interface WorkspaceCoreExports {\n /** Absolute path of the monorepo root (the dir containing the root package.json). */\n workspaceRoot: string;\n /** Resolved package name — e.g. \"@my-company/shared\". */\n packageName: string;\n /** Absolute path to the workspace core package's root directory. */\n packageDir: string;\n /** Plugin slot → export name (if the workspace core declares an override for that slot). */\n plugins: Partial<Record<PluginSlot, string>>;\n /** Absolute path to the workspace core's actions/ directory, or null if it doesn't have one. */\n actionsDir: string | null;\n /** Absolute path to the workspace core's skills/ directory, or null. */\n skillsDir: string | null;\n /** Absolute path to the workspace core's AGENTS.md, or null. */\n agentsMdPath: string | null;\n}\n\nlet cache: { cwd: string; result: WorkspaceCoreExports | null } | undefined;\n\n/**\n * Walk up from startDir looking for a directory whose package.json has an\n * `agent-native.workspaceCore` field. Returns both the root dir and the\n * declared package name, or null if there's no workspace core in the tree.\n */\nasync function findWorkspaceRoot(\n startDir: string,\n): Promise<{ workspaceRoot: string; packageName: string } | null> {\n const fs = await getFs();\n let dir = path.resolve(startDir);\n // Hard stop at filesystem root to avoid infinite loops.\n for (let i = 0; i < 20; i++) {\n const pkgPath = path.join(dir, \"package.json\");\n if (fs.existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n const declared = pkg?.[\"agent-native\"]?.workspaceCore;\n if (typeof declared === \"string\" && declared.length > 0) {\n return { workspaceRoot: dir, packageName: declared };\n }\n } catch {\n // Malformed package.json — keep walking up.\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n\n/**\n * Resolve a workspace package name to its directory inside the monorepo.\n * Tries in order:\n * 1. <workspaceRoot>/node_modules/<packageName>/package.json (pnpm symlink)\n * 2. For each dir under <workspaceRoot>/packages/*, read its package.json\n * and match on `name`.\n * 3. For each dir under <workspaceRoot>/packages/*\\/*, same match.\n *\n * The pnpm symlink approach is fastest when deps are installed; the direct\n * scan is a fallback for pre-install scenarios (e.g. running tests before\n * the first `pnpm install` in a scaffolded workspace).\n */\nasync function resolvePackageDir(\n workspaceRoot: string,\n packageName: string,\n): Promise<string | null> {\n const fs = await getFs();\n\n // 1) pnpm / npm install symlink\n const nmCandidate = path.join(workspaceRoot, \"node_modules\", packageName);\n if (fs.existsSync(path.join(nmCandidate, \"package.json\"))) {\n return nmCandidate;\n }\n\n // 2) scan packages/*\n const packagesDir = path.join(workspaceRoot, \"packages\");\n const candidates: string[] = [];\n if (fs.existsSync(packagesDir)) {\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory()) continue;\n candidates.push(path.join(packagesDir, entry.name));\n }\n }\n\n // 3) scan packages/*/* (for scoped layouts like packages/@company/shared)\n if (fs.existsSync(packagesDir)) {\n for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n const scopeDir = path.join(packagesDir, entry.name);\n for (const sub of fs.readdirSync(scopeDir, { withFileTypes: true })) {\n if (!sub.isDirectory()) continue;\n candidates.push(path.join(scopeDir, sub.name));\n }\n }\n }\n\n for (const candidate of candidates) {\n const pkgPath = path.join(candidate, \"package.json\");\n if (!fs.existsSync(pkgPath)) continue;\n try {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, \"utf-8\"));\n if (pkg?.name === packageName) return candidate;\n } catch {\n // ignore\n }\n }\n return null;\n}\n\n/**\n * Probe a workspace core package directory to discover which plugin slots it\n * exports. We read its package.json `exports` field + peek at\n * `src/server/index.ts` (or dist/server/index.js) looking for exports of the\n * form `<slot>Plugin` — the same convention the core server index uses.\n */\nasync function discoverPluginExports(\n packageDir: string,\n): Promise<Partial<Record<PluginSlot, string>>> {\n const fs = await getFs();\n const out: Partial<Record<PluginSlot, string>> = {};\n\n const candidates = [\n path.join(packageDir, \"src\", \"server\", \"index.ts\"),\n path.join(packageDir, \"dist\", \"server\", \"index.js\"),\n path.join(packageDir, \"src\", \"server.ts\"),\n path.join(packageDir, \"dist\", \"server.js\"),\n ];\n\n let source = \"\";\n for (const c of candidates) {\n if (fs.existsSync(c)) {\n try {\n source = fs.readFileSync(c, \"utf-8\");\n break;\n } catch {\n // keep trying\n }\n }\n }\n if (!source) return out;\n\n // Map slot name → export name we're looking for. \"agent-chat\" has a hyphen,\n // so we probe both the camelCase and dash-free variants.\n const slotExportNames: Record<PluginSlot, string[]> = {\n \"agent-chat\": [\"agentChatPlugin\"],\n auth: [\"authPlugin\"],\n \"context-xray\": [\"contextXrayPlugin\"],\n \"core-routes\": [\"coreRoutesPlugin\"],\n integrations: [\"integrationsPlugin\"],\n org: [\"orgPlugin\"],\n resources: [\"resourcesPlugin\"],\n sentry: [\"sentryPlugin\"],\n terminal: [\"terminalPlugin\"],\n };\n\n for (const [slot, names] of Object.entries(slotExportNames) as [\n PluginSlot,\n string[],\n ][]) {\n for (const name of names) {\n // Match any of:\n // export const <name>\n // export async function <name>\n // export function <name>\n // export { <name>\n // export { foo as <name>\n const patterns = [\n new RegExp(`export\\\\s+const\\\\s+${name}\\\\b`, \"m\"),\n new RegExp(`export\\\\s+(?:async\\\\s+)?function\\\\s+${name}\\\\b`, \"m\"),\n new RegExp(`export\\\\s*\\\\{[^}]*?\\\\b${name}\\\\b[^}]*?\\\\}`, \"m\"),\n ];\n if (patterns.some((re) => re.test(source))) {\n out[slot] = name;\n break;\n }\n }\n }\n return out;\n}\n\n/**\n * Main entry point. Discovers the workspace core for the given cwd (defaults\n * to process.cwd()) and returns its layout. Returns null if there's no\n * workspace core in the ancestor chain. Result is cached per-cwd so repeated\n * calls during a single build are cheap.\n */\nexport async function getWorkspaceCoreExports(\n cwd: string = process.cwd(),\n): Promise<WorkspaceCoreExports | null> {\n if (cache && cache.cwd === cwd) return cache.result;\n\n const fs = await getFs();\n\n const rootInfo = await findWorkspaceRoot(cwd);\n if (!rootInfo) {\n cache = { cwd, result: null };\n return null;\n }\n\n const packageDir = await resolvePackageDir(\n rootInfo.workspaceRoot,\n rootInfo.packageName,\n );\n if (!packageDir) {\n cache = { cwd, result: null };\n return null;\n }\n\n const plugins = await discoverPluginExports(packageDir);\n\n const actionsDir = path.join(packageDir, \"actions\");\n const skillsDir =\n [\n path.join(packageDir, \".agents\", \"skills\"),\n path.join(packageDir, \"skills\"),\n ].find((candidate) => fs.existsSync(candidate)) ?? null;\n const agentsMdPath = path.join(packageDir, \"AGENTS.md\");\n\n const result: WorkspaceCoreExports = {\n workspaceRoot: rootInfo.workspaceRoot,\n packageName: rootInfo.packageName,\n packageDir,\n plugins,\n actionsDir: fs.existsSync(actionsDir) ? actionsDir : null,\n skillsDir,\n agentsMdPath: fs.existsSync(agentsMdPath) ? agentsMdPath : null,\n };\n\n cache = { cwd, result };\n return result;\n}\n\n/** Reset the internal cache. Exposed only for tests. */\nexport function _resetWorkspaceCoreCache(): void {\n cache = undefined;\n}\n"]}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { type CredentialContext } from "../credentials/index.js";
|
|
2
|
+
import type { WorkspaceConnectionTemplateUse } from "../connections/catalog.js";
|
|
3
|
+
export declare const PROVIDER_API_IDS: readonly ["amplitude", "apollo", "bigquery", "commonroom", "dataforseo", "ga4", "gcloud", "github", "gmail", "gong", "google_calendar", "google_drive", "granola", "grafana", "hubspot", "jira", "mixpanel", "notion", "posthog", "prometheus", "pylon", "sentry", "slack", "stripe", "twitter"];
|
|
4
|
+
export type ProviderApiId = (typeof PROVIDER_API_IDS)[number];
|
|
5
|
+
export type ProviderApiMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
|
|
6
|
+
export interface ProviderApiRequestArgs {
|
|
7
|
+
provider: ProviderApiId | string;
|
|
8
|
+
method?: ProviderApiMethod;
|
|
9
|
+
path: string;
|
|
10
|
+
query?: unknown;
|
|
11
|
+
headers?: Record<string, unknown>;
|
|
12
|
+
body?: unknown;
|
|
13
|
+
auth?: "default" | "none";
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
maxBytes?: number;
|
|
16
|
+
connectionId?: string | null;
|
|
17
|
+
accountId?: string | null;
|
|
18
|
+
}
|
|
19
|
+
export type ProviderApiAuthKind = {
|
|
20
|
+
type: "none";
|
|
21
|
+
} | {
|
|
22
|
+
type: "bearer";
|
|
23
|
+
keys: readonly string[];
|
|
24
|
+
workspaceProvider?: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "basic";
|
|
27
|
+
usernameKey: string;
|
|
28
|
+
passwordKey: string;
|
|
29
|
+
workspaceProvider?: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "basic-raw";
|
|
32
|
+
key: string;
|
|
33
|
+
workspaceProvider?: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "api-key-header";
|
|
36
|
+
key: string;
|
|
37
|
+
header: string;
|
|
38
|
+
workspaceProvider?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "google-service-account";
|
|
41
|
+
scopes: readonly string[];
|
|
42
|
+
} | {
|
|
43
|
+
type: "oauth-bearer";
|
|
44
|
+
oauthProvider: string;
|
|
45
|
+
tokenLabel: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: "prometheus";
|
|
48
|
+
};
|
|
49
|
+
export interface ProviderApiConfig {
|
|
50
|
+
id: ProviderApiId;
|
|
51
|
+
label: string;
|
|
52
|
+
defaultBaseUrl: string;
|
|
53
|
+
baseUrlCredentialKey?: string;
|
|
54
|
+
auth: ProviderApiAuthKind;
|
|
55
|
+
credentialKeys: readonly string[];
|
|
56
|
+
docsUrls: readonly string[];
|
|
57
|
+
specUrls?: readonly string[];
|
|
58
|
+
allowedHostSuffixes?: readonly string[];
|
|
59
|
+
defaultHeaders?: Record<string, string>;
|
|
60
|
+
placeholders?: readonly ProviderApiPlaceholder[];
|
|
61
|
+
examples?: readonly ProviderApiExample[];
|
|
62
|
+
notes?: readonly string[];
|
|
63
|
+
templateUses?: readonly WorkspaceConnectionTemplateUse[];
|
|
64
|
+
}
|
|
65
|
+
export interface ProviderApiPlaceholder {
|
|
66
|
+
name: string;
|
|
67
|
+
credentialKey: string;
|
|
68
|
+
label: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ProviderApiExample {
|
|
71
|
+
label: string;
|
|
72
|
+
method: ProviderApiMethod;
|
|
73
|
+
path: string;
|
|
74
|
+
body?: unknown;
|
|
75
|
+
}
|
|
76
|
+
export interface ProviderApiResolvedCredential {
|
|
77
|
+
key: string;
|
|
78
|
+
value: string;
|
|
79
|
+
source: string;
|
|
80
|
+
provider: string;
|
|
81
|
+
connectionId?: string;
|
|
82
|
+
connectionLabel?: string;
|
|
83
|
+
accountId?: string;
|
|
84
|
+
accountLabel?: string | null;
|
|
85
|
+
scope?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ProviderApiCredentialLookupOptions {
|
|
88
|
+
appId: string;
|
|
89
|
+
provider: string;
|
|
90
|
+
key: string;
|
|
91
|
+
ctx: CredentialContext;
|
|
92
|
+
workspaceProvider?: string;
|
|
93
|
+
connectionId?: string | null;
|
|
94
|
+
localCredentialSource: string;
|
|
95
|
+
}
|
|
96
|
+
export type ProviderApiCredentialResolver = (options: ProviderApiCredentialLookupOptions) => Promise<ProviderApiResolvedCredential | null>;
|
|
97
|
+
export interface ProviderApiRuntimeOptions {
|
|
98
|
+
appId: string;
|
|
99
|
+
providerIds?: readonly (ProviderApiId | string)[];
|
|
100
|
+
localCredentialSource?: string;
|
|
101
|
+
getCredentialContext?: () => CredentialContext | null;
|
|
102
|
+
resolveCredential?: ProviderApiCredentialResolver;
|
|
103
|
+
}
|
|
104
|
+
interface ProviderApiRuntime {
|
|
105
|
+
providerIds: readonly ProviderApiId[];
|
|
106
|
+
listCatalog(provider?: ProviderApiId | string): ReturnType<typeof listProviderApiCatalog>;
|
|
107
|
+
fetchDocs(options: {
|
|
108
|
+
provider: ProviderApiId | string;
|
|
109
|
+
url?: string;
|
|
110
|
+
maxBytes?: number;
|
|
111
|
+
}): Promise<unknown>;
|
|
112
|
+
executeRequest(args: ProviderApiRequestArgs): Promise<unknown>;
|
|
113
|
+
}
|
|
114
|
+
export declare function getProviderApiConfig(provider: ProviderApiId | string): ProviderApiConfig;
|
|
115
|
+
export declare function isProviderApiId(provider: string): provider is ProviderApiId;
|
|
116
|
+
export declare function listProviderApiIdsForTemplateUse(templateUse: WorkspaceConnectionTemplateUse): ProviderApiId[];
|
|
117
|
+
export declare function listProviderApiCatalog(provider?: ProviderApiId | string, options?: {
|
|
118
|
+
providerIds?: readonly (ProviderApiId | string)[];
|
|
119
|
+
}): {
|
|
120
|
+
id: "amplitude" | "bigquery" | "sentry" | "posthog" | "mixpanel" | "github" | "slack" | "twitter" | "notion" | "gmail" | "google_drive" | "hubspot" | "granola" | "apollo" | "commonroom" | "dataforseo" | "ga4" | "gcloud" | "gong" | "google_calendar" | "grafana" | "jira" | "prometheus" | "pylon" | "stripe";
|
|
121
|
+
label: string;
|
|
122
|
+
defaultBaseUrl: string;
|
|
123
|
+
baseUrlCredentialKey: string;
|
|
124
|
+
auth: string;
|
|
125
|
+
credentialKeys: readonly string[];
|
|
126
|
+
docsUrls: readonly string[];
|
|
127
|
+
specUrls: readonly string[];
|
|
128
|
+
allowedHostSuffixes: readonly string[];
|
|
129
|
+
placeholders: readonly ProviderApiPlaceholder[];
|
|
130
|
+
defaultHeaders: Record<string, string>;
|
|
131
|
+
examples: readonly ProviderApiExample[];
|
|
132
|
+
notes: readonly string[];
|
|
133
|
+
templateUses: readonly WorkspaceConnectionTemplateUse[];
|
|
134
|
+
}[];
|
|
135
|
+
export declare function createProviderApiRuntime(options: ProviderApiRuntimeOptions): ProviderApiRuntime;
|
|
136
|
+
export declare function fetchProviderApiDocs(options: {
|
|
137
|
+
provider: ProviderApiId | string;
|
|
138
|
+
url?: string;
|
|
139
|
+
maxBytes?: number;
|
|
140
|
+
}, runtime?: ProviderApiRuntimeOptions): Promise<{
|
|
141
|
+
provider: "amplitude" | "bigquery" | "sentry" | "posthog" | "mixpanel" | "github" | "slack" | "twitter" | "notion" | "gmail" | "google_drive" | "hubspot" | "granola" | "apollo" | "commonroom" | "dataforseo" | "ga4" | "gcloud" | "gong" | "google_calendar" | "grafana" | "jira" | "prometheus" | "pylon" | "stripe";
|
|
142
|
+
catalog: {
|
|
143
|
+
id: "amplitude" | "bigquery" | "sentry" | "posthog" | "mixpanel" | "github" | "slack" | "twitter" | "notion" | "gmail" | "google_drive" | "hubspot" | "granola" | "apollo" | "commonroom" | "dataforseo" | "ga4" | "gcloud" | "gong" | "google_calendar" | "grafana" | "jira" | "prometheus" | "pylon" | "stripe";
|
|
144
|
+
label: string;
|
|
145
|
+
defaultBaseUrl: string;
|
|
146
|
+
baseUrlCredentialKey: string;
|
|
147
|
+
auth: string;
|
|
148
|
+
credentialKeys: readonly string[];
|
|
149
|
+
docsUrls: readonly string[];
|
|
150
|
+
specUrls: readonly string[];
|
|
151
|
+
allowedHostSuffixes: readonly string[];
|
|
152
|
+
placeholders: readonly ProviderApiPlaceholder[];
|
|
153
|
+
defaultHeaders: Record<string, string>;
|
|
154
|
+
examples: readonly ProviderApiExample[];
|
|
155
|
+
notes: readonly string[];
|
|
156
|
+
templateUses: readonly WorkspaceConnectionTemplateUse[];
|
|
157
|
+
};
|
|
158
|
+
request?: undefined;
|
|
159
|
+
response?: undefined;
|
|
160
|
+
} | {
|
|
161
|
+
provider: "amplitude" | "bigquery" | "sentry" | "posthog" | "mixpanel" | "github" | "slack" | "twitter" | "notion" | "gmail" | "google_drive" | "hubspot" | "granola" | "apollo" | "commonroom" | "dataforseo" | "ga4" | "gcloud" | "gong" | "google_calendar" | "grafana" | "jira" | "prometheus" | "pylon" | "stripe";
|
|
162
|
+
catalog: {
|
|
163
|
+
id: "amplitude" | "bigquery" | "sentry" | "posthog" | "mixpanel" | "github" | "slack" | "twitter" | "notion" | "gmail" | "google_drive" | "hubspot" | "granola" | "apollo" | "commonroom" | "dataforseo" | "ga4" | "gcloud" | "gong" | "google_calendar" | "grafana" | "jira" | "prometheus" | "pylon" | "stripe";
|
|
164
|
+
label: string;
|
|
165
|
+
defaultBaseUrl: string;
|
|
166
|
+
baseUrlCredentialKey: string;
|
|
167
|
+
auth: string;
|
|
168
|
+
credentialKeys: readonly string[];
|
|
169
|
+
docsUrls: readonly string[];
|
|
170
|
+
specUrls: readonly string[];
|
|
171
|
+
allowedHostSuffixes: readonly string[];
|
|
172
|
+
placeholders: readonly ProviderApiPlaceholder[];
|
|
173
|
+
defaultHeaders: Record<string, string>;
|
|
174
|
+
examples: readonly ProviderApiExample[];
|
|
175
|
+
notes: readonly string[];
|
|
176
|
+
templateUses: readonly WorkspaceConnectionTemplateUse[];
|
|
177
|
+
};
|
|
178
|
+
request: {
|
|
179
|
+
url: string;
|
|
180
|
+
};
|
|
181
|
+
response: {
|
|
182
|
+
status: number;
|
|
183
|
+
statusText: string;
|
|
184
|
+
ok: boolean;
|
|
185
|
+
elapsedMs: number;
|
|
186
|
+
headers: Record<string, string>;
|
|
187
|
+
contentType: string;
|
|
188
|
+
size: number;
|
|
189
|
+
truncated: boolean;
|
|
190
|
+
text: string;
|
|
191
|
+
json: unknown;
|
|
192
|
+
};
|
|
193
|
+
}>;
|
|
194
|
+
export declare function executeProviderApiRequest(args: ProviderApiRequestArgs, runtime: ProviderApiRuntimeOptions): Promise<{
|
|
195
|
+
provider: {
|
|
196
|
+
id: "amplitude" | "bigquery" | "sentry" | "posthog" | "mixpanel" | "github" | "slack" | "twitter" | "notion" | "gmail" | "google_drive" | "hubspot" | "granola" | "apollo" | "commonroom" | "dataforseo" | "ga4" | "gcloud" | "gong" | "google_calendar" | "grafana" | "jira" | "prometheus" | "pylon" | "stripe";
|
|
197
|
+
label: string;
|
|
198
|
+
docsUrls: readonly string[];
|
|
199
|
+
specUrls: readonly string[];
|
|
200
|
+
};
|
|
201
|
+
request: {
|
|
202
|
+
connectionId?: string;
|
|
203
|
+
accountId?: string;
|
|
204
|
+
method: ProviderApiMethod;
|
|
205
|
+
url: string;
|
|
206
|
+
path: string;
|
|
207
|
+
auth: string;
|
|
208
|
+
credentialSources: {
|
|
209
|
+
fingerprint: string;
|
|
210
|
+
source: string;
|
|
211
|
+
key: string;
|
|
212
|
+
scope?: string;
|
|
213
|
+
accountId?: string;
|
|
214
|
+
provider: string;
|
|
215
|
+
accountLabel?: string | null;
|
|
216
|
+
connectionId?: string;
|
|
217
|
+
connectionLabel?: string;
|
|
218
|
+
}[];
|
|
219
|
+
headerNames: string[];
|
|
220
|
+
};
|
|
221
|
+
response: {
|
|
222
|
+
status: number;
|
|
223
|
+
statusText: string;
|
|
224
|
+
ok: boolean;
|
|
225
|
+
elapsedMs: number;
|
|
226
|
+
headers: Record<string, string>;
|
|
227
|
+
contentType: string;
|
|
228
|
+
size: number;
|
|
229
|
+
truncated: boolean;
|
|
230
|
+
text: string;
|
|
231
|
+
json: unknown;
|
|
232
|
+
};
|
|
233
|
+
guidance: string;
|
|
234
|
+
}>;
|
|
235
|
+
export declare function defaultProviderApiCredentialResolver(options: ProviderApiCredentialLookupOptions): Promise<ProviderApiResolvedCredential | null>;
|
|
236
|
+
export {};
|
|
237
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider-api/index.ts"],"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