glirastes 0.3.0 → 0.3.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/CHANGELOG.md +63 -0
- package/README.md +146 -9
- package/codegen/package.json +5 -0
- package/dist/cjs/codegen/asset-sync.d.ts +20 -0
- package/dist/cjs/codegen/asset-sync.js +28 -0
- package/dist/cjs/codegen/coverage.d.ts +66 -0
- package/dist/cjs/codegen/coverage.js +408 -0
- package/dist/cjs/codegen/endpoint-scanner.d.ts +16 -0
- package/dist/cjs/codegen/endpoint-scanner.js +197 -0
- package/dist/cjs/codegen/format.d.ts +17 -0
- package/dist/cjs/codegen/format.js +34 -0
- package/dist/cjs/codegen/fs-utils.d.ts +45 -0
- package/dist/cjs/codegen/fs-utils.js +165 -0
- package/dist/cjs/codegen/index.d.ts +13 -0
- package/dist/cjs/codegen/index.js +33 -0
- package/dist/cjs/codegen/mcp-generator.d.ts +50 -0
- package/dist/cjs/codegen/mcp-generator.js +803 -0
- package/dist/cjs/codegen/module-generator.d.ts +11 -0
- package/dist/cjs/codegen/module-generator.js +353 -0
- package/dist/cjs/codegen/nestjs-scanner.d.ts +43 -0
- package/dist/cjs/codegen/nestjs-scanner.js +241 -0
- package/dist/cjs/codegen/output-recommender.d.ts +23 -0
- package/dist/cjs/codegen/output-recommender.js +33 -0
- package/dist/cjs/codegen/scaffolder.d.ts +36 -0
- package/dist/cjs/codegen/scaffolder.js +262 -0
- package/dist/cjs/codegen/skill-generator.d.ts +49 -0
- package/dist/cjs/codegen/skill-generator.js +967 -0
- package/dist/cjs/codegen/types.d.ts +52 -0
- package/dist/cjs/codegen/types.js +16 -0
- package/dist/cjs/codegen/ui-scanner.d.ts +24 -0
- package/dist/cjs/codegen/ui-scanner.js +202 -0
- package/dist/cjs/codegen/validator.d.ts +35 -0
- package/dist/cjs/codegen/validator.js +292 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/openapi/index.d.ts +78 -0
- package/dist/cjs/openapi/index.js +347 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/react/audio-worklet-processor.d.ts +16 -0
- package/dist/cjs/react/audio-worklet-processor.js +27 -0
- package/dist/cjs/react/bridges/rest-session-bridge.d.ts +113 -0
- package/dist/cjs/react/bridges/rest-session-bridge.js +209 -0
- package/dist/cjs/react/components/ai-chat-panel.d.ts +12 -0
- package/dist/cjs/react/components/ai-chat-panel.js +67 -0
- package/dist/cjs/react/components/ai-trigger-button.d.ts +2 -0
- package/dist/cjs/react/components/ai-trigger-button.js +239 -0
- package/dist/cjs/react/components/approval-card.d.ts +9 -0
- package/dist/cjs/react/components/approval-card.js +24 -0
- package/dist/cjs/react/components/bulk-approval-card.d.ts +9 -0
- package/dist/cjs/react/components/bulk-approval-card.js +36 -0
- package/dist/cjs/react/components/chat-input.d.ts +10 -0
- package/dist/cjs/react/components/chat-input.js +60 -0
- package/dist/cjs/react/components/chat-window.d.ts +2 -0
- package/dist/cjs/react/components/chat-window.js +134 -0
- package/dist/cjs/react/components/confirm-dialog.d.ts +32 -0
- package/dist/cjs/react/components/confirm-dialog.js +48 -0
- package/dist/cjs/react/components/floating-chat-ui.d.ts +90 -0
- package/dist/cjs/react/components/floating-chat-ui.js +163 -0
- package/dist/cjs/react/components/mention-chip.d.ts +16 -0
- package/dist/cjs/react/components/mention-chip.js +42 -0
- package/dist/cjs/react/components/mention-input.d.ts +8 -0
- package/dist/cjs/react/components/mention-input.js +117 -0
- package/dist/cjs/react/components/message-bubble.d.ts +11 -0
- package/dist/cjs/react/components/message-bubble.js +171 -0
- package/dist/cjs/react/components/message-list.d.ts +8 -0
- package/dist/cjs/react/components/message-list.js +52 -0
- package/dist/cjs/react/components/pipeline-timeline.d.ts +7 -0
- package/dist/cjs/react/components/pipeline-timeline.js +72 -0
- package/dist/cjs/react/components/recording-bar.d.ts +2 -0
- package/dist/cjs/react/components/recording-bar.js +81 -0
- package/dist/cjs/react/components/recording-controls.d.ts +18 -0
- package/dist/cjs/react/components/recording-controls.js +38 -0
- package/dist/cjs/react/components/rich-mention-input.d.ts +2 -0
- package/dist/cjs/react/components/rich-mention-input.js +571 -0
- package/dist/cjs/react/components/session-switcher.d.ts +14 -0
- package/dist/cjs/react/components/session-switcher.js +133 -0
- package/dist/cjs/react/components/suggestion-bar.d.ts +9 -0
- package/dist/cjs/react/components/suggestion-bar.js +47 -0
- package/dist/cjs/react/components/suggestion-chip.d.ts +9 -0
- package/dist/cjs/react/components/suggestion-chip.js +14 -0
- package/dist/cjs/react/components/voice-input-addon.d.ts +13 -0
- package/dist/cjs/react/components/voice-input-addon.js +31 -0
- package/dist/cjs/react/components/voice-input-button.d.ts +2 -0
- package/dist/cjs/react/components/voice-input-button.js +55 -0
- package/dist/cjs/react/components/wavesurfer-loader.d.ts +5 -0
- package/dist/cjs/react/components/wavesurfer-loader.js +36 -0
- package/dist/cjs/react/hooks/use-ai-chat.d.ts +22 -0
- package/dist/cjs/react/hooks/use-ai-chat.js +51 -0
- package/dist/cjs/react/hooks/use-approvals.d.ts +23 -0
- package/dist/cjs/react/hooks/use-approvals.js +63 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +2 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.js +329 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +48 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.js +308 -0
- package/dist/cjs/react/hooks/use-draggable-position.d.ts +25 -0
- package/dist/cjs/react/hooks/use-draggable-position.js +134 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.d.ts +20 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.js +93 -0
- package/dist/cjs/react/hooks/use-mentions.d.ts +23 -0
- package/dist/cjs/react/hooks/use-mentions.js +42 -0
- package/dist/cjs/react/hooks/use-suggestions.d.ts +22 -0
- package/dist/cjs/react/hooks/use-suggestions.js +39 -0
- package/dist/cjs/react/index.d.ts +43 -0
- package/dist/cjs/react/index.js +111 -0
- package/dist/cjs/react/provider/ai-chat-provider.d.ts +45 -0
- package/dist/cjs/react/provider/ai-chat-provider.js +1024 -0
- package/dist/cjs/react/provider/chat-context.d.ts +84 -0
- package/dist/cjs/react/provider/chat-context.js +13 -0
- package/dist/cjs/react/template.d.ts +84 -0
- package/dist/cjs/react/template.js +90 -0
- package/dist/cjs/react/themes.d.ts +24 -0
- package/dist/cjs/react/themes.js +273 -0
- package/dist/cjs/react/transports/langgraph/index.d.ts +2 -0
- package/dist/cjs/react/transports/langgraph/index.js +8 -0
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +62 -0
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +94 -0
- package/dist/cjs/react/transports/langgraph.d.ts +71 -0
- package/dist/cjs/react/transports/langgraph.js +369 -0
- package/dist/cjs/react/transports/vercel/index.d.ts +2 -0
- package/dist/cjs/react/transports/vercel/index.js +8 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +49 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +81 -0
- package/dist/cjs/react/transports/vercel.d.ts +30 -0
- package/dist/cjs/react/transports/vercel.js +69 -0
- package/dist/cjs/react/types.d.ts +760 -0
- package/dist/cjs/react/types.js +2 -0
- package/dist/cjs/react/ui.d.ts +73 -0
- package/dist/cjs/react/ui.js +183 -0
- package/dist/cjs/react/utils/create-approval-description.d.ts +53 -0
- package/dist/cjs/react/utils/create-approval-description.js +122 -0
- package/dist/cjs/react/utils/create-tool-result-handler.d.ts +90 -0
- package/dist/cjs/react/utils/create-tool-result-handler.js +168 -0
- package/dist/cjs/react/utils/mention-markup.d.ts +13 -0
- package/dist/cjs/react/utils/mention-markup.js +117 -0
- package/dist/cjs/react/utils/merge-pipeline-steps.d.ts +19 -0
- package/dist/cjs/react/utils/merge-pipeline-steps.js +81 -0
- package/dist/cjs/react/utils/sanitize-stored-messages.d.ts +23 -0
- package/dist/cjs/react/utils/sanitize-stored-messages.js +52 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +10 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +42 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +32 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +4 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +11 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +80 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +119 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +13 -0
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +131 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +7 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +52 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +19 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +108 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +8 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +59 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +3 -0
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +3 -0
- package/dist/cjs/server/adapters/nestjs/chat/index.js +9 -0
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +4 -0
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +73 -0
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +72 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +6 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +13 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +5 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +15 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +6 -0
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +22 -0
- package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +4 -0
- package/dist/cjs/server/adapters/nestjs/decorators/constants.js +7 -0
- package/dist/cjs/server/adapters/nestjs/index.d.ts +14 -0
- package/dist/cjs/server/adapters/nestjs/index.js +42 -0
- package/dist/cjs/server/adapters/nestjs/metadata.d.ts +39 -0
- package/dist/cjs/server/adapters/nestjs/metadata.js +36 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +36 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +159 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +37 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +44 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +28 -0
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +41 -0
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +16 -0
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +117 -0
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +26 -0
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +259 -0
- package/dist/cjs/server/adapters/nestjs/swagger.d.ts +7 -0
- package/dist/cjs/server/adapters/nestjs/swagger.js +39 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +22 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.js +60 -0
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +94 -0
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +965 -0
- package/dist/cjs/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
- package/dist/cjs/server/adapters/nextjs/filter-fallback-error.js +41 -0
- package/dist/cjs/server/adapters/nextjs/index.d.ts +8 -0
- package/dist/cjs/server/adapters/nextjs/index.js +22 -0
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +58 -0
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +114 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.d.ts +64 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +489 -0
- package/dist/cjs/server/adapters/nextjs/server-action-helper.d.ts +7 -0
- package/dist/cjs/server/adapters/nextjs/server-action-helper.js +40 -0
- package/dist/cjs/server/adapters/nextjs/types.d.ts +246 -0
- package/dist/cjs/server/adapters/nextjs/types.js +2 -0
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +9 -0
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.js +12 -0
- package/dist/cjs/server/core/followup-tool.d.ts +9 -0
- package/dist/cjs/server/core/followup-tool.js +82 -0
- package/dist/cjs/server/core/index.d.ts +139 -0
- package/dist/cjs/server/core/index.js +818 -0
- package/dist/cjs/server/core/intent-classifier.d.ts +94 -0
- package/dist/cjs/server/core/intent-classifier.js +324 -0
- package/dist/cjs/server/core/model-selector.d.ts +12 -0
- package/dist/cjs/server/core/model-selector.js +48 -0
- package/dist/cjs/server/core/module-router.d.ts +14 -0
- package/dist/cjs/server/core/module-router.js +110 -0
- package/dist/cjs/server/core/zod-compact.d.ts +18 -0
- package/dist/cjs/server/core/zod-compact.js +129 -0
- package/dist/cjs/server/index.d.ts +6 -0
- package/dist/cjs/server/index.js +28 -0
- package/dist/cjs/server/lancer/cache.d.ts +9 -0
- package/dist/cjs/server/lancer/cache.js +33 -0
- package/dist/cjs/server/lancer/client.d.ts +2 -0
- package/dist/cjs/server/lancer/client.js +279 -0
- package/dist/cjs/server/lancer/errors.d.ts +13 -0
- package/dist/cjs/server/lancer/errors.js +21 -0
- package/dist/cjs/server/lancer/index.d.ts +3 -0
- package/dist/cjs/server/lancer/index.js +7 -0
- package/dist/cjs/server/lancer/telemetry-buffer.d.ts +15 -0
- package/dist/cjs/server/lancer/telemetry-buffer.js +64 -0
- package/dist/cjs/server/lancer/types.d.ts +201 -0
- package/dist/cjs/server/lancer/types.js +5 -0
- package/dist/cjs/server/pii-shield/aegis-detector.d.ts +26 -0
- package/dist/cjs/server/pii-shield/aegis-detector.js +26 -0
- package/dist/cjs/server/pii-shield/create-pii-shield.d.ts +2 -0
- package/dist/cjs/server/pii-shield/create-pii-shield.js +191 -0
- package/dist/cjs/server/pii-shield/deep-walk.d.ts +1 -0
- package/dist/cjs/server/pii-shield/deep-walk.js +19 -0
- package/dist/cjs/server/pii-shield/fake-data.d.ts +5 -0
- package/dist/cjs/server/pii-shield/fake-data.js +170 -0
- package/dist/cjs/server/pii-shield/index.d.ts +4 -0
- package/dist/cjs/server/pii-shield/index.js +9 -0
- package/dist/cjs/server/pii-shield/leakage.d.ts +1 -0
- package/dist/cjs/server/pii-shield/leakage.js +15 -0
- package/dist/cjs/server/pii-shield/session-mapping.d.ts +12 -0
- package/dist/cjs/server/pii-shield/session-mapping.js +70 -0
- package/dist/cjs/server/pipeline.d.ts +26 -0
- package/dist/cjs/server/pipeline.js +127 -0
- package/dist/cjs/server/testing/approvals.d.ts +11 -0
- package/dist/cjs/server/testing/approvals.js +41 -0
- package/dist/cjs/server/testing/combination.d.ts +3 -0
- package/dist/cjs/server/testing/combination.js +83 -0
- package/dist/cjs/server/testing/create-test-suite.d.ts +29 -0
- package/dist/cjs/server/testing/create-test-suite.js +81 -0
- package/dist/cjs/server/testing/edge-cases.d.ts +8 -0
- package/dist/cjs/server/testing/edge-cases.js +277 -0
- package/dist/cjs/server/testing/guardrails.d.ts +14 -0
- package/dist/cjs/server/testing/guardrails.js +152 -0
- package/dist/cjs/server/testing/helpers.d.ts +14 -0
- package/dist/cjs/server/testing/helpers.js +119 -0
- package/dist/cjs/server/testing/index.d.ts +12 -0
- package/dist/cjs/server/testing/index.js +37 -0
- package/dist/cjs/server/testing/mock-executor.d.ts +8 -0
- package/dist/cjs/server/testing/mock-executor.js +40 -0
- package/dist/cjs/server/testing/regression.d.ts +7 -0
- package/dist/cjs/server/testing/regression.js +27 -0
- package/dist/cjs/server/testing/routing.d.ts +12 -0
- package/dist/cjs/server/testing/routing.js +63 -0
- package/dist/cjs/server/testing/schema-consistency.d.ts +6 -0
- package/dist/cjs/server/testing/schema-consistency.js +56 -0
- package/dist/cjs/server/testing/smoke.d.ts +11 -0
- package/dist/cjs/server/testing/smoke.js +64 -0
- package/dist/cjs/server/testing/types.d.ts +156 -0
- package/dist/cjs/server/testing/types.js +2 -0
- package/dist/cjs/types.d.ts +696 -0
- package/dist/cjs/types.js +91 -0
- package/dist/cli/commands/install-skills.d.ts +17 -0
- package/dist/cli/commands/install-skills.js +185 -0
- package/dist/cli/commands/install-skills.js.map +1 -0
- package/dist/cli/index.js +25 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/react/components/ai-trigger-button.js +4 -6
- package/dist/react/components/ai-trigger-button.js.map +1 -1
- package/dist/react/components/recording-bar.js +4 -6
- package/dist/react/components/recording-bar.js.map +1 -1
- package/dist/react/components/wavesurfer-loader.d.ts +5 -0
- package/dist/react/components/wavesurfer-loader.js +34 -0
- package/dist/react/components/wavesurfer-loader.js.map +1 -0
- package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +1 -1
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js +3 -2
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +1 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +1 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +10 -8
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +1 -1
- package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
- package/dist/server/adapters/nestjs/chat/ws-loader.js +37 -0
- package/dist/server/adapters/nestjs/chat/ws-loader.js.map +1 -0
- package/openapi/package.json +5 -0
- package/package.json +59 -16
- package/react/langgraph/package.json +5 -0
- package/react/package.json +5 -0
- package/react/vercel/package.json +5 -0
- package/server/nestjs/package.json +5 -0
- package/server/nextjs/package.json +5 -0
- package/server/package.json +5 -0
- package/server/testing/package.json +5 -0
- package/skills/README.md +107 -0
- package/skills/building-glirastes-chat-ui/SKILL.md +378 -0
- package/skills/integrating-glirastes-nestjs/SKILL.md +346 -0
- package/skills/integrating-glirastes-nextjs/SKILL.md +306 -0
- package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
- package/skills/maintaining-glirastes-tools/SKILL.md +463 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recommendOutputFormat = recommendOutputFormat;
|
|
4
|
+
/**
|
|
5
|
+
* Recommend the best output format (skill, mcp, or both) based on
|
|
6
|
+
* the project's auth strategy, transport needs, and tool count.
|
|
7
|
+
*
|
|
8
|
+
* - OAuth2 → MCP (needs persistent token management)
|
|
9
|
+
* - Streaming/WebSocket → MCP (needs persistent connection)
|
|
10
|
+
* - Multi-agent → MCP (shared server benefits)
|
|
11
|
+
* - Many tools (>20) → both (MCP for power users, skill for simple use)
|
|
12
|
+
* - Default → skill (simpler, no server process needed)
|
|
13
|
+
*/
|
|
14
|
+
function recommendOutputFormat(input) {
|
|
15
|
+
// OAuth2 → MCP (needs persistent auth state)
|
|
16
|
+
if (input.auth.type === 'oauth2') {
|
|
17
|
+
return { format: 'mcp', reason: 'OAuth2 requires persistent token management — MCP server handles refresh automatically' };
|
|
18
|
+
}
|
|
19
|
+
// Streaming/WebSocket → MCP
|
|
20
|
+
if (input.hasStreaming || input.hasWebSocket) {
|
|
21
|
+
return { format: 'mcp', reason: 'Streaming/WebSocket needs a persistent connection — MCP server is ideal' };
|
|
22
|
+
}
|
|
23
|
+
// Multi-agent → MCP
|
|
24
|
+
if (input.multiAgentAccess) {
|
|
25
|
+
return { format: 'mcp', reason: 'Multiple agents benefit from a shared MCP server instance' };
|
|
26
|
+
}
|
|
27
|
+
// Many tools → both (MCP for power users, skill for simple use)
|
|
28
|
+
if (input.toolCount && input.toolCount > 20) {
|
|
29
|
+
return { format: 'both', reason: 'Large tool count benefits from both formats — skill for quick setup, MCP for full access' };
|
|
30
|
+
}
|
|
31
|
+
// Default: skill (simpler)
|
|
32
|
+
return { format: 'skill', reason: 'Simple REST API with standard auth works well as a skill file' };
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface ScaffoldOptions {
|
|
2
|
+
/** Path to the route.ts file to scaffold from */
|
|
3
|
+
routeFile: string;
|
|
4
|
+
/** Root directory of the project */
|
|
5
|
+
rootDir: string;
|
|
6
|
+
/** File name for the tool file (default: 'ai-tool.ts') */
|
|
7
|
+
toolFileName?: string;
|
|
8
|
+
/** Overwrite existing file (default: false) */
|
|
9
|
+
force?: boolean;
|
|
10
|
+
/** Dry run — print output without writing */
|
|
11
|
+
dryRun?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ScaffoldResult {
|
|
14
|
+
code: string;
|
|
15
|
+
outputPath: string;
|
|
16
|
+
analysis: {
|
|
17
|
+
routeFile: string;
|
|
18
|
+
apiPath: string;
|
|
19
|
+
methods: string[];
|
|
20
|
+
module: string;
|
|
21
|
+
pathParams: string[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generate an ai-tool.ts scaffold from a route.ts file.
|
|
26
|
+
* Returns a structured result with code, output path, and analysis metadata.
|
|
27
|
+
*/
|
|
28
|
+
export declare function scaffoldAiTool(options: ScaffoldOptions): Promise<ScaffoldResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Format a scaffold result as a rich, color-coded human-readable string.
|
|
31
|
+
*/
|
|
32
|
+
export declare function formatScaffoldResult(result: ScaffoldResult, options?: {
|
|
33
|
+
dryRun?: boolean;
|
|
34
|
+
rootDir?: string;
|
|
35
|
+
}): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scaffoldAiTool = scaffoldAiTool;
|
|
4
|
+
exports.formatScaffoldResult = formatScaffoldResult;
|
|
5
|
+
const promises_1 = require("node:fs/promises");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const fs_utils_js_1 = require("./fs-utils.js");
|
|
8
|
+
const format_js_1 = require("./format.js");
|
|
9
|
+
/**
|
|
10
|
+
* Analyze a route.ts file to extract HTTP methods, parameters, and body fields.
|
|
11
|
+
*/
|
|
12
|
+
async function analyzeRoute(routeFile, rootDir) {
|
|
13
|
+
const content = await (0, fs_utils_js_1.readFileSafe)(routeFile);
|
|
14
|
+
if (!content)
|
|
15
|
+
throw new Error(`File not found: ${routeFile}`);
|
|
16
|
+
// Extract exported HTTP methods
|
|
17
|
+
const methods = [];
|
|
18
|
+
for (const method of ['GET', 'POST', 'PATCH', 'PUT', 'DELETE']) {
|
|
19
|
+
if (new RegExp(`export\\s+(?:async\\s+)?function\\s+${method}\\b`).test(content)) {
|
|
20
|
+
methods.push(method);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Extract path params from directory structure
|
|
24
|
+
const routeDir = (0, node_path_1.dirname)(routeFile);
|
|
25
|
+
const rel = (0, node_path_1.relative)(rootDir, routeDir);
|
|
26
|
+
const segments = rel.split(node_path_1.sep);
|
|
27
|
+
const pathParams = [];
|
|
28
|
+
const apiSegments = [];
|
|
29
|
+
let inApi = false;
|
|
30
|
+
for (const seg of segments) {
|
|
31
|
+
if (seg === 'api') {
|
|
32
|
+
inApi = true;
|
|
33
|
+
apiSegments.push(seg);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!inApi)
|
|
37
|
+
continue;
|
|
38
|
+
const paramMatch = seg.match(/^\[(\w+)\]$/);
|
|
39
|
+
if (paramMatch) {
|
|
40
|
+
pathParams.push(paramMatch[1]);
|
|
41
|
+
apiSegments.push(`:${paramMatch[1]}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
apiSegments.push(seg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const apiPath = '/' + apiSegments.join('/');
|
|
48
|
+
// Extract body fields (from request.json() destructuring)
|
|
49
|
+
const bodyFields = [];
|
|
50
|
+
const bodyMatch = content.match(/(?:const|let)\s*\{([^}]+)\}\s*=\s*(?:await\s+)?(?:request|req)\.json\(\)/);
|
|
51
|
+
if (bodyMatch) {
|
|
52
|
+
const fields = bodyMatch[1].split(',').map((f) => f.trim().split(':')[0].trim());
|
|
53
|
+
bodyFields.push(...fields.filter(Boolean));
|
|
54
|
+
}
|
|
55
|
+
// Extract search params
|
|
56
|
+
const searchParams = [];
|
|
57
|
+
const spMatches = content.matchAll(/searchParams\.get\(\s*['"`](\w+)['"`]\s*\)/g);
|
|
58
|
+
for (const match of spMatches) {
|
|
59
|
+
searchParams.push(match[1]);
|
|
60
|
+
}
|
|
61
|
+
// Check for Zod schema usage
|
|
62
|
+
const hasZodSchema = /z\.object/.test(content);
|
|
63
|
+
return { methods, pathParams, bodyFields, searchParams, hasZodSchema, apiPath };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Derive tool name from API path.
|
|
67
|
+
* e.g., /api/tasks/:id → get_task, /api/tasks → list_tasks
|
|
68
|
+
*/
|
|
69
|
+
function deriveToolName(method, apiPath) {
|
|
70
|
+
const segments = apiPath
|
|
71
|
+
.split('/')
|
|
72
|
+
.filter((s) => s && s !== 'api' && !s.startsWith(':'));
|
|
73
|
+
const resource = segments[segments.length - 1] ?? 'resource';
|
|
74
|
+
const prefixMap = {
|
|
75
|
+
GET: segments.length === 1 ? 'list' : 'get',
|
|
76
|
+
POST: 'create',
|
|
77
|
+
PATCH: 'update',
|
|
78
|
+
PUT: 'update',
|
|
79
|
+
DELETE: 'delete',
|
|
80
|
+
};
|
|
81
|
+
const prefix = prefixMap[method] ?? method.toLowerCase();
|
|
82
|
+
return `${prefix}_${resource}`.replace(/-/g, '_');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Derive tool ID from API path.
|
|
86
|
+
* e.g., /api/tasks/:id → tasks.get
|
|
87
|
+
*/
|
|
88
|
+
function deriveToolId(method, apiPath) {
|
|
89
|
+
const segments = apiPath
|
|
90
|
+
.split('/')
|
|
91
|
+
.filter((s) => s && s !== 'api' && !s.startsWith(':'));
|
|
92
|
+
const actionMap = {
|
|
93
|
+
GET: segments.length === 1 ? 'list' : 'get',
|
|
94
|
+
POST: 'create',
|
|
95
|
+
PATCH: 'update',
|
|
96
|
+
PUT: 'update',
|
|
97
|
+
DELETE: 'delete',
|
|
98
|
+
};
|
|
99
|
+
const action = actionMap[method] ?? method.toLowerCase();
|
|
100
|
+
return `${segments.join('.')}.${action}`;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Suggest module type based on API path patterns.
|
|
104
|
+
*/
|
|
105
|
+
function suggestModule(method, apiPath) {
|
|
106
|
+
const path = apiPath.toLowerCase();
|
|
107
|
+
if (path.includes('/calendar') || path.includes('/events'))
|
|
108
|
+
return 'calendar';
|
|
109
|
+
if (path.includes('/group') || path.includes('/user') || path.includes('/member'))
|
|
110
|
+
return 'group_management';
|
|
111
|
+
if (path.includes('/task') || path.includes('/todo')) {
|
|
112
|
+
return method === 'GET' ? 'task_query' : 'task_mutation';
|
|
113
|
+
}
|
|
114
|
+
return method === 'GET' ? 'task_query' : 'task_mutation';
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Build Zod input schema code from extracted parameters.
|
|
118
|
+
*/
|
|
119
|
+
function buildInputSchemaCode(pathParams, bodyFields, searchParams, method) {
|
|
120
|
+
const fields = [];
|
|
121
|
+
for (const param of pathParams) {
|
|
122
|
+
fields.push(` ${param}: z.string().uuid(), // path parameter`);
|
|
123
|
+
}
|
|
124
|
+
if (method === 'GET' || method === 'DELETE') {
|
|
125
|
+
for (const param of searchParams) {
|
|
126
|
+
fields.push(` ${param}: z.string().optional(), // search param`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
for (const field of bodyFields) {
|
|
131
|
+
fields.push(` ${field}: z.string(), // TODO: adjust type`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (fields.length === 0) {
|
|
135
|
+
return 'z.object({})';
|
|
136
|
+
}
|
|
137
|
+
return `z.object({\n${fields.join('\n')}\n })`;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Generate an ai-tool.ts scaffold from a route.ts file.
|
|
141
|
+
* Returns a structured result with code, output path, and analysis metadata.
|
|
142
|
+
*/
|
|
143
|
+
async function scaffoldAiTool(options) {
|
|
144
|
+
const toolFileName = options.toolFileName ?? 'ai-tool.ts';
|
|
145
|
+
const analysis = await analyzeRoute(options.routeFile, options.rootDir);
|
|
146
|
+
if (analysis.methods.length === 0) {
|
|
147
|
+
throw new Error(`No exported HTTP methods found in ${options.routeFile}`);
|
|
148
|
+
}
|
|
149
|
+
const toolDir = (0, node_path_1.dirname)(options.routeFile);
|
|
150
|
+
const outputPath = (0, node_path_1.join)(toolDir, toolFileName);
|
|
151
|
+
// Check if file already exists
|
|
152
|
+
if (!options.force && !options.dryRun) {
|
|
153
|
+
try {
|
|
154
|
+
await (0, promises_1.stat)(outputPath);
|
|
155
|
+
throw new Error(`${toolFileName} already exists at ${outputPath}. Use --force to overwrite.`);
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
if (e.code !== 'ENOENT')
|
|
159
|
+
throw e;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Determine module (use first method's suggestion as primary)
|
|
163
|
+
const primaryModule = suggestModule(analysis.methods[0], analysis.apiPath);
|
|
164
|
+
// Generate tool definitions
|
|
165
|
+
const tools = [];
|
|
166
|
+
for (const method of analysis.methods) {
|
|
167
|
+
const toolName = deriveToolName(method, analysis.apiPath);
|
|
168
|
+
const toolId = deriveToolId(method, analysis.apiPath);
|
|
169
|
+
const module = suggestModule(method, analysis.apiPath);
|
|
170
|
+
const isMutating = method !== 'GET';
|
|
171
|
+
const inputSchema = buildInputSchemaCode(analysis.pathParams, analysis.bodyFields, analysis.searchParams, method);
|
|
172
|
+
// Suggest uiAction
|
|
173
|
+
let uiActionLine = '';
|
|
174
|
+
if (isMutating) {
|
|
175
|
+
const entity = analysis.apiPath
|
|
176
|
+
.split('/')
|
|
177
|
+
.filter((s) => s && s !== 'api' && !s.startsWith(':'))[0] ?? 'entity';
|
|
178
|
+
const action = method === 'POST'
|
|
179
|
+
? 'created'
|
|
180
|
+
: method === 'DELETE'
|
|
181
|
+
? 'deleted'
|
|
182
|
+
: 'updated';
|
|
183
|
+
if (analysis.pathParams.length > 0) {
|
|
184
|
+
uiActionLine = ` uiActionOnSuccess: { type: '${entity.replace(/s$/, '')}-${action}', ${entity.replace(/s$/, '')}Id: '$${analysis.pathParams[0]}' },`;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
uiActionLine = ` uiActionOnSuccess: { type: '${entity.replace(/s$/, '')}-${action}', ${entity.replace(/s$/, '')}Id: '$id' },`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
tools.push(`defineEndpointTool({
|
|
191
|
+
id: '${toolId}',
|
|
192
|
+
toolName: '${toolName}',
|
|
193
|
+
module: '${module}',
|
|
194
|
+
// sharedWith: [], // TODO: add shared modules if needed
|
|
195
|
+
description: '${toolName.replace(/_/g, ' ')}. TODO: write a clear description for the AI.',
|
|
196
|
+
method: '${method}',
|
|
197
|
+
path: '${analysis.apiPath}',
|
|
198
|
+
inputSchema: ${inputSchema},
|
|
199
|
+
// allowedRoles: ['admin', 'user'], // Optional: specify roles, or omit to allow all roles
|
|
200
|
+
${isMutating ? 'needsApproval: true,' : ''}
|
|
201
|
+
${uiActionLine ? uiActionLine : ' // uiActionOnSuccess: { type: \'...\' },'}
|
|
202
|
+
})`);
|
|
203
|
+
}
|
|
204
|
+
// Build file content
|
|
205
|
+
const isSingle = tools.length === 1;
|
|
206
|
+
const exportLine = isSingle
|
|
207
|
+
? `export const aiTool = ${tools[0]};`
|
|
208
|
+
: `export const aiTools = [\n${tools.map((t) => ` ${t}`).join(',\n')},\n];`;
|
|
209
|
+
const code = `import { z } from 'zod';
|
|
210
|
+
import { defineEndpointTool } from 'glirastes';
|
|
211
|
+
|
|
212
|
+
${exportLine}
|
|
213
|
+
`;
|
|
214
|
+
if (!options.dryRun) {
|
|
215
|
+
await (0, promises_1.writeFile)(outputPath, code, 'utf-8');
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
code,
|
|
219
|
+
outputPath,
|
|
220
|
+
analysis: {
|
|
221
|
+
routeFile: options.routeFile,
|
|
222
|
+
apiPath: analysis.apiPath,
|
|
223
|
+
methods: analysis.methods,
|
|
224
|
+
module: primaryModule,
|
|
225
|
+
pathParams: analysis.pathParams,
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Format a scaffold result as a rich, color-coded human-readable string.
|
|
231
|
+
*/
|
|
232
|
+
function formatScaffoldResult(result, options) {
|
|
233
|
+
const lines = [];
|
|
234
|
+
const rootDir = options?.rootDir ?? process.cwd();
|
|
235
|
+
const relRoute = (0, node_path_1.relative)(rootDir, result.analysis.routeFile);
|
|
236
|
+
const relOutput = (0, node_path_1.relative)(rootDir, result.outputPath);
|
|
237
|
+
// Header
|
|
238
|
+
lines.push((0, format_js_1.header)('Scaffold AI Tool'));
|
|
239
|
+
// Analysis summary
|
|
240
|
+
lines.push(` ${format_js_1.colors.dim}Route:${format_js_1.colors.reset} ${relRoute}`);
|
|
241
|
+
lines.push(` ${format_js_1.colors.dim}Path:${format_js_1.colors.reset} ${result.analysis.apiPath}`);
|
|
242
|
+
lines.push(` ${format_js_1.colors.dim}Methods:${format_js_1.colors.reset} ${result.analysis.methods.join(', ')}`);
|
|
243
|
+
lines.push(` ${format_js_1.colors.dim}Module:${format_js_1.colors.reset} ${result.analysis.module}`);
|
|
244
|
+
if (result.analysis.pathParams.length > 0) {
|
|
245
|
+
lines.push(` ${format_js_1.colors.dim}Params:${format_js_1.colors.reset} ${result.analysis.pathParams.join(', ')}`);
|
|
246
|
+
}
|
|
247
|
+
lines.push('');
|
|
248
|
+
if (options?.dryRun) {
|
|
249
|
+
lines.push(`${format_js_1.colors.yellow}${format_js_1.colors.bold}--- Dry Run (not writing) ---${format_js_1.colors.reset}\n`);
|
|
250
|
+
lines.push(result.code);
|
|
251
|
+
lines.push(`${format_js_1.colors.yellow}${format_js_1.colors.bold}--- End Dry Run ---${format_js_1.colors.reset}`);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
lines.push(`${format_js_1.colors.green}${format_js_1.colors.bold}\u2705 Created:${format_js_1.colors.reset} ${relOutput}`);
|
|
255
|
+
lines.push('');
|
|
256
|
+
lines.push(`${format_js_1.colors.dim}Next steps:${format_js_1.colors.reset}`);
|
|
257
|
+
lines.push(` 1. Edit ${relOutput} \u2014 fill in TODO placeholders`);
|
|
258
|
+
lines.push(` 2. Run ${format_js_1.colors.cyan}glirastes generate-tools${format_js_1.colors.reset} to register`);
|
|
259
|
+
}
|
|
260
|
+
lines.push('');
|
|
261
|
+
return lines.join('\n');
|
|
262
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GenerateOptions } from './types.js';
|
|
2
|
+
import type { AgentSkillConfig } from '../types.js';
|
|
3
|
+
export interface GenerateSkillsOptions extends GenerateOptions {
|
|
4
|
+
/** Skill configuration (app name, base URL, auth) */
|
|
5
|
+
skillConfig: AgentSkillConfig;
|
|
6
|
+
/** Output format(s) to generate */
|
|
7
|
+
formats?: Array<'markdown' | 'json'>;
|
|
8
|
+
/** Custom output directory for skill files (default: .claude/skills/generated/) */
|
|
9
|
+
skillOutputDir?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface GenerateSkillsResult {
|
|
12
|
+
markdownPath?: string;
|
|
13
|
+
/** Paths of all generated markdown files (modular output) */
|
|
14
|
+
markdownPaths?: string[];
|
|
15
|
+
jsonPath?: string;
|
|
16
|
+
toolCount: number;
|
|
17
|
+
moduleCount: number;
|
|
18
|
+
/** Full extracted tool metadata for syncing to Glirastes */
|
|
19
|
+
tools: Array<{
|
|
20
|
+
toolName: string;
|
|
21
|
+
description: string;
|
|
22
|
+
method: string;
|
|
23
|
+
path: string;
|
|
24
|
+
module?: string;
|
|
25
|
+
allowedRoles?: string[];
|
|
26
|
+
needsApproval?: boolean;
|
|
27
|
+
inputFields: Array<{
|
|
28
|
+
name: string;
|
|
29
|
+
type: string;
|
|
30
|
+
required: boolean;
|
|
31
|
+
description?: string;
|
|
32
|
+
}>;
|
|
33
|
+
outputFields: Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
}>;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate agent skill files from discovered tool definitions.
|
|
41
|
+
*
|
|
42
|
+
* Scans the project for endpoint and UI tool definitions and produces:
|
|
43
|
+
* - Modular Markdown skill files (one router SKILL.md + one file per module)
|
|
44
|
+
* - A JSON manifest (machine-readable for Codex / Agent SDK)
|
|
45
|
+
*
|
|
46
|
+
* Both formats contain the full tool catalog with auth instructions,
|
|
47
|
+
* enabling autonomous agents to interact with the platform API.
|
|
48
|
+
*/
|
|
49
|
+
export declare function generateAgentSkills(options: GenerateSkillsOptions): Promise<GenerateSkillsResult>;
|