@dxos/compute 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/lib/AiMetering.mjs +1 -0
  2. package/dist/lib/Hook.mjs +1 -0
  3. package/dist/lib/Operation.mjs +3 -3
  4. package/dist/lib/Process.mjs +2 -2
  5. package/dist/lib/Trace.mjs +1 -1
  6. package/dist/lib/chunk-AgentIdentity.mjs +1 -1
  7. package/dist/lib/chunk-AgentService.mjs.map +1 -1
  8. package/dist/lib/chunk-AiMetering.mjs +77 -0
  9. package/dist/lib/chunk-AiMetering.mjs.map +1 -0
  10. package/dist/lib/chunk-Cancellation.mjs +1 -1
  11. package/dist/lib/chunk-Hook.mjs +78 -0
  12. package/dist/lib/chunk-Hook.mjs.map +1 -0
  13. package/dist/lib/chunk-Instructions.mjs +1 -1
  14. package/dist/lib/chunk-Operation.mjs +169 -5
  15. package/dist/lib/chunk-Operation.mjs.map +1 -1
  16. package/dist/lib/chunk-OperationHandlerSet.mjs +1 -1
  17. package/dist/lib/chunk-OperationRegistry.mjs +1 -1
  18. package/dist/lib/chunk-OperationRegistry.mjs.map +1 -1
  19. package/dist/lib/chunk-Process.mjs +18 -10
  20. package/dist/lib/chunk-Process.mjs.map +1 -1
  21. package/dist/lib/chunk-Project.mjs +52 -24
  22. package/dist/lib/chunk-Project.mjs.map +1 -1
  23. package/dist/lib/chunk-Reducer.mjs +827 -0
  24. package/dist/lib/chunk-Reducer.mjs.map +1 -0
  25. package/dist/lib/chunk-Routine.mjs +1 -1
  26. package/dist/lib/chunk-Runnable.mjs +1 -1
  27. package/dist/lib/chunk-ServiceResolver.mjs +1 -1
  28. package/dist/lib/chunk-Skill.mjs +10 -47
  29. package/dist/lib/chunk-Skill.mjs.map +1 -1
  30. package/dist/lib/chunk-Spec.mjs +49 -0
  31. package/dist/lib/chunk-Spec.mjs.map +1 -0
  32. package/dist/lib/chunk-SpecReview.mjs +98 -0
  33. package/dist/lib/chunk-SpecReview.mjs.map +1 -0
  34. package/dist/lib/chunk-SqlService.mjs.map +1 -1
  35. package/dist/lib/chunk-StorageService.mjs +1 -1
  36. package/dist/lib/chunk-Template.mjs +2 -2
  37. package/dist/lib/chunk-Trace.mjs +97 -13
  38. package/dist/lib/chunk-Trace.mjs.map +1 -1
  39. package/dist/lib/chunk-Trajectory.mjs +326 -0
  40. package/dist/lib/chunk-Trajectory.mjs.map +1 -0
  41. package/dist/lib/chunk-Transcript.mjs +84 -0
  42. package/dist/lib/chunk-Transcript.mjs.map +1 -0
  43. package/dist/lib/chunk-definitions.mjs +1 -1
  44. package/dist/lib/errors.mjs +3 -1
  45. package/dist/lib/errors.mjs.map +1 -1
  46. package/dist/lib/index.mjs +14 -8
  47. package/dist/lib/testing.mjs +2 -2
  48. package/dist/lib/trajectory/Reducer.mjs +1 -0
  49. package/dist/lib/trajectory/Trajectory.mjs +1 -0
  50. package/dist/lib/trajectory/Transcript.mjs +1 -0
  51. package/dist/lib/types/Project.mjs +1 -1
  52. package/dist/lib/types/Skill.mjs +1 -1
  53. package/dist/lib/types/Spec.mjs +1 -0
  54. package/dist/lib/types/SpecReview.mjs +1 -0
  55. package/dist/types/src/AgentService.d.ts +9 -0
  56. package/dist/types/src/AgentService.d.ts.map +1 -1
  57. package/dist/types/src/AiMetering.d.ts +23 -0
  58. package/dist/types/src/AiMetering.d.ts.map +1 -0
  59. package/dist/types/src/AiMetering.test.d.ts +2 -0
  60. package/dist/types/src/AiMetering.test.d.ts.map +1 -0
  61. package/dist/types/src/Hook.d.ts +84 -0
  62. package/dist/types/src/Hook.d.ts.map +1 -0
  63. package/dist/types/src/Hook.test.d.ts +2 -0
  64. package/dist/types/src/Hook.test.d.ts.map +1 -0
  65. package/dist/types/src/Operation.d.ts +276 -2
  66. package/dist/types/src/Operation.d.ts.map +1 -1
  67. package/dist/types/src/Process.d.ts +26 -4
  68. package/dist/types/src/Process.d.ts.map +1 -1
  69. package/dist/types/src/Script.test.d.ts +2 -0
  70. package/dist/types/src/Script.test.d.ts.map +1 -0
  71. package/dist/types/src/Trace.d.ts +103 -1
  72. package/dist/types/src/Trace.d.ts.map +1 -1
  73. package/dist/types/src/errors.d.ts +30 -0
  74. package/dist/types/src/errors.d.ts.map +1 -1
  75. package/dist/types/src/index.d.ts +3 -1
  76. package/dist/types/src/index.d.ts.map +1 -1
  77. package/dist/types/src/trajectory/Reducer.d.ts +191 -0
  78. package/dist/types/src/trajectory/Reducer.d.ts.map +1 -0
  79. package/dist/types/src/trajectory/Reducer.test.d.ts +2 -0
  80. package/dist/types/src/trajectory/Reducer.test.d.ts.map +1 -0
  81. package/dist/types/src/trajectory/Trajectory.d.ts +3211 -0
  82. package/dist/types/src/trajectory/Trajectory.d.ts.map +1 -0
  83. package/dist/types/src/trajectory/Trajectory.test.d.ts +2 -0
  84. package/dist/types/src/trajectory/Trajectory.test.d.ts.map +1 -0
  85. package/dist/types/src/trajectory/Transcript.d.ts +40 -0
  86. package/dist/types/src/trajectory/Transcript.d.ts.map +1 -0
  87. package/dist/types/src/trajectory/index.d.ts +4 -0
  88. package/dist/types/src/trajectory/index.d.ts.map +1 -0
  89. package/dist/types/src/trajectory/light-threads.test.d.ts +2 -0
  90. package/dist/types/src/trajectory/light-threads.test.d.ts.map +1 -0
  91. package/dist/types/src/trajectory/samples.test.d.ts +2 -0
  92. package/dist/types/src/trajectory/samples.test.d.ts.map +1 -0
  93. package/dist/types/src/types/Project.d.ts +11 -12
  94. package/dist/types/src/types/Project.d.ts.map +1 -1
  95. package/dist/types/src/types/Skill.d.ts +6 -51
  96. package/dist/types/src/types/Skill.d.ts.map +1 -1
  97. package/dist/types/src/types/Spec.d.ts +26 -0
  98. package/dist/types/src/types/Spec.d.ts.map +1 -0
  99. package/dist/types/src/types/SpecReview.d.ts +76 -0
  100. package/dist/types/src/types/SpecReview.d.ts.map +1 -0
  101. package/dist/types/src/types/index.d.ts +2 -0
  102. package/dist/types/src/types/index.d.ts.map +1 -1
  103. package/dist/types/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +59 -26
  105. package/src/AgentService.ts +9 -0
  106. package/src/AiMetering.test.ts +89 -0
  107. package/src/AiMetering.ts +93 -0
  108. package/src/Hook.test.ts +75 -0
  109. package/src/Hook.ts +154 -0
  110. package/src/Operation.test.ts +23 -0
  111. package/src/Operation.ts +334 -0
  112. package/src/Process.ts +33 -6
  113. package/src/Script.test.ts +74 -0
  114. package/src/Trace.ts +97 -4
  115. package/src/errors.ts +3 -0
  116. package/src/index.ts +3 -1
  117. package/src/trajectory/Reducer.test.ts +575 -0
  118. package/src/trajectory/Reducer.ts +1026 -0
  119. package/src/trajectory/Trajectory.test.ts +114 -0
  120. package/src/trajectory/Trajectory.ts +440 -0
  121. package/src/trajectory/Transcript.ts +113 -0
  122. package/src/trajectory/index.ts +7 -0
  123. package/src/trajectory/light-threads.test.ts +310 -0
  124. package/src/trajectory/samples.test.ts +285 -0
  125. package/src/types/Project.test.ts +2 -1
  126. package/src/types/Project.ts +43 -27
  127. package/src/types/Skill.ts +6 -61
  128. package/src/types/Spec.ts +68 -0
  129. package/src/types/SpecReview.ts +98 -0
  130. package/src/types/index.ts +2 -0
  131. package/dist/lib/McpServer.mjs +0 -1
  132. package/dist/lib/chunk-McpServer.mjs +0 -124
  133. package/dist/lib/chunk-McpServer.mjs.map +0 -1
  134. package/dist/types/src/McpServer.d.ts +0 -113
  135. package/dist/types/src/McpServer.d.ts.map +0 -1
  136. package/src/McpServer.ts +0 -142
package/src/McpServer.ts DELETED
@@ -1,142 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- // @import-as-namespace
6
-
7
- import * as Schema from 'effect/Schema';
8
-
9
- import { Annotation, DXN, Obj, Ref, Type } from '@dxos/echo';
10
- import { AccessToken } from '@dxos/link';
11
-
12
- /**
13
- * MCP server connection spec — the minimal fields needed to dial an MCP server.
14
- *
15
- * Used as a value type embedded in skills and passed to runtime session connect logic.
16
- * The user-facing ECHO object ({@link McpServer}) composes this struct and adds instance-level
17
- * fields (`enabled`, credentials) and ECHO annotations.
18
- */
19
- export const Spec = Schema.Struct({
20
- name: Schema.String.pipe(Schema.optional).annotate({
21
- description: 'Human-readable name of the MCP server',
22
- }),
23
-
24
- url: Schema.String.annotate({
25
- description: 'URL of the MCP server',
26
- }),
27
-
28
- /**
29
- * Transport protocol. Prefer `'http'` (Streamable HTTP) for new servers; `'sse'` is
30
- * kept for compatibility with servers that haven't migrated and is deprecated per
31
- * the MCP SDK. Clients support both during the migration period.
32
- */
33
- protocol: Schema.Union([Schema.Literal('http'), Schema.Literal('sse')]).annotate({
34
- description: 'Transport protocol of the MCP server (prefer "http"; "sse" deprecated)',
35
- }),
36
-
37
- /**
38
- * Optional API key sent as a Bearer token.
39
- * Persisted in plaintext wherever the spec is stored; a space-level {@link McpServer} references an
40
- * `AccessToken` instead.
41
- */
42
- apiKey: Schema.optional(Schema.String).annotate({
43
- description: 'Optional API key sent with requests',
44
- }),
45
- });
46
-
47
- export type Spec = Schema.Schema.Type<typeof Spec>;
48
-
49
- /**
50
- * Tokens issued to Composer by the server's authorization server (MCP authorization, OAuth 2.1).
51
- */
52
- export const OAuthTokens = Schema.Struct({
53
- accessToken: Schema.String,
54
- tokenType: Schema.String,
55
- refreshToken: Schema.optional(Schema.String),
56
- /** Epoch milliseconds; absent when the server did not say. */
57
- expiresAt: Schema.optional(Schema.Number),
58
- scope: Schema.optional(Schema.String),
59
- });
60
-
61
- export type OAuthTokens = Schema.Schema.Type<typeof OAuthTokens>;
62
-
63
- /**
64
- * OAuth state for a server that requires authorization. The client registration is kept alongside
65
- * the tokens because a refresh must present the same client id the tokens were issued to, and the
66
- * agent refreshing them may be hosted on EDGE rather than in the browser that signed in.
67
- */
68
- export const OAuthState = Schema.Struct({
69
- clientId: Schema.String,
70
- clientSecret: Schema.optional(Schema.String),
71
- redirectUrl: Schema.optional(Schema.String),
72
- tokens: Schema.optional(OAuthTokens),
73
- });
74
-
75
- export type OAuthState = Schema.Schema.Type<typeof OAuthState>;
76
-
77
- /**
78
- * MCP server configuration stored as a space-level ECHO object; every enabled one is connected at
79
- * the start of each agent turn in the space.
80
- *
81
- * NOTE: OAuth tokens and legacy `apiKey` values are stored in plaintext and replicated to all peers
82
- * with access to the space, as are non-managed `AccessToken` values.
83
- */
84
- export class McpServer extends Type.makeObject<McpServer>(DXN.make('org.dxos.type.assistant.mcpServer', '0.1.0'))(
85
- Schema.Struct({
86
- ...Spec.fields,
87
- enabled: Schema.optional(Schema.Boolean),
88
- /** Static credential sent as a Bearer token. */
89
- accessToken: Schema.optional(Ref.Ref(AccessToken.AccessToken)),
90
- /** Present once the server has been signed in to via OAuth. */
91
- oauth: Schema.optional(OAuthState),
92
- }).pipe(
93
- Annotation.LabelAnnotation.set(['name']),
94
- Annotation.IconAnnotation.set({ icon: 'ph--plugs-connected--regular', hue: 'sky' }),
95
- ),
96
- ) {}
97
-
98
- /**
99
- * The server's OAuth state as the store `@dxos/mcp-client`'s `McpOAuth` provider reads and writes,
100
- * so whichever peer refreshes the tokens (browser or EDGE agent) persists them for the others.
101
- */
102
- export const oauthStore = (server: McpServer) => ({
103
- registration: () =>
104
- server.oauth && {
105
- clientId: server.oauth.clientId,
106
- clientSecret: server.oauth.clientSecret,
107
- redirectUrl: server.oauth.redirectUrl,
108
- },
109
- saveRegistration: (registration: { clientId: string; clientSecret?: string; redirectUrl?: string } | undefined) => {
110
- // A new (or discarded) registration invalidates tokens issued to the previous client id.
111
- Obj.update(server, (server) => {
112
- if (!registration) {
113
- delete server.oauth;
114
- return;
115
- }
116
- const { clientId, clientSecret, redirectUrl } = registration;
117
- server.oauth = {
118
- clientId,
119
- ...(clientSecret !== undefined && { clientSecret }),
120
- ...(redirectUrl !== undefined && { redirectUrl }),
121
- };
122
- });
123
- },
124
- tokens: () => server.oauth?.tokens,
125
- saveTokens: (tokens: OAuthTokens | undefined) => {
126
- Obj.update(server, (server) => {
127
- if (server.oauth) {
128
- const { tokens: _previous, ...registration } = server.oauth;
129
- server.oauth = { ...registration, ...(tokens && { tokens: storedTokens(tokens) }) };
130
- }
131
- });
132
- },
133
- });
134
-
135
- /** ECHO keeps an explicit `undefined` as a key, so absent optional fields are left out instead. */
136
- const storedTokens = ({ accessToken, tokenType, refreshToken, expiresAt, scope }: OAuthTokens): OAuthTokens => ({
137
- accessToken,
138
- tokenType,
139
- ...(refreshToken !== undefined && { refreshToken }),
140
- ...(expiresAt !== undefined && { expiresAt }),
141
- ...(scope !== undefined && { scope }),
142
- });