deepspace 0.10.1 → 0.10.3

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.
Files changed (75) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/chunk-ZJ43EK3N.js +1751 -0
  3. package/dist/chunk-ZJ43EK3N.js.map +1 -0
  4. package/dist/cli.js +848 -650
  5. package/dist/cli.js.map +1 -1
  6. package/dist/documentation-client-core.d.ts +18 -0
  7. package/dist/documentation-client-core.js +395 -0
  8. package/dist/documentation-client-core.js.map +1 -0
  9. package/dist/documentation-default-renderer.cjs +124 -0
  10. package/dist/documentation-react.d.ts +2 -0
  11. package/dist/documentation-react.js +35 -0
  12. package/dist/documentation-react.js.map +1 -0
  13. package/dist/documentation-runtime.js +71 -0
  14. package/dist/documentation-server-core.d.ts +11 -0
  15. package/dist/documentation-server-core.js +48 -0
  16. package/dist/documentation-server-core.js.map +1 -0
  17. package/dist/documentation.d.ts +367 -0
  18. package/dist/documentation.js +4122 -0
  19. package/dist/documentation.js.map +1 -0
  20. package/dist/feature-installer.js +145 -0
  21. package/dist/feature-installer.js.map +1 -1
  22. package/dist/fonts/geist-mono-OFL.txt +93 -0
  23. package/dist/fonts/geist-mono-variable.woff2 +0 -0
  24. package/dist/fonts/inter-OFL.txt +92 -0
  25. package/dist/fonts/inter-variable.woff2 +0 -0
  26. package/dist/index.d.ts +177 -1
  27. package/dist/index.js +133 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/public-BGRX_Cjd.d.ts +234 -0
  30. package/dist/schema.d.ts +186 -0
  31. package/dist/schema.js +610 -0
  32. package/dist/schema.js.map +1 -0
  33. package/dist/server.d.ts +83 -4
  34. package/dist/server.js +296 -1
  35. package/dist/server.js.map +1 -1
  36. package/dist/testing.d.ts +5 -8
  37. package/dist/testing.js +48 -14
  38. package/dist/testing.js.map +1 -1
  39. package/dist/worker.d.ts +249 -5
  40. package/dist/worker.js +1438 -19
  41. package/dist/worker.js.map +1 -1
  42. package/features/admin-page/src/admin-schema.ts +1 -1
  43. package/features/ai-chat/feature.json +2 -2
  44. package/features/ai-chat/src/ChatPanel.tsx +6 -11
  45. package/features/ai-chat/src/ai-chat-schema.ts +1 -2
  46. package/features/canvas/src/canvas-schema.ts +1 -1
  47. package/features/documentation/content/index.mdx +14 -0
  48. package/features/documentation/content/quickstart.mdx +12 -0
  49. package/features/documentation/documentation.json +18 -0
  50. package/features/documentation/feature.json +68 -0
  51. package/features/{docs → documents}/feature.json +27 -27
  52. package/features/{docs/src/DocsEditorPage.tsx → documents/src/DocumentsEditorPage.tsx} +74 -74
  53. package/features/{docs/src/DocsListPage.tsx → documents/src/DocumentsListPage.tsx} +102 -102
  54. package/features/{docs/src/DocsOutlinePanel.tsx → documents/src/DocumentsOutlinePanel.tsx} +9 -9
  55. package/features/{docs/src/DocsPresence.tsx → documents/src/DocumentsPresence.tsx} +18 -18
  56. package/features/{docs → documents}/src/InviteDialog.tsx +21 -21
  57. package/features/{docs → documents}/src/LibrarySidebar.tsx +25 -25
  58. package/features/documents/src/__tests__/documents-presence-access.test.ts +71 -0
  59. package/features/{docs/src/docs-library-types.ts → documents/src/documents-library-types.ts} +3 -3
  60. package/features/{docs/src/docs-schema.ts → documents/src/documents-schema.ts} +6 -6
  61. package/features/{docs/src/docs-ui.css → documents/src/documents-ui.css} +89 -89
  62. package/features/{docs → documents}/src/editor/DocEditorSurface.tsx +11 -11
  63. package/features/{docs/src/editor/DocsTiptapToolbar.tsx → documents/src/editor/DocumentsTiptapToolbar.tsx} +21 -21
  64. package/features/{docs → documents}/src/editor/useDocEditor.ts +4 -4
  65. package/features/{docs/src/use-docs-presence-access.ts → documents/src/use-documents-presence-access.ts} +51 -51
  66. package/features/file-attachments/src/attachments-schema.ts +1 -1
  67. package/features/items/src/items-schema.ts +1 -1
  68. package/features/leaderboard/src/leaderboard-schema.ts +1 -1
  69. package/features/messaging/src/ChatMultiPage.tsx +1 -1
  70. package/features/messaging/src/ChatPage.tsx +1 -1
  71. package/features/messaging/src/messaging-schema.ts +2 -2
  72. package/features/tasks/src/tasks-schema.ts +1 -1
  73. package/features/testing/src/test-schema.ts +2 -2
  74. package/package.json +26 -1
  75. package/features/docs/src/__tests__/docs-presence-access.test.ts +0 -71
package/dist/server.js CHANGED
@@ -611,6 +611,275 @@ function createDeepSpaceAI(env, provider, options = {}) {
611
611
  }
612
612
  }
613
613
 
614
+ // src/server/utils/agent.ts
615
+ import {
616
+ stepCountIs,
617
+ streamText
618
+ } from "ai";
619
+
620
+ // src/shared/ai-models.ts
621
+ var MULTI_STEP_AGENT_PROFILES = ["application", "documentation"];
622
+ function createMultiStepModelFactory(provider) {
623
+ return (model) => ({
624
+ ...model,
625
+ ...provider,
626
+ agentSupport: "multi-step",
627
+ agentProfiles: MULTI_STEP_AGENT_PROFILES
628
+ });
629
+ }
630
+ var anthropicModel = createMultiStepModelFactory({
631
+ provider: "anthropic",
632
+ providerLabel: "Anthropic",
633
+ transport: "messages"
634
+ });
635
+ var openAIModel = createMultiStepModelFactory({
636
+ provider: "openai",
637
+ providerLabel: "OpenAI",
638
+ transport: "chat-completions"
639
+ });
640
+ var DEEPSPACE_AI_MODELS = [
641
+ anthropicModel({
642
+ id: "claude-fable-5",
643
+ label: "Claude Fable 5",
644
+ family: "Claude 5",
645
+ recommendation: "frontier"
646
+ }),
647
+ anthropicModel({
648
+ id: "claude-opus-5",
649
+ label: "Claude Opus 5",
650
+ family: "Claude 5",
651
+ recommendation: "frontier"
652
+ }),
653
+ anthropicModel({
654
+ id: "claude-sonnet-5",
655
+ label: "Claude Sonnet 5",
656
+ family: "Claude 5",
657
+ recommendation: "balanced"
658
+ }),
659
+ anthropicModel({
660
+ id: "claude-haiku-4-5",
661
+ label: "Claude Haiku 4.5",
662
+ family: "Claude 4.5",
663
+ recommendation: "fast"
664
+ }),
665
+ openAIModel({
666
+ id: "gpt-5.6-sol",
667
+ label: "GPT-5.6 Sol",
668
+ family: "GPT-5.6",
669
+ recommendation: "frontier"
670
+ }),
671
+ openAIModel({
672
+ id: "gpt-5.6-terra",
673
+ label: "GPT-5.6 Terra",
674
+ family: "GPT-5.6",
675
+ recommendation: "balanced"
676
+ }),
677
+ openAIModel({
678
+ id: "gpt-5.6-luna",
679
+ label: "GPT-5.6 Luna",
680
+ family: "GPT-5.6",
681
+ recommendation: "fast"
682
+ }),
683
+ {
684
+ id: "gpt-oss-120b",
685
+ label: "GPT-OSS 120B",
686
+ provider: "cerebras",
687
+ providerLabel: "Cerebras",
688
+ family: "GPT-OSS",
689
+ agentSupport: "single-step",
690
+ agentProfiles: [],
691
+ transport: "chat-completions",
692
+ recommendation: "limited",
693
+ note: "Available for direct generation; the current proxy adapter has not passed multi-step tool-result continuation."
694
+ }
695
+ ];
696
+ var DEEPSPACE_AI_DEFAULTS = {
697
+ agent: "claude-sonnet-5",
698
+ directGeneration: "claude-sonnet-5",
699
+ summarization: "claude-haiku-4-5"
700
+ };
701
+ var DEEPSPACE_AGENT_PROFILES = {
702
+ application: {
703
+ id: "application",
704
+ defaultModel: DEEPSPACE_AI_DEFAULTS.agent,
705
+ maxSteps: 21,
706
+ maxToolCalls: 20,
707
+ allowedTools: "application-defined"
708
+ },
709
+ documentation: {
710
+ id: "documentation",
711
+ defaultModel: DEEPSPACE_AI_DEFAULTS.agent,
712
+ // Permit up to twenty completed read-only tools plus one final synthesis
713
+ // step. The runner disables tools once the tool-call budget is exhausted.
714
+ maxSteps: 21,
715
+ maxToolCalls: 20,
716
+ allowedTools: ["documentation_search", "documentation_read"]
717
+ }
718
+ };
719
+ function getDeepSpaceAIModel(modelId) {
720
+ if (typeof modelId !== "string") return null;
721
+ return DEEPSPACE_AI_MODELS.find((model) => model.id === modelId) ?? null;
722
+ }
723
+ function resolveDeepSpaceAgentModel(modelId, profileId = "application") {
724
+ const profile = DEEPSPACE_AGENT_PROFILES[profileId];
725
+ const resolvedId = modelId === void 0 ? profile.defaultModel : modelId;
726
+ const model = getDeepSpaceAIModel(resolvedId);
727
+ if (!model || !model.agentProfiles.includes(profileId)) return null;
728
+ return { modelId: model.id, provider: model.provider, model, profile };
729
+ }
730
+
731
+ // src/server/utils/agent.ts
732
+ var DeepSpaceAgentModelError = class extends Error {
733
+ constructor(modelId, profile) {
734
+ super(
735
+ `Model ${typeof modelId === "string" ? JSON.stringify(modelId) : String(modelId)} is not compatible with the ${profile} agent profile`
736
+ );
737
+ this.modelId = modelId;
738
+ this.profile = profile;
739
+ this.name = "DeepSpaceAgentModelError";
740
+ }
741
+ code = "unsupported_agent_model";
742
+ };
743
+ var DeepSpaceAgentProfileError = class extends Error {
744
+ constructor(profile, toolName) {
745
+ super(`The ${profile} agent profile does not allow tool ${JSON.stringify(toolName)}`);
746
+ this.profile = profile;
747
+ this.toolName = toolName;
748
+ this.name = "DeepSpaceAgentProfileError";
749
+ }
750
+ code = "agent_profile_violation";
751
+ };
752
+ function streamDeepSpaceAgent(env, options) {
753
+ const { profile, modelId, authToken, ...streamOptions } = options;
754
+ const selection = resolveDeepSpaceAgentModel(modelId, profile);
755
+ if (!selection) throw new DeepSpaceAgentModelError(modelId, profile);
756
+ if (selection.profile.allowedTools !== "application-defined") {
757
+ const allowed = selection.profile.allowedTools;
758
+ for (const toolName of Object.keys(streamOptions.tools ?? {})) {
759
+ if (!allowed.includes(toolName)) {
760
+ throw new DeepSpaceAgentProfileError(profile, toolName);
761
+ }
762
+ }
763
+ }
764
+ const provider = createDeepSpaceAI(env, selection.provider, authToken ? { authToken } : {});
765
+ const { prepareStep, tools, ...remainingStreamOptions } = streamOptions;
766
+ const boundedTools = limitToolExecutions(tools, selection.profile.maxToolCalls);
767
+ const result = streamText({
768
+ ...remainingStreamOptions,
769
+ ...boundedTools ? { tools: boundedTools } : {},
770
+ model: provider(selection.modelId),
771
+ stopWhen: stepCountIs(selection.profile.maxSteps),
772
+ prepareStep: enforceToolCallLimit(prepareStep, selection.profile.maxToolCalls),
773
+ ...selection.provider === "openai" ? { providerOptions: { openai: { reasoningEffort: "none" } } } : {}
774
+ });
775
+ return { selection, result };
776
+ }
777
+ function enforceToolCallLimit(prepareStep, maxToolCalls) {
778
+ if (maxToolCalls === void 0) return prepareStep;
779
+ return async (context) => {
780
+ const prepared = await prepareStep?.(context);
781
+ const completedToolCalls = context.steps.reduce(
782
+ (count, step) => count + step.toolCalls.length,
783
+ 0
784
+ );
785
+ if (completedToolCalls < maxToolCalls) return prepared;
786
+ return { ...prepared, activeTools: [], toolChoice: "none" };
787
+ };
788
+ }
789
+ function limitToolExecutions(tools, maxToolCalls) {
790
+ if (!tools || maxToolCalls === void 0) return tools;
791
+ let executions = 0;
792
+ return Object.fromEntries(
793
+ Object.entries(tools).map(([name, definition]) => {
794
+ if (typeof definition.execute !== "function") return [name, definition];
795
+ const execute = definition.execute;
796
+ return [
797
+ name,
798
+ {
799
+ ...definition,
800
+ execute: (...args) => {
801
+ if (executions >= maxToolCalls) {
802
+ return Promise.resolve({
803
+ error: `The agent tool-call limit of ${maxToolCalls} has been reached`
804
+ });
805
+ }
806
+ executions++;
807
+ return execute(...args);
808
+ }
809
+ }
810
+ ];
811
+ })
812
+ );
813
+ }
814
+ function deepSpaceAgentErrorSummary(error, context = {}) {
815
+ const details = [];
816
+ const contextFields = [
817
+ context.profile ? `profile=${context.profile}` : void 0,
818
+ context.provider ? `provider=${safeLogToken(context.provider)}` : void 0,
819
+ context.modelId ? `model=${safeLogToken(context.modelId)}` : void 0
820
+ ].filter((part) => Boolean(part));
821
+ if (contextFields.length > 0) details.push(contextFields.join(" "));
822
+ const pending = [error];
823
+ const visited = /* @__PURE__ */ new Set();
824
+ while (pending.length > 0 && details.length < 8) {
825
+ const current = pending.shift();
826
+ if (current == null || visited.has(current)) continue;
827
+ visited.add(current);
828
+ if (typeof current === "object") {
829
+ const record = current;
830
+ const parts = [
831
+ typeof record.name === "string" ? `name=${safeLogToken(record.name)}` : current instanceof Error ? `name=${safeLogToken(current.name)}` : void 0,
832
+ safeErrorMessage(current, record),
833
+ typeof record.statusCode === "number" ? `status=${record.statusCode}` : void 0,
834
+ typeof record.code === "string" ? `code=${safeLogToken(record.code)}` : void 0,
835
+ typeof record.requestId === "string" ? `requestId=${safeLogToken(record.requestId)}` : void 0,
836
+ ...safeProviderResponseMetadata(record.responseBody)
837
+ ].filter((part) => Boolean(part));
838
+ details.push(parts.join(" ") || Object.prototype.toString.call(current));
839
+ if (record.lastError != null) pending.push(record.lastError);
840
+ if (record.cause != null) pending.push(record.cause);
841
+ if (Array.isArray(record.errors)) pending.push(...record.errors);
842
+ continue;
843
+ }
844
+ details.push(String(current));
845
+ }
846
+ return details.join(" <- ") || "Unknown error";
847
+ }
848
+ function safeErrorMessage(current, record) {
849
+ if (record.responseBody !== void 0) return void 0;
850
+ const message = current instanceof Error ? current.message : record.message;
851
+ if (typeof message !== "string" || !message.trim()) return void 0;
852
+ return `message=${safeLogText(message)}`;
853
+ }
854
+ function safeProviderResponseMetadata(responseBody) {
855
+ if (typeof responseBody !== "string") return [];
856
+ try {
857
+ const parsed = JSON.parse(responseBody);
858
+ const error = parsed.error && typeof parsed.error === "object" ? parsed.error : void 0;
859
+ const code = typeof error?.code === "string" ? error.code : typeof error?.type === "string" ? error.type : void 0;
860
+ const requestId = typeof parsed.request_id === "string" ? parsed.request_id : void 0;
861
+ return [
862
+ code ? `upstreamCode=${safeLogToken(code)}` : void 0,
863
+ requestId ? `upstreamRequestId=${safeLogToken(requestId)}` : void 0
864
+ ].filter((part) => Boolean(part));
865
+ } catch {
866
+ return [];
867
+ }
868
+ }
869
+ function safeLogToken(value) {
870
+ return value.replace(/[^a-zA-Z0-9._:/-]/g, "_").slice(0, 120);
871
+ }
872
+ function safeLogText(value) {
873
+ const withoutControlCharacters = Array.from(value, (character) => {
874
+ const codePoint = character.codePointAt(0) ?? 0;
875
+ return codePoint <= 31 || codePoint === 127 ? " " : character;
876
+ }).join("");
877
+ return withoutControlCharacters.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [redacted]").replace(
878
+ /\b(api[_ -]?key|authorization|password|secret|token)\b\s*[:=]\s*\S+/gi,
879
+ "$1=[redacted]"
880
+ ).trim().slice(0, 300);
881
+ }
882
+
614
883
  // src/server/utils/composio-tools.ts
615
884
  import { tool, jsonSchema } from "ai";
616
885
  var EMPTY_SCHEMA = { type: "object", properties: {} };
@@ -5994,7 +6263,8 @@ var ALLOWED_BINDING_TYPES = /* @__PURE__ */ new Set([
5994
6263
  "queue",
5995
6264
  "browser_rendering",
5996
6265
  "analytics_engine",
5997
- "hyperdrive"
6266
+ "hyperdrive",
6267
+ "ratelimit"
5998
6268
  ]);
5999
6269
  var RESERVED_BINDING_NAMES = /* @__PURE__ */ new Set([
6000
6270
  "ASSETS",
@@ -6002,6 +6272,7 @@ var RESERVED_BINDING_NAMES = /* @__PURE__ */ new Set([
6002
6272
  "API_WORKER",
6003
6273
  "DEEPSPACE_APP_ID",
6004
6274
  "DEEPSPACE_RESOURCE_ID",
6275
+ "DEEPSPACE_RELEASE_OPERATION_ID",
6005
6276
  "APP_NAME",
6006
6277
  "OWNER_USER_ID",
6007
6278
  "AUTH_JWT_PUBLIC_KEY",
@@ -6092,6 +6363,17 @@ function requiredFieldError(b) {
6092
6363
  return `hyperdrive binding "${b.name}": auto-provisioning not yet supported (provide a real id)`;
6093
6364
  }
6094
6365
  return null;
6366
+ case "ratelimit":
6367
+ if (!/^\d+$/u.test(b.namespace_id) || Number(b.namespace_id) <= 0) {
6368
+ return `ratelimit binding "${b.name}" requires a positive integer namespace_id string`;
6369
+ }
6370
+ if (!Number.isInteger(b.simple?.limit) || b.simple.limit <= 0) {
6371
+ return `ratelimit binding "${b.name}" requires simple.limit (positive integer)`;
6372
+ }
6373
+ if (b.simple.period !== 10 && b.simple.period !== 60) {
6374
+ return `ratelimit binding "${b.name}" requires simple.period (10 or 60)`;
6375
+ }
6376
+ return null;
6095
6377
  case "ai":
6096
6378
  case "browser_rendering":
6097
6379
  case "analytics_engine":
@@ -6169,6 +6451,15 @@ function bindingManifestFromOutputConfig(outputConfig) {
6169
6451
  const id = pluckString(h, "id");
6170
6452
  if (name && id) out.push({ type: "hyperdrive", name, id });
6171
6453
  }
6454
+ for (const r of asObjectArray(outputConfig.ratelimits)) {
6455
+ const name = pluckString(r, "name");
6456
+ const namespace_id = pluckString(r, "namespace_id");
6457
+ const simple = isObject(r.simple) ? r.simple : null;
6458
+ const limit = pluckNumber(simple, "limit");
6459
+ const period = pluckNumber(simple, "period");
6460
+ if (!name || !namespace_id || limit === null || period !== 10 && period !== 60) continue;
6461
+ out.push({ type: "ratelimit", name, namespace_id, simple: { limit, period } });
6462
+ }
6172
6463
  return out;
6173
6464
  }
6174
6465
  function isObject(v) {
@@ -7365,6 +7656,8 @@ export {
7365
7656
  DEFAULT_QUERY_LIMIT,
7366
7657
  DEPLOYED_APPS_DEFAULTS,
7367
7658
  DIRECTORY_SCHEMAS,
7659
+ DeepSpaceAgentModelError,
7660
+ DeepSpaceAgentProfileError,
7368
7661
  GLOBAL_DO_TYPES,
7369
7662
  GLOBAL_DO_TYPE_NAMES,
7370
7663
  GameRoom,
@@ -7424,6 +7717,7 @@ export {
7424
7717
  createScopedR2Handler,
7425
7718
  dataToColumnValues,
7426
7719
  decodeJwtPayload,
7720
+ deepSpaceAgentErrorSummary,
7427
7721
  deleteChatCascade,
7428
7722
  deleteRecord,
7429
7723
  enqueueJob,
@@ -7481,6 +7775,7 @@ export {
7481
7775
  rowToData,
7482
7776
  runMigrations,
7483
7777
  saveYjsDoc,
7778
+ streamDeepSpaceAgent,
7484
7779
  timingSafeEqualHex,
7485
7780
  timingSafeEqualStrings,
7486
7781
  totalChars,