@xopcai/xopc 0.0.174 → 0.0.176
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/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-CyEDJeIt.js → activity-store-DsFM1upC.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DF7Bol6I.js → agent-avatar-dicebear-DvdMLOga.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BVjlpbeZ.js +2 -0
- package/dist/gateway/static/root/assets/{api-DYunqroX.js → api-BdPLCCBm.js} +1 -1
- package/dist/gateway/static/root/assets/{api-DwyUxpgY.js → api-Bop4IQRW.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B4xJyvDu.js → app-management-settings-panel-DMLDOHul.js} +1 -1
- package/dist/gateway/static/root/assets/appearance-settings-DbI9foFR.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-njqxLWYD.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DWhBmmjD.js → archive-plugin-Dfdxuwvb.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BOpZfa_I.js → attachment-load-Dn3RlnYD.js} +2 -2
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-DonnL2dL.js → attachment-preview-renderer-Cmo-5BP5.js} +2 -2
- package/dist/gateway/static/root/assets/{attachment-process-heavy-RnGYy9bC.js → attachment-process-heavy-B2_kr5EA.js} +3 -3
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Byu3I7Rs.js → automation-suggestion-card-Bc0Y7A9u.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-D-eweHZJ.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-6AG1qatz.js → binary-plugins-0XtB-xC0.js} +2 -2
- package/dist/gateway/static/root/assets/{block-editor-CJhrn98_.js → block-editor-C4fXWbEE.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-lC86-drr.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CBVb4mt9.js → browser-workflow-inputs-CZmzNymN.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Cq4XUKbu.js → browser-workflows-page-CBYM9HqG.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6tYNfHqJ.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-hbW4NAKO.js → capability-presets-api-BiJxmmhW.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co-ymbd9.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CzMjHb17.js → channel-recipient-api-BKTUZDp-.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-D46eVjaQ.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-BMRAO4zZ.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-B9Au6gMZ.js → connector-logo-Pr4RIKjj.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-Dw1eYbRi.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-B8cZuQUt.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CNff5TFb.js → desktop-pet-settings-CEQacUDF.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Bf956uo-.js → directory-picker-path-field-DWnxdZtc.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CHM8FE1g.js → dreaming-settings-D2e2w2Ho.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-ZqM_0eUs.js → extension-debug-page-BLjTGbv3.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D4hvXOMM.js → extension-page-D2_UC6hy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-GsqxaJjA.js → extension-settings-page-BsH6o_PX.js} +1 -1
- package/dist/gateway/static/root/assets/{focus-detail-page-CE6uwrl1.js → focus-detail-page-BBXUtxRB.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-B4THmgnS.js → gateway-config-api-C-DkC6UJ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CPv-MxGE.js → gateway-settings-DEOGiimF.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-MP3K71pP.js → gateway-startup-retry-BlSLh1TF.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CSFcRE_N.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-VjRArfAJ.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-DCcDuIjG.js → goals-config-api-CcdS9qek.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BAcErdch.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-o9QMXvNq.js → goals-settings-BY7crl0z.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DixwpXnH.js → heartbeat-settings-DtTkS0gs.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-BOGH9FGi.js → image-generation-api-WGgkbwDZ.js} +1 -1
- package/dist/gateway/static/root/assets/index-2UImfRDC.js +212 -0
- package/dist/gateway/static/root/assets/index-CS9sVShT.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D4o4ZPF6.js → keyboard-shortcuts-settings-C5lpWQ3f.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Cl0fcPL4.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-GzMmpO7G.js → local-apps-page-b05wWvXG.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CAuhEGCn.js → locale-store-sToMfHX_.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-cDE1jLJv.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-CIX8D1pv.js → markdown-split-0gPVst5y.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bp3eIA45.js → media-plugins-Rxyq_KTm.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CarlxqXV.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-RVFiYAoO.js → notes-page-DRhNDl_Q.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-BKNBk0Uf.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-BGAYH3Ef.js → page-tabs-cOEOQqHh.js} +1 -1
- package/dist/gateway/static/root/assets/pdf-D4PI9qAw.js +54 -0
- package/dist/gateway/static/root/assets/pdf.worker.min-CHFwMXne.mjs +29 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BM6pDkHp.js → preview-open-alternatives-BopOLFvu.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BiMetEmn.js → product-open-page-DWVPmmOq.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BhjEXNQW.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B80e69PH.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CwdVob6H.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BdjV8MK5.js → save-bar-controls-BfZmKe1t.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-ChlqXU46.js → schedule-field-Cpi4jCRV.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DDKf5ZSH.js → schema-form-OXFkcZQe.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BGt3Asj6.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BnTdM9Nn.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CPG0KGVs.js → settings-form-section-BwqkZCHJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-DRSDHucM.js → settings-loading-skeleton-BbqH_S3Y.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CeB7_xD0.js → settings-page-BoxC-JSa.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-BENrkwd0.js → settings-page-layout-Ddu2iGaW.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-z1Lwv0js.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DIzczJkG.js → share-preview-page-CVazOFjy.js} +2 -2
- package/dist/gateway/static/root/assets/shares-settings-C4lXuyQj.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-DSuIDkeI.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-xgZczqVe.js +2 -0
- package/dist/gateway/static/root/assets/skills-page.utils-DgyB1tSo.js +1 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Dp4d5Q1B.js → system-settings-panel-BoLSQL65.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CbGc1laW.js → theme-store-CBNcGOfj.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-gochWrny.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-DwPk3OPL.js → typed-models-lib-DvRnr7YB.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CXrEu2dw.js → use-channel-catalog-CA9BFVB7.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-CEfIy4WZ.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DFoA79LB.js → voice-api-key-field-v8tgylEZ.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-B-3MClaf.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CEsFEdax.js +1 -0
- package/dist/gateway/static/root/assets/work-page-CT9AHnq6.js +3 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CC3cJn5k.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-C-1-_Zp1.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +8 -8
- package/dist/src/agent/context/execution-scope.d.ts +26 -0
- package/dist/src/agent/context/execution-scope.js +84 -0
- package/dist/src/agent/context/project-context.d.ts +3 -1
- package/dist/src/agent/context/project-context.js +26 -8
- package/dist/src/agent/embedded/model-runtime.d.ts +1 -2
- package/dist/src/agent/embedded/model-runtime.js +17 -29
- package/dist/src/agent/embedded/session-runner.js +2 -3
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +1 -0
- package/dist/src/agent/prompt/system-prompt.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +7 -4
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/session/session-config-service.d.ts +4 -1
- package/dist/src/agent/session/session-config-service.js +5 -3
- package/dist/src/agent/session/session-inspector.d.ts +6 -0
- package/dist/src/agent/session/session-inspector.js +9 -2
- package/dist/src/agent/skills/hub-pull.js +1 -1
- package/dist/src/agent/skills/index.d.ts +2 -0
- package/dist/src/agent/skills/index.js +14 -5
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/test-framework.js +1 -1
- package/dist/src/agent/workflow/subagent-runner.js +2 -0
- package/dist/src/agent/workflow/types.d.ts +1 -0
- package/dist/src/auth/model-credential-store.d.ts +17 -0
- package/dist/src/auth/model-credential-store.js +110 -0
- package/dist/src/auth/oauth/github-copilot.js +2 -2
- package/dist/src/auth/oauth/openai-codex.js +98 -7
- package/dist/src/auth/oauth/types.d.ts +4 -1
- package/dist/src/auth/oauth/xopc-cloud.js +124 -6
- package/dist/src/automations/domain/defaults.d.ts +1 -0
- package/dist/src/automations/domain/defaults.js +4 -0
- package/dist/src/automations/domain/index.d.ts +1 -0
- package/dist/src/automations/domain/index.js +2 -1
- package/dist/src/automations/index.js +2 -1
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/skills.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/schema.d.ts +21 -0
- package/dist/src/config/schema.js +12 -2
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -0
- package/dist/src/gateway/hono/oauth-async.d.ts +5 -0
- package/dist/src/gateway/hono/oauth-async.js +20 -8
- package/dist/src/gateway/hono/routes/config-patch/gateway.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/gateway.js +9 -0
- package/dist/src/gateway/hono/routes/goals.js +13 -0
- package/dist/src/gateway/hono/routes/home.d.ts +16 -3
- package/dist/src/gateway/hono/routes/home.js +98 -25
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/project-skills.d.ts +3 -0
- package/dist/src/gateway/hono/routes/project-skills.js +119 -0
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +2 -1
- package/dist/src/gateway/service.js +5 -5
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/projects/index.d.ts +1 -0
- package/dist/src/projects/index.js +2 -1
- package/dist/src/projects/project-skill-service.d.ts +67 -0
- package/dist/src/projects/project-skill-service.js +131 -0
- package/dist/src/providers/index.js +4 -2
- package/dist/src/providers/provider-auth-service.d.ts +22 -0
- package/dist/src/providers/provider-auth-service.js +66 -0
- package/dist/src/providers/register-runtime-providers.d.ts +6 -0
- package/dist/src/providers/register-runtime-providers.js +55 -0
- package/dist/src/providers/xopc-cloud-account-service.d.ts +2 -2
- package/dist/src/providers/xopc-cloud-account-service.js +6 -5
- package/dist/src/providers/xopc-cloud-config.d.ts +3 -0
- package/dist/src/providers/xopc-cloud-config.js +13 -0
- package/dist/src/providers/xopc-cloud-model-source.d.ts +2 -2
- package/dist/src/providers/xopc-cloud-model-source.js +6 -5
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +2 -2
- package/dist/src/session/thinking-resolve.d.ts +8 -0
- package/dist/src/session/thinking-resolve.js +6 -3
- package/dist/src/storage/sqlite/home-attention-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/home-attention-repository.js +21 -0
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/migrations/067_home_attention_acknowledgements.sql +9 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +10 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +2 -2
- package/dist/src/tui/xopc-tui-keybindings.d.ts +44 -4
- package/dist/src/workflows/engine/workflow-engine.d.ts +1 -0
- package/dist/src/workflows/engine/workflow-engine.js +2 -0
- package/dist/src/workflows/service/workflow-run-service.js +11 -5
- package/dist/src/workflows/service/workflow-session-bridge.js +2 -1
- package/package.json +5 -5
- package/dist/gateway/static/root/assets/agents-BVxEFPQ5.js +0 -2
- package/dist/gateway/static/root/assets/appearance-settings-B2PQxRiu.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BtIgd82S.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-CG_SCH5b.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CfLqPWZC.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DCJmm6cR.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CnkAYvWI.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-DtqqFpDn.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-C-5yHbc0.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CaHfs8YF.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CvFMKYdb.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DAeb82xP.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-CwLSp01r.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-DvJQ6_4M.js +0 -2
- package/dist/gateway/static/root/assets/index-CfXiRNN5.css +0 -1
- package/dist/gateway/static/root/assets/index-eyttVNS_.js +0 -212
- package/dist/gateway/static/root/assets/local-app-workbench-page-CPcfqn_A.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-DXABWCZp.js +0 -7
- package/dist/gateway/static/root/assets/messages-BiBdO1-O.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-DgJzZRX3.js +0 -4
- package/dist/gateway/static/root/assets/pdf-epILhEOn.js +0 -54
- package/dist/gateway/static/root/assets/pdf.worker.min-iDqQPrd3.mjs +0 -31
- package/dist/gateway/static/root/assets/project-detail-page-DF7F70Vg.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-Cw3jyi5s.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-ChAJsaNY.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BxZIxt7z.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DcDLS0xV.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-4Xa9NA7v.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BpN0o5Cf.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DvF2UAaL.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CGKXpNfy.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-BhgCeDuO.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Dy_fKAK_.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BWkjb1NK.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DLBNFse5.js +0 -1
- package/dist/gateway/static/root/assets/work-page-Bn5RXMIE.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BuniGPO0.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-_vFhRrAl.js +0 -11
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ProjectSkillError, ProjectSkillService } from "../../../projects/project-skill-service.js";
|
|
2
|
+
import "../../../projects/index.js";
|
|
3
|
+
//#region src/gateway/hono/routes/project-skills.ts
|
|
4
|
+
function projectSkills(deps) {
|
|
5
|
+
return new ProjectSkillService({
|
|
6
|
+
projects: deps.service.projects,
|
|
7
|
+
getConfig: () => deps.service.currentConfig,
|
|
8
|
+
refreshSkills: () => deps.service.agentService.refreshSkillsAfterDiskChange()
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function errorResponse(c, error) {
|
|
12
|
+
if (error instanceof ProjectSkillError) return c.json({
|
|
13
|
+
ok: false,
|
|
14
|
+
code: error.code,
|
|
15
|
+
error: error.message
|
|
16
|
+
}, error.status);
|
|
17
|
+
return c.json({
|
|
18
|
+
ok: false,
|
|
19
|
+
code: "project_skill_operation_failed",
|
|
20
|
+
error: error instanceof Error ? error.message : String(error)
|
|
21
|
+
}, 400);
|
|
22
|
+
}
|
|
23
|
+
function registerProjectSkillRoutes(authenticated, deps) {
|
|
24
|
+
authenticated.get("/api/projects/:projectId/skills", (c) => {
|
|
25
|
+
try {
|
|
26
|
+
return c.json({
|
|
27
|
+
ok: true,
|
|
28
|
+
...projectSkills(deps).list(c.req.param("projectId"))
|
|
29
|
+
});
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return errorResponse(c, error);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
authenticated.get("/api/projects/:projectId/skills/:skillId", (c) => {
|
|
35
|
+
try {
|
|
36
|
+
return c.json({
|
|
37
|
+
ok: true,
|
|
38
|
+
skill: projectSkills(deps).getContent(c.req.param("projectId"), c.req.param("skillId"))
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
return errorResponse(c, error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
authenticated.post("/api/projects/:projectId/skills/upload", async (c) => {
|
|
45
|
+
try {
|
|
46
|
+
const body = await c.req.parseBody();
|
|
47
|
+
const file = body.file;
|
|
48
|
+
if (!(file instanceof File)) return c.json({
|
|
49
|
+
ok: false,
|
|
50
|
+
error: "Skill zip file is required"
|
|
51
|
+
}, 400);
|
|
52
|
+
const skill = await projectSkills(deps).installZip(c.req.param("projectId"), Buffer.from(await file.arrayBuffer()), {
|
|
53
|
+
skillId: typeof body.skillId === "string" ? body.skillId : void 0,
|
|
54
|
+
overwrite: body.overwrite === "true"
|
|
55
|
+
});
|
|
56
|
+
return c.json({
|
|
57
|
+
ok: true,
|
|
58
|
+
skill
|
|
59
|
+
}, 201);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return errorResponse(c, error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
authenticated.post("/api/projects/:projectId/skills/marketplace/install", async (c) => {
|
|
65
|
+
try {
|
|
66
|
+
const body = await c.req.json();
|
|
67
|
+
const name = typeof body.name === "string" ? body.name.trim() : "";
|
|
68
|
+
if (!name) return c.json({
|
|
69
|
+
ok: false,
|
|
70
|
+
error: "Marketplace skill name is required"
|
|
71
|
+
}, 400);
|
|
72
|
+
const skill = await projectSkills(deps).installMarketplace(c.req.param("projectId"), {
|
|
73
|
+
name,
|
|
74
|
+
version: typeof body.version === "string" ? body.version : void 0,
|
|
75
|
+
provider: typeof body.provider === "string" ? body.provider : void 0,
|
|
76
|
+
overwrite: body.overwrite === true
|
|
77
|
+
});
|
|
78
|
+
return c.json({
|
|
79
|
+
ok: true,
|
|
80
|
+
skill
|
|
81
|
+
}, 201);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return errorResponse(c, error);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
authenticated.post("/api/projects/:projectId/skills/source/install", async (c) => {
|
|
87
|
+
try {
|
|
88
|
+
const body = await c.req.json();
|
|
89
|
+
const source = typeof body.source === "string" ? body.source.trim() : "";
|
|
90
|
+
if (!source) return c.json({
|
|
91
|
+
ok: false,
|
|
92
|
+
error: "Skill source is required"
|
|
93
|
+
}, 400);
|
|
94
|
+
const skill = await projectSkills(deps).installSource(c.req.param("projectId"), {
|
|
95
|
+
source,
|
|
96
|
+
skillId: typeof body.skillId === "string" ? body.skillId : void 0,
|
|
97
|
+
ref: typeof body.ref === "string" ? body.ref : void 0,
|
|
98
|
+
subpath: typeof body.subpath === "string" ? body.subpath : void 0,
|
|
99
|
+
force: body.force === true
|
|
100
|
+
});
|
|
101
|
+
return c.json({
|
|
102
|
+
ok: true,
|
|
103
|
+
skill
|
|
104
|
+
}, 201);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return errorResponse(c, error);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
authenticated.delete("/api/projects/:projectId/skills/:skillId", async (c) => {
|
|
110
|
+
try {
|
|
111
|
+
await projectSkills(deps).remove(c.req.param("projectId"), c.req.param("skillId"));
|
|
112
|
+
return c.json({ ok: true });
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return errorResponse(c, error);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { registerProjectSkillRoutes };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PACKAGE_VERSION, init_package_version } from "../../../package-version.js";
|
|
2
2
|
import { loadConfig } from "../../../config/loader.js";
|
|
3
3
|
import "../../../config/index.js";
|
|
4
|
-
import { acquireUpdateLock } from "../../../infra/update-lock.js";
|
|
5
4
|
import { normalizeUpdateChannel } from "../../../infra/update-channels.js";
|
|
5
|
+
import { acquireUpdateLock } from "../../../infra/update-lock.js";
|
|
6
|
+
import { formatUpdateApiResult, runGatewayUpdateWithPostSteps } from "../../../infra/update-runner.js";
|
|
6
7
|
import { getUpdateAvailable, runGatewayUpdateCheck } from "../../../infra/update-startup.js";
|
|
7
8
|
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
8
|
-
import { formatUpdateApiResult, runGatewayUpdateWithPostSteps } from "../../../infra/update-runner.js";
|
|
9
9
|
import { streamSSE } from "hono/streaming";
|
|
10
10
|
//#region src/gateway/hono/routes/update.ts
|
|
11
11
|
init_package_version();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildDefaultCorsOrigins, isAllInterfacesHost, isLoopbackHost, resolveEffectiveGatewayPort, resolveGatewayServiceListenPort } from "./host.js";
|
|
2
2
|
import { defaultGatewayBindMode, isContainerEnvironment, resolveGatewayBindHost, resolveGatewayBindHostSync, resolveGatewayBindMode, resolveGatewayEffectiveHost } from "../config/gateway-bind.js";
|
|
3
|
+
import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofOutput } from "./ports.js";
|
|
3
4
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
4
5
|
import { resolveGatewayListenHost, resolveGatewayListenPlan } from "./listen.js";
|
|
5
6
|
import { buckets } from "./rate-limit/buckets.js";
|
|
@@ -13,7 +14,6 @@ import { createHonoApp } from "./hono/app.js";
|
|
|
13
14
|
import { GatewayServer } from "./server.js";
|
|
14
15
|
import { GatewayLockError, acquireGatewayLock } from "./lock.js";
|
|
15
16
|
import { runGatewayLoop } from "./run-loop.js";
|
|
16
|
-
import { checkPortAvailable, forceFreePortAndWait, listPortListeners, parseLsofOutput } from "./ports.js";
|
|
17
17
|
import { apiError, apiOk } from "./protocol.js";
|
|
18
18
|
import "./hono/index.js";
|
|
19
19
|
import { assertSecureGatewayHttpUrl, assertSecureWebSocketUrl, isInsecurePrivateWsAllowed, isSecureWebSocketUrl } from "./ws-security.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { loadConfig } from "../config/loader.js";
|
|
2
2
|
import "../config/index.js";
|
|
3
3
|
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
4
|
+
import { consumeGatewayRestartIntentSync, consumeGatewaySigusr1RestartAuthorization, isGatewaySigusr1RestartExternallyAllowed, resetGatewayRestartStateForInProcessRestart, scheduleGatewaySigusr1Restart, setGatewaySigusr1RestartPolicy } from "../infra/restart.js";
|
|
4
5
|
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
5
6
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
6
7
|
import { acquireGatewayLock } from "./lock.js";
|
|
7
|
-
import { consumeGatewayRestartIntentSync, consumeGatewaySigusr1RestartAuthorization, isGatewaySigusr1RestartExternallyAllowed, resetGatewayRestartStateForInProcessRestart, scheduleGatewaySigusr1Restart, setGatewaySigusr1RestartPolicy } from "../infra/restart.js";
|
|
8
8
|
//#region src/gateway/run-loop.ts
|
|
9
9
|
/**
|
|
10
10
|
* Gateway Run Loop - Core run loop for gateway process management
|
|
@@ -88,7 +88,8 @@ export declare class GatewaySessionsApi {
|
|
|
88
88
|
patchAgentConfig(sessionKey: string, body: {
|
|
89
89
|
thinkingLevel?: string;
|
|
90
90
|
model?: string | null;
|
|
91
|
-
|
|
91
|
+
activityDetailLevel?: string | null;
|
|
92
|
+
reasoningLevel?: string | null;
|
|
92
93
|
verboseLevel?: string;
|
|
93
94
|
workingDirectory?: string;
|
|
94
95
|
}): Promise<import("../../agent/session/session-config-service.js").PatchSessionAgentConfigResult>;
|
|
@@ -50,6 +50,11 @@ import { FocusService } from "../focuses/service.js";
|
|
|
50
50
|
import { processFocusMonitorRun } from "../focuses/run-processor.js";
|
|
51
51
|
import { startFocusReconciler } from "../focuses/reconciler.js";
|
|
52
52
|
import "../focuses/index.js";
|
|
53
|
+
import { LocalAppService } from "../local-apps/service.js";
|
|
54
|
+
import "../local-apps/index.js";
|
|
55
|
+
import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|
56
|
+
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
57
|
+
import { MobileNotificationService } from "../mobile/notification-service.js";
|
|
53
58
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
54
59
|
import { reconcileDreamingAutomations } from "./dreaming-automation-reconciler.js";
|
|
55
60
|
import { NotesStore } from "../notes/store.js";
|
|
@@ -75,13 +80,8 @@ import "./rate-limit/index.js";
|
|
|
75
80
|
import { assertGatewayRuntimeConfig } from "./runtime-config.js";
|
|
76
81
|
import { auditGatewayConfig } from "./security/audit.js";
|
|
77
82
|
import { ModelCatalogSyncService } from "../providers/model-catalog-sync-service.js";
|
|
78
|
-
import { runBootstrapMigrationsSync } from "../migrations/runner.js";
|
|
79
|
-
import { MobileNotificationService } from "../mobile/notification-service.js";
|
|
80
|
-
import { LocalAppService } from "../local-apps/service.js";
|
|
81
|
-
import "../local-apps/index.js";
|
|
82
83
|
import { createRuntimeBrowserRecipeService } from "../browser/recipes/runtime-service.js";
|
|
83
84
|
import "../browser/recipes/index.js";
|
|
84
|
-
import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|
85
85
|
import { resolveChannelConnectDeferSet } from "./resolve-channel-connect-defer.js";
|
|
86
86
|
import { restartGatewayProcessWithFreshPid } from "./respawn.js";
|
|
87
87
|
import { GatewaySessionsApi } from "./service/sessions-api.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, shouldSilence, stripHeartbeatToken } from "./tokens.js";
|
|
2
|
-
import { appendCronEventLines } from "./event-prompt.js";
|
|
3
2
|
import { isWithinActiveHours } from "./active-hours.js";
|
|
4
3
|
import { isHeartbeatContentEmpty } from "./content-check.js";
|
|
4
|
+
import { appendCronEventLines } from "./event-prompt.js";
|
|
5
5
|
import { createHeartbeatWake } from "./wake.js";
|
|
6
6
|
export { DEFAULT_ACK_MAX_CHARS, HEARTBEAT_OK, NO_REPLY, appendCronEventLines, createHeartbeatWake, isHeartbeatContentEmpty, isWithinActiveHours, shouldSilence, stripHeartbeatToken };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { listPortListeners } from "../gateway/ports.js";
|
|
2
1
|
import { isGatewayArgv, parseProcCmdline } from "./gateway-process-argv.js";
|
|
2
|
+
import { listPortListeners } from "../gateway/ports.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { spawnSync } from "node:child_process";
|
|
5
5
|
//#region src/infra/gateway-processes.ts
|
|
@@ -4,8 +4,8 @@ import { init_paths, resolveConfigPath } from "../config/paths.js";
|
|
|
4
4
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
5
5
|
import { isRestartEnabled } from "../config/commands.flags.js";
|
|
6
6
|
import { resolveGatewayService } from "../daemon/service.js";
|
|
7
|
-
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
8
7
|
import { findVerifiedGatewayListenerPidsOnPortSync, signalVerifiedGatewayPidSync } from "./gateway-processes.js";
|
|
8
|
+
import { authorizeGatewaySigusr1Restart, writeGatewayRestartIntentSync } from "./restart.js";
|
|
9
9
|
import { refreshGatewayServiceAfterUpdate } from "./update-service-refresh.js";
|
|
10
10
|
//#region src/infra/update-restart.ts
|
|
11
11
|
init_loader();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { runPostUpdateExtensionSync } from "../extensions/update.js";
|
|
2
|
-
import "./update-channels.js";
|
|
3
|
-
import { compareSemver, resolveNpmChannelTag } from "./update-check.js";
|
|
4
2
|
import { readPackageName, readPackageVersion } from "./package-json.js";
|
|
5
3
|
import { createDefaultCommandRunner, runCommandWithTimeout } from "./run-command.js";
|
|
6
4
|
import { XOPC_PACKAGE_NAME, cleanupGlobalRenameDirs, createGlobalInstallEnv, detectGlobalInstallManagerForRoot, resolveGlobalInstallSpec, resolveGlobalInstallTarget } from "./update-global.js";
|
|
7
5
|
import { runGlobalPackageUpdateSteps } from "./package-update-steps.js";
|
|
8
6
|
import { resolveStableNodePath } from "./stable-node-path.js";
|
|
7
|
+
import "./update-channels.js";
|
|
8
|
+
import { compareSemver, resolveNpmChannelTag } from "./update-check.js";
|
|
9
9
|
import { trimLogTail } from "./update-log.js";
|
|
10
10
|
import { maybeRestartGatewayAfterUpdate } from "./update-restart.js";
|
|
11
11
|
import path from "node:path";
|
|
@@ -3,9 +3,9 @@ import { init_paths_state, resolveUpdateCheckStatePath } from "../config/paths-s
|
|
|
3
3
|
import { createLogger } from "../utils/logger/index.js";
|
|
4
4
|
import { init_logger } from "../utils/logger.js";
|
|
5
5
|
import { init_write_file_atomic, writeTextAtomic } from "./write-file-atomic.js";
|
|
6
|
-
import { acquireUpdateLock } from "./update-lock.js";
|
|
7
6
|
import { normalizeUpdateChannel } from "./update-channels.js";
|
|
8
7
|
import { compareSemver, detectInstallKind, resolveNpmChannelTag, resolvePackageRoot } from "./update-check.js";
|
|
8
|
+
import { acquireUpdateLock } from "./update-lock.js";
|
|
9
9
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
10
|
import { readFile } from "node:fs/promises";
|
|
11
11
|
//#region src/infra/update-startup.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
4
|
-
import { gatewayCredentialAuthorization } from "../gateway/credential.js";
|
|
5
4
|
import { loadUndiciRuntimeDeps } from "../infra/undici-fetch.js";
|
|
6
5
|
import { toConversation } from "./channel-shared.js";
|
|
6
|
+
import { gatewayCredentialAuthorization } from "../gateway/credential.js";
|
|
7
7
|
import { createGatewayHttpClientFromConfig, resolveGatewayHttpBaseUrl } from "./gateway-http-client.js";
|
|
8
8
|
//#region src/mcp/channel-bridge.ts
|
|
9
9
|
init_loader();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
2
|
export * from './project-store.js';
|
|
3
3
|
export * from './project-service.js';
|
|
4
|
+
export * from './project-skill-service.js';
|
|
4
5
|
export * from './project-agent.js';
|
|
5
6
|
export * from './project-agent-suggestion.js';
|
|
6
7
|
export * from './project-kind.js';
|
|
@@ -4,6 +4,7 @@ import { bindGoalToProject, bindGoalsToProject, listProjectGoalIds, unbindGoalFr
|
|
|
4
4
|
import { bindSessionToProject, bindSessionsToProject, listProjectSessionKeys, moveSessionToProject, unbindSessionFromProject } from "./session-bind.js";
|
|
5
5
|
import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, canonicalWorkspacePath, ensureWorkspaceDirectory, inferProjectNameFromWorkspaceRoot, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, resolveWorkspaceProjectRoot, workspaceDirectoryExists } from "./workspace-project.js";
|
|
6
6
|
import { ProjectService } from "./project-service.js";
|
|
7
|
+
import { ProjectSkillError, ProjectSkillService } from "./project-skill-service.js";
|
|
7
8
|
import { isValidProjectAgentId, normalizeProjectAgentId, resolveProjectAgentId } from "./project-agent.js";
|
|
8
9
|
import { inferProjectKind } from "./project-kind.js";
|
|
9
10
|
import { CODING_PROJECT_AGENT_ID, inferSuggestedProjectDefaultAgentId, suggestProjectDefaultAgentId } from "./project-agent-suggestion.js";
|
|
@@ -11,4 +12,4 @@ import { buildProjectLoopOverview } from "./project-loop.js";
|
|
|
11
12
|
import { bindWorkflowRunToProject } from "./workflow-bind.js";
|
|
12
13
|
import { bindAutomationToProject } from "./automation-bind.js";
|
|
13
14
|
import { bindMemoryRecordToProject } from "./memory-bind.js";
|
|
14
|
-
export { CODING_PROJECT_AGENT_ID, ProjectService, ProjectStore, ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, bindAutomationToProject, bindGoalToProject, bindGoalsToProject, bindMemoryRecordToProject, bindSessionToProject, bindSessionsToProject, bindWorkflowRunToProject, buildProjectLoopOverview, canonicalWorkspacePath, ensureWorkspaceDirectory, getProjectForSession, getProjectWorkspacePathForSession, inferProjectKind, inferProjectNameFromWorkspaceRoot, inferSuggestedProjectDefaultAgentId, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, isValidProjectAgentId, listProjectGoalIds, listProjectSessionKeys, moveSessionToProject, normalizeProjectAgentId, resolveProjectAgentId, resolveProjectWorkspacePath, resolveWorkspaceProjectRoot, slugifyProjectName, suggestProjectDefaultAgentId, unbindGoalFromProject, unbindSessionFromProject, workspaceDirectoryExists };
|
|
15
|
+
export { CODING_PROJECT_AGENT_ID, ProjectService, ProjectSkillError, ProjectSkillService, ProjectStore, ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, bindAutomationToProject, bindGoalToProject, bindGoalsToProject, bindMemoryRecordToProject, bindSessionToProject, bindSessionsToProject, bindWorkflowRunToProject, buildProjectLoopOverview, canonicalWorkspacePath, ensureWorkspaceDirectory, getProjectForSession, getProjectWorkspacePathForSession, inferProjectKind, inferProjectNameFromWorkspaceRoot, inferSuggestedProjectDefaultAgentId, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, isValidProjectAgentId, listProjectGoalIds, listProjectSessionKeys, moveSessionToProject, normalizeProjectAgentId, resolveProjectAgentId, resolveProjectWorkspacePath, resolveWorkspaceProjectRoot, slugifyProjectName, suggestProjectDefaultAgentId, unbindGoalFromProject, unbindSessionFromProject, workspaceDirectoryExists };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Config } from '../config/schema.js';
|
|
2
|
+
import type { SkillDiagnostic, SkillMetadata, SkillToolConditions } from '../agent/skills/types.js';
|
|
3
|
+
import type { ProjectService } from './project-service.js';
|
|
4
|
+
export type ProjectSkillErrorCode = 'project_not_found' | 'project_workspace_required' | 'project_workspace_missing' | 'project_workspace_not_writable' | 'skill_not_found' | 'invalid_skill_id';
|
|
5
|
+
export declare class ProjectSkillError extends Error {
|
|
6
|
+
readonly code: ProjectSkillErrorCode;
|
|
7
|
+
readonly status: 400 | 403 | 404 | 409;
|
|
8
|
+
constructor(code: ProjectSkillErrorCode, status: 400 | 403 | 404 | 409, message: string);
|
|
9
|
+
}
|
|
10
|
+
export interface ProjectSkillSummary {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
disableModelInvocation: boolean;
|
|
16
|
+
metadata: SkillMetadata;
|
|
17
|
+
toolConditions?: SkillToolConditions;
|
|
18
|
+
requiredEnvVarNames?: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface ProjectSkillListResult {
|
|
21
|
+
workspaceRoot: string;
|
|
22
|
+
skillsRoot: string;
|
|
23
|
+
items: ProjectSkillSummary[];
|
|
24
|
+
diagnostics: SkillDiagnostic[];
|
|
25
|
+
}
|
|
26
|
+
interface ProjectSkillServiceOptions {
|
|
27
|
+
projects: ProjectService;
|
|
28
|
+
getConfig: () => Config;
|
|
29
|
+
refreshSkills: () => void | Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare class ProjectSkillService {
|
|
32
|
+
private readonly options;
|
|
33
|
+
constructor(options: ProjectSkillServiceOptions);
|
|
34
|
+
list(projectId: string): ProjectSkillListResult;
|
|
35
|
+
getContent(projectId: string, skillId: string): ProjectSkillSummary & {
|
|
36
|
+
bodyMarkdown: string;
|
|
37
|
+
};
|
|
38
|
+
installZip(projectId: string, buffer: Buffer, input?: {
|
|
39
|
+
skillId?: string;
|
|
40
|
+
overwrite?: boolean;
|
|
41
|
+
}): Promise<ProjectSkillSummary & {
|
|
42
|
+
bodyMarkdown: string;
|
|
43
|
+
}>;
|
|
44
|
+
installMarketplace(projectId: string, input: {
|
|
45
|
+
name: string;
|
|
46
|
+
version?: string;
|
|
47
|
+
provider?: string;
|
|
48
|
+
overwrite?: boolean;
|
|
49
|
+
}): Promise<ProjectSkillSummary & {
|
|
50
|
+
bodyMarkdown: string;
|
|
51
|
+
}>;
|
|
52
|
+
installSource(projectId: string, input: {
|
|
53
|
+
source: string;
|
|
54
|
+
skillId?: string;
|
|
55
|
+
ref?: string;
|
|
56
|
+
subpath?: string;
|
|
57
|
+
force?: boolean;
|
|
58
|
+
}): Promise<ProjectSkillSummary & {
|
|
59
|
+
bodyMarkdown: string;
|
|
60
|
+
}>;
|
|
61
|
+
remove(projectId: string, skillId: string): Promise<void>;
|
|
62
|
+
private findSkill;
|
|
63
|
+
private resolveLocation;
|
|
64
|
+
private isDirectSkill;
|
|
65
|
+
private toSummary;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../agent/skills/workspace-skills-dir.js";
|
|
2
|
+
import { loadWorkspaceSkills } from "../agent/skills/index.js";
|
|
3
|
+
import { removeSkillsLockEntry } from "../agent/skills/hub-lock.js";
|
|
4
|
+
import { deleteManagedSkill, installSkillFromZip, isValidSkillId } from "../agent/skills/managed-store.js";
|
|
5
|
+
import { pullSkillFromSource } from "../agent/skills/hub-pull.js";
|
|
6
|
+
import { downloadFromMarketplace } from "../agent/skills/skills-marketplace.js";
|
|
7
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
8
|
+
import { accessSync, constants, existsSync, statSync } from "node:fs";
|
|
9
|
+
//#region src/projects/project-skill-service.ts
|
|
10
|
+
var ProjectSkillError = class extends Error {
|
|
11
|
+
constructor(code, status, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.name = "ProjectSkillError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var ProjectSkillService = class {
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.options = options;
|
|
21
|
+
}
|
|
22
|
+
list(projectId) {
|
|
23
|
+
const location = this.resolveLocation(projectId, false);
|
|
24
|
+
const loaded = loadWorkspaceSkills(location.workspaceRoot);
|
|
25
|
+
return {
|
|
26
|
+
...location,
|
|
27
|
+
items: loaded.skills.filter((skill) => this.isDirectSkill(skill, location.skillsRoot)).map((skill) => this.toSummary(skill)),
|
|
28
|
+
diagnostics: loaded.diagnostics
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
getContent(projectId, skillId) {
|
|
32
|
+
const { skill } = this.findSkill(projectId, skillId);
|
|
33
|
+
return {
|
|
34
|
+
...this.toSummary(skill),
|
|
35
|
+
bodyMarkdown: skill.content
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async installZip(projectId, buffer, input = {}) {
|
|
39
|
+
const location = this.resolveLocation(projectId, true);
|
|
40
|
+
const installed = installSkillFromZip(buffer, {
|
|
41
|
+
skillId: input.skillId,
|
|
42
|
+
overwrite: input.overwrite,
|
|
43
|
+
rootDir: location.skillsRoot
|
|
44
|
+
});
|
|
45
|
+
removeSkillsLockEntry(installed.skillId, resolveWorkspaceSkillsLockPath(location.workspaceRoot));
|
|
46
|
+
await this.options.refreshSkills();
|
|
47
|
+
return this.getContent(projectId, installed.skillId);
|
|
48
|
+
}
|
|
49
|
+
async installMarketplace(projectId, input) {
|
|
50
|
+
const downloaded = await downloadFromMarketplace(this.options.getConfig(), input.name, input.version, input.provider);
|
|
51
|
+
return this.installZip(projectId, downloaded.buffer, {
|
|
52
|
+
skillId: downloaded.skillId,
|
|
53
|
+
overwrite: input.overwrite
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async installSource(projectId, input) {
|
|
57
|
+
const location = this.resolveLocation(projectId, true);
|
|
58
|
+
const installed = await pullSkillFromSource(input.source, {
|
|
59
|
+
skillId: input.skillId,
|
|
60
|
+
ref: input.ref,
|
|
61
|
+
subpath: input.subpath,
|
|
62
|
+
force: input.force,
|
|
63
|
+
installRoot: location.skillsRoot,
|
|
64
|
+
lockPath: resolveWorkspaceSkillsLockPath(location.workspaceRoot)
|
|
65
|
+
});
|
|
66
|
+
await this.options.refreshSkills();
|
|
67
|
+
return this.getContent(projectId, installed.skillId);
|
|
68
|
+
}
|
|
69
|
+
async remove(projectId, skillId) {
|
|
70
|
+
const location = this.resolveLocation(projectId, true);
|
|
71
|
+
if (!isValidSkillId(skillId)) throw new ProjectSkillError("invalid_skill_id", 400, "Invalid skill id");
|
|
72
|
+
if (!existsSync(join(location.skillsRoot, skillId, "SKILL.md"))) throw new ProjectSkillError("skill_not_found", 404, "Project skill not found");
|
|
73
|
+
deleteManagedSkill(skillId, location.skillsRoot);
|
|
74
|
+
removeSkillsLockEntry(skillId, resolveWorkspaceSkillsLockPath(location.workspaceRoot));
|
|
75
|
+
await this.options.refreshSkills();
|
|
76
|
+
}
|
|
77
|
+
findSkill(projectId, skillId) {
|
|
78
|
+
if (!isValidSkillId(skillId)) throw new ProjectSkillError("invalid_skill_id", 400, "Invalid skill id");
|
|
79
|
+
const location = this.resolveLocation(projectId, false);
|
|
80
|
+
const skill = loadWorkspaceSkills(location.workspaceRoot).skills.find((item) => {
|
|
81
|
+
return !relative(location.skillsRoot, item.baseDir).includes(sep) && basename(item.baseDir) === skillId;
|
|
82
|
+
});
|
|
83
|
+
if (!skill) throw new ProjectSkillError("skill_not_found", 404, "Project skill not found");
|
|
84
|
+
return {
|
|
85
|
+
skill,
|
|
86
|
+
skillsRoot: location.skillsRoot
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
resolveLocation(projectId, requireWritable) {
|
|
90
|
+
const project = this.options.projects.get(projectId);
|
|
91
|
+
if (!project) throw new ProjectSkillError("project_not_found", 404, "Project not found");
|
|
92
|
+
const configuredRoot = project.workspaceRoot?.trim();
|
|
93
|
+
if (!configuredRoot) throw new ProjectSkillError("project_workspace_required", 409, "Project workspace is required");
|
|
94
|
+
const workspaceRoot = resolve(configuredRoot);
|
|
95
|
+
try {
|
|
96
|
+
if (!existsSync(workspaceRoot) || !statSync(workspaceRoot).isDirectory()) throw new ProjectSkillError("project_workspace_missing", 409, "Project workspace does not exist");
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (error instanceof ProjectSkillError) throw error;
|
|
99
|
+
throw new ProjectSkillError("project_workspace_missing", 409, "Project workspace does not exist");
|
|
100
|
+
}
|
|
101
|
+
const skillsRoot = resolveWorkspaceSkillsDir(workspaceRoot);
|
|
102
|
+
if (requireWritable) try {
|
|
103
|
+
const xopcRoot = dirname(skillsRoot);
|
|
104
|
+
accessSync(existsSync(skillsRoot) ? skillsRoot : existsSync(xopcRoot) ? xopcRoot : workspaceRoot, constants.W_OK);
|
|
105
|
+
} catch {
|
|
106
|
+
throw new ProjectSkillError("project_workspace_not_writable", 403, "Project workspace is not writable");
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
workspaceRoot,
|
|
110
|
+
skillsRoot
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
isDirectSkill(skill, skillsRoot) {
|
|
114
|
+
const rel = relative(skillsRoot, skill.baseDir);
|
|
115
|
+
return Boolean(rel) && !rel.includes(sep) && isValidSkillId(basename(skill.baseDir));
|
|
116
|
+
}
|
|
117
|
+
toSummary(skill) {
|
|
118
|
+
return {
|
|
119
|
+
id: basename(skill.baseDir),
|
|
120
|
+
name: skill.name,
|
|
121
|
+
description: skill.description,
|
|
122
|
+
category: skill.category,
|
|
123
|
+
disableModelInvocation: skill.disableModelInvocation,
|
|
124
|
+
metadata: skill.metadata,
|
|
125
|
+
toolConditions: skill.toolConditions,
|
|
126
|
+
requiredEnvVarNames: skill.requiredEnvVarNames
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { ProjectSkillError, ProjectSkillService };
|
|
@@ -5,10 +5,11 @@ import { hasProviderAuthOnDiskSync, init_sync_provider_auth } from "../auth/sync
|
|
|
5
5
|
import { PROVIDER_ENV_MAP, getApiKeyFromEnv, init_env_keys } from "./env-keys.js";
|
|
6
6
|
import { init_model_ref, splitProviderModelRef } from "./model-ref.js";
|
|
7
7
|
import { ModelRegistry, getModelRegistry, init_model_registry, prewarmModelRegistry, resetModelRegistry } from "./model-registry.js";
|
|
8
|
-
import { CredentialResolver, hasCredentials, init_credentials
|
|
8
|
+
import { CredentialResolver, hasCredentials, init_credentials } from "../auth/credentials.js";
|
|
9
9
|
import { EXTENSION_PROVIDER_BASE_URL, init_constants } from "./constants.js";
|
|
10
10
|
import { getSupplementalModels, init_model_supplements } from "./model-supplements.js";
|
|
11
11
|
import { getProviderRegistry, init_plugin_registry } from "./plugin-registry.js";
|
|
12
|
+
import { init_provider_auth_service, resolveProviderApiKey } from "./provider-auth-service.js";
|
|
12
13
|
import { getModel, getModels, getProviders } from "@earendil-works/pi-ai/compat";
|
|
13
14
|
//#region src/providers/index.ts
|
|
14
15
|
/**
|
|
@@ -144,7 +145,7 @@ function getAllProviders() {
|
|
|
144
145
|
}
|
|
145
146
|
async function getApiKey(provider, credentialOptions) {
|
|
146
147
|
if (getProviderRegistry().has(provider)) return "extension-managed";
|
|
147
|
-
const credentialKey = await
|
|
148
|
+
const credentialKey = await resolveProviderApiKey(provider, credentialOptions);
|
|
148
149
|
if (credentialKey) return credentialKey;
|
|
149
150
|
const registryKey = getModelRegistry().getApiKey(provider);
|
|
150
151
|
if (registryKey) return registryKey;
|
|
@@ -320,6 +321,7 @@ var init_providers = __esmMin((() => {
|
|
|
320
321
|
init_model_supplements();
|
|
321
322
|
init_model_ref();
|
|
322
323
|
init_plugin_registry();
|
|
324
|
+
init_provider_auth_service();
|
|
323
325
|
OPENAI_CODEX_CANONICAL_BASE_URL = "https://chatgpt.com/backend-api/codex";
|
|
324
326
|
PROVIDER_META = {
|
|
325
327
|
"xopc-cloud": {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ModelRuntime } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { CredentialResolver, type CredentialResolverOptions } from '../auth/credentials.js';
|
|
3
|
+
import { XopcModelCredentialStore } from '../auth/model-credential-store.js';
|
|
4
|
+
type ApiKeyResolver = Pick<CredentialResolver, 'resolveApiKey'>;
|
|
5
|
+
export interface ProviderAuthServiceOptions {
|
|
6
|
+
credentials?: XopcModelCredentialStore;
|
|
7
|
+
resolver?: ApiKeyResolver;
|
|
8
|
+
runtimeFactory?: (credentials: XopcModelCredentialStore) => Promise<ModelRuntime>;
|
|
9
|
+
}
|
|
10
|
+
/** Resolves request credentials while keeping OAuth refresh inside the shared persistent store. */
|
|
11
|
+
export declare class ProviderAuthService {
|
|
12
|
+
private readonly credentials;
|
|
13
|
+
private readonly resolver;
|
|
14
|
+
private readonly runtimeFactory;
|
|
15
|
+
private runtime;
|
|
16
|
+
constructor(options?: ProviderAuthServiceOptions);
|
|
17
|
+
resolveApiKey(providerId: string, signal?: AbortSignal): Promise<string | null>;
|
|
18
|
+
private getRuntime;
|
|
19
|
+
}
|
|
20
|
+
export declare function getProviderAuthService(): ProviderAuthService;
|
|
21
|
+
export declare function resolveProviderApiKey(providerId: string, credentialOptions?: CredentialResolverOptions): Promise<string | null>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { init_paths, resolveModelsJsonPath } from "../config/paths.js";
|
|
3
|
+
import { CredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
4
|
+
import { XopcModelCredentialStore, init_model_credential_store } from "../auth/model-credential-store.js";
|
|
5
|
+
import { init_register_runtime_providers, registerRuntimeProviders } from "./register-runtime-providers.js";
|
|
6
|
+
import { InMemoryModelsStore } from "@earendil-works/pi-ai";
|
|
7
|
+
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
//#region src/providers/provider-auth-service.ts
|
|
9
|
+
async function createAuthRuntime(credentials) {
|
|
10
|
+
const runtime = await ModelRuntime.create({
|
|
11
|
+
credentials,
|
|
12
|
+
modelsPath: resolveModelsJsonPath(),
|
|
13
|
+
modelsStore: new InMemoryModelsStore()
|
|
14
|
+
});
|
|
15
|
+
registerRuntimeProviders(runtime);
|
|
16
|
+
return runtime;
|
|
17
|
+
}
|
|
18
|
+
function getProviderAuthService() {
|
|
19
|
+
defaultProviderAuthService ??= new ProviderAuthService();
|
|
20
|
+
return defaultProviderAuthService;
|
|
21
|
+
}
|
|
22
|
+
async function resolveProviderApiKey(providerId, credentialOptions) {
|
|
23
|
+
if (!credentialOptions) return await getProviderAuthService().resolveApiKey(providerId);
|
|
24
|
+
const resolver = new CredentialResolver(credentialOptions);
|
|
25
|
+
return await new ProviderAuthService({
|
|
26
|
+
credentials: new XopcModelCredentialStore(resolver),
|
|
27
|
+
resolver
|
|
28
|
+
}).resolveApiKey(providerId);
|
|
29
|
+
}
|
|
30
|
+
var ProviderAuthService, defaultProviderAuthService;
|
|
31
|
+
var init_provider_auth_service = __esmMin((() => {
|
|
32
|
+
init_credentials();
|
|
33
|
+
init_model_credential_store();
|
|
34
|
+
init_paths();
|
|
35
|
+
init_register_runtime_providers();
|
|
36
|
+
ProviderAuthService = class {
|
|
37
|
+
credentials;
|
|
38
|
+
resolver;
|
|
39
|
+
runtimeFactory;
|
|
40
|
+
runtime;
|
|
41
|
+
constructor(options = {}) {
|
|
42
|
+
const defaultResolver = new CredentialResolver();
|
|
43
|
+
this.resolver = options.resolver ?? defaultResolver;
|
|
44
|
+
this.credentials = options.credentials ?? new XopcModelCredentialStore(defaultResolver);
|
|
45
|
+
this.runtimeFactory = options.runtimeFactory ?? createAuthRuntime;
|
|
46
|
+
}
|
|
47
|
+
async resolveApiKey(providerId, signal) {
|
|
48
|
+
if ((await this.credentials.read(providerId, { signal }))?.type === "oauth") {
|
|
49
|
+
const runtime = await this.getRuntime();
|
|
50
|
+
const provider = runtime.getProvider(providerId);
|
|
51
|
+
if (provider?.auth.oauth && !provider.auth.apiKey) return (await runtime.getAuth(providerId, { signal }))?.auth.apiKey ?? null;
|
|
52
|
+
}
|
|
53
|
+
return await this.resolver.resolveApiKey(providerId);
|
|
54
|
+
}
|
|
55
|
+
getRuntime() {
|
|
56
|
+
this.runtime ??= this.runtimeFactory(this.credentials).catch((error) => {
|
|
57
|
+
this.runtime = void 0;
|
|
58
|
+
throw error;
|
|
59
|
+
});
|
|
60
|
+
return this.runtime;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}));
|
|
64
|
+
//#endregion
|
|
65
|
+
init_provider_auth_service();
|
|
66
|
+
export { ProviderAuthService, getProviderAuthService, init_provider_auth_service, resolveProviderApiKey };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModelRuntime } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { type ModelCatalogSnapshot } from './model-catalog-store.js';
|
|
3
|
+
type RuntimeProviderRegistrar = Pick<ModelRuntime, 'registerProvider'>;
|
|
4
|
+
/** Register dynamically discovered model providers, including their OAuth contract. */
|
|
5
|
+
export declare function registerRuntimeProviders(modelRuntime: RuntimeProviderRegistrar, catalog?: ModelCatalogSnapshot): void;
|
|
6
|
+
export {};
|