@mastra/server 1.47.0-alpha.2 → 1.47.0-alpha.4

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 (79) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/dist/{api-schema-manifest-YB7LBQHE.js → api-schema-manifest-OQOZ53HZ.js} +3 -3
  3. package/dist/{api-schema-manifest-YB7LBQHE.js.map → api-schema-manifest-OQOZ53HZ.js.map} +1 -1
  4. package/dist/{api-schema-manifest-UURVUNXQ.cjs → api-schema-manifest-SYCCXMOC.cjs} +4 -4
  5. package/dist/{api-schema-manifest-UURVUNXQ.cjs.map → api-schema-manifest-SYCCXMOC.cjs.map} +1 -1
  6. package/dist/{chunk-PWU43QJA.js → chunk-3WE5YAL5.js} +100 -22
  7. package/dist/chunk-3WE5YAL5.js.map +1 -0
  8. package/dist/{chunk-USOMBGLF.cjs → chunk-4LQSGGSH.cjs} +100 -22
  9. package/dist/chunk-4LQSGGSH.cjs.map +1 -0
  10. package/dist/{chunk-AAA3TYIM.js → chunk-6SZGOLAP.js} +3 -3
  11. package/dist/{chunk-AAA3TYIM.js.map → chunk-6SZGOLAP.js.map} +1 -1
  12. package/dist/{chunk-CZ5EDK57.cjs → chunk-ABKWQKXZ.cjs} +4 -3
  13. package/dist/chunk-ABKWQKXZ.cjs.map +1 -0
  14. package/dist/{chunk-BIYCTKL5.js → chunk-CIWN2JM4.js} +3 -3
  15. package/dist/{chunk-BIYCTKL5.js.map → chunk-CIWN2JM4.js.map} +1 -1
  16. package/dist/{chunk-U72IZ5BP.cjs → chunk-EQ7LRJEB.cjs} +62 -62
  17. package/dist/{chunk-U72IZ5BP.cjs.map → chunk-EQ7LRJEB.cjs.map} +1 -1
  18. package/dist/{chunk-WAIWLM6T.js → chunk-GLMV4AZT.js} +4 -3
  19. package/dist/chunk-GLMV4AZT.js.map +1 -0
  20. package/dist/{chunk-J3LTFYRY.js → chunk-K4HCNNHA.js} +4 -3
  21. package/dist/chunk-K4HCNNHA.js.map +1 -0
  22. package/dist/{chunk-6UL3DHZP.js → chunk-M43CP74T.js} +7 -7
  23. package/dist/{chunk-6UL3DHZP.js.map → chunk-M43CP74T.js.map} +1 -1
  24. package/dist/{chunk-L4V4FQDA.cjs → chunk-PSC3HAPW.cjs} +57 -57
  25. package/dist/{chunk-L4V4FQDA.cjs.map → chunk-PSC3HAPW.cjs.map} +1 -1
  26. package/dist/{chunk-XOGNYKAF.cjs → chunk-PTPMBE6M.cjs} +4 -3
  27. package/dist/chunk-PTPMBE6M.cjs.map +1 -0
  28. package/dist/{chunk-L56ROTL6.cjs → chunk-S6TNTR3A.cjs} +7 -7
  29. package/dist/{chunk-L56ROTL6.cjs.map → chunk-S6TNTR3A.cjs.map} +1 -1
  30. package/dist/{chunk-55YQXUOE.cjs → chunk-TCWIDHH6.cjs} +3 -3
  31. package/dist/{chunk-55YQXUOE.cjs.map → chunk-TCWIDHH6.cjs.map} +1 -1
  32. package/dist/{chunk-MIIC4RAA.cjs → chunk-TPZFGGU4.cjs} +89 -89
  33. package/dist/{chunk-MIIC4RAA.cjs.map → chunk-TPZFGGU4.cjs.map} +1 -1
  34. package/dist/{chunk-ILVGJFCT.js → chunk-UXO4GWPT.js} +5 -5
  35. package/dist/{chunk-ILVGJFCT.js.map → chunk-UXO4GWPT.js.map} +1 -1
  36. package/dist/{chunk-R7624SPL.js → chunk-XQ5INMFW.js} +3 -3
  37. package/dist/{chunk-R7624SPL.js.map → chunk-XQ5INMFW.js.map} +1 -1
  38. package/dist/docs/SKILL.md +1 -1
  39. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  40. package/dist/server/handlers/agent-builder.cjs +17 -17
  41. package/dist/server/handlers/agent-builder.d.ts +8 -3
  42. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  43. package/dist/server/handlers/agent-builder.js +1 -1
  44. package/dist/server/handlers/harness.cjs +35 -35
  45. package/dist/server/handlers/harness.d.ts +53 -0
  46. package/dist/server/handlers/harness.d.ts.map +1 -1
  47. package/dist/server/handlers/harness.js +1 -1
  48. package/dist/server/handlers/schedules.cjs +6 -6
  49. package/dist/server/handlers/schedules.d.ts +10 -5
  50. package/dist/server/handlers/schedules.d.ts.map +1 -1
  51. package/dist/server/handlers/schedules.js +1 -1
  52. package/dist/server/handlers/system.cjs +3 -3
  53. package/dist/server/handlers/system.js +1 -1
  54. package/dist/server/handlers/workflows.cjs +27 -27
  55. package/dist/server/handlers/workflows.d.ts +12 -5
  56. package/dist/server/handlers/workflows.d.ts.map +1 -1
  57. package/dist/server/handlers/workflows.js +1 -1
  58. package/dist/server/handlers.cjs +4 -4
  59. package/dist/server/handlers.js +2 -2
  60. package/dist/server/schemas/index.cjs +18 -18
  61. package/dist/server/schemas/index.js +2 -2
  62. package/dist/server/schemas/schedules.d.ts +6 -0
  63. package/dist/server/schemas/schedules.d.ts.map +1 -1
  64. package/dist/server/schemas/workflows.d.ts +4 -0
  65. package/dist/server/schemas/workflows.d.ts.map +1 -1
  66. package/dist/server/server-adapter/index.cjs +13 -13
  67. package/dist/server/server-adapter/index.d.ts +1 -1
  68. package/dist/server/server-adapter/index.js +2 -2
  69. package/dist/server/server-adapter/routes/agent-builder.d.ts +8 -3
  70. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
  71. package/dist/server/server-adapter/routes/workflows.d.ts +12 -5
  72. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  73. package/package.json +5 -5
  74. package/dist/chunk-CZ5EDK57.cjs.map +0 -1
  75. package/dist/chunk-J3LTFYRY.js.map +0 -1
  76. package/dist/chunk-PWU43QJA.js.map +0 -1
  77. package/dist/chunk-USOMBGLF.cjs.map +0 -1
  78. package/dist/chunk-WAIWLM6T.js.map +0 -1
  79. package/dist/chunk-XOGNYKAF.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.47.0-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`462a769`](https://github.com/mastra-ai/mastra/commit/462a769da61850862ca1be3d74134d33078ee6a7), [`f328049`](https://github.com/mastra-ai/mastra/commit/f3280498c324afd2a8d36cd828f5b9f94a2dddc1), [`e545228`](https://github.com/mastra-ai/mastra/commit/e54522856934a5dc030b7b6385771e3548020d59)]:
8
+ - @mastra/core@1.47.0-alpha.4
9
+
10
+ ## 1.47.0-alpha.3
11
+
12
+ ### Minor Changes
13
+
14
+ - Enrich the harness HTTP session surface so a client can render a status line, ([#18446](https://github.com/mastra-ai/mastra/pull/18446))
15
+ read behavior settings, and scope threads per working directory.
16
+
17
+ `GET /harness/:harnessId/sessions/:resourceId` now also returns:
18
+ - `omProgress` — the status-line slice of observational-memory progress
19
+ (pending tokens vs. observation threshold, accumulated observations vs.
20
+ reflection threshold, plus projected message removal / reflection savings)
21
+ - `tokenUsage` — cumulative token usage for the current thread
22
+ - `settings` — agent behavior settings (`yolo`, `thinkingLevel`,
23
+ `notifications`, `smartEditing`)
24
+
25
+ `GET /harness/:harnessId/sessions/:resourceId/threads` accepts an optional
26
+ `tags` query param (a JSON-encoded object). A single resourceId can be shared
27
+ across git worktrees of the same repo (the id is derived from the git URL), so
28
+ passing `tags` scopes the list to threads matching every tag (e.g.
29
+ `{ projectPath }` for the working directory). Each returned thread now also
30
+ includes the scoping `tags` it was stamped with at creation.
31
+
32
+ The session event stream route (`.../stream`) now enqueues raw event objects
33
+ and lets the server adapter handle SSE framing, fixing a double-framing bug
34
+ where events were wrapped twice (`data: "data: {...}\n\n"\n\n`) and could not be
35
+ parsed by clients.
36
+
37
+ `@mastra/client-js` gains the matching types and reads:
38
+ - `HarnessOMProgress` and `HarnessSessionSettings`, surfaced on
39
+ `HarnessSessionState` (`omProgress`, `tokenUsage`, `settings`)
40
+ - a `display_state_changed` event in `KnownHarnessEvent` carrying the
41
+ status-line figures
42
+ - `HarnessSession.listThreads()` now accepts either a number (back-compat) or
43
+ `{ limit?, tags? }`
44
+
45
+ Example:
46
+
47
+ ```ts
48
+ const session = client.getHarness('code').session(resourceId);
49
+
50
+ // Scope a worktree's thread list (and resumed session) to its own threads.
51
+ await session.create({ tags: { projectPath: '/repo/worktree-a' } });
52
+ const threads = await session.listThreads({ tags: { projectPath: '/repo/worktree-a' } });
53
+
54
+ // Read the status-line figures and agent settings.
55
+ const state = await session.state();
56
+ state.omProgress; // observational-memory progress
57
+ state.tokenUsage; // cumulative token usage
58
+ state.settings; // { yolo, thinkingLevel, notifications, smartEditing }
59
+ ```
60
+
61
+ - Scope harness session creation with tags so sessions sharing a resourceId can ([#18446](https://github.com/mastra-ai/mastra/pull/18446))
62
+ each resume their own thread.
63
+
64
+ `harness.createSession()` now accepts an optional `tags` record. The tags are
65
+ (a) seeded into the new session's state, (b) stamped onto every thread the
66
+ session creates (so thread listings can be filtered back to the session's
67
+ scope), and (c) used to filter initial thread selection: a thread is a resume
68
+ candidate only when its metadata matches every provided tag. Previously, initial
69
+ thread selection only consulted the
70
+ harness-global `initialState.projectPath`; on a multi-session server (where one
71
+ Harness serves many scopes) a session could resume the most recently updated
72
+ thread from a _different_ scope that shared the resourceId. Using a generic tag
73
+ record (e.g. `{ projectPath }`) keeps room for future scoping dimensions without
74
+ further API changes.
75
+
76
+ The `@mastra/client-js` `HarnessSession.create()` method accepts `{ tags }`, and
77
+ the `POST /harness/:id/sessions` route accepts a `tags` body field.
78
+
79
+ ```ts
80
+ // before: initial thread chosen by resourceId only
81
+ const session = await harness.createSession({ resourceId, id, ownerId });
82
+
83
+ // after: initial thread scoped to this worktree via a tag
84
+ const session = await harness.createSession({
85
+ resourceId,
86
+ id,
87
+ ownerId,
88
+ tags: { projectPath: '/repo/worktree-a' },
89
+ });
90
+ ```
91
+
92
+ ### Patch Changes
93
+
94
+ - Fixed conditional workflows so that re-running or rehydrating a run (time travel) no longer leaves the wrong branch marked as active. When a paused or replayed run lands on a conditional, arms whose condition does not evaluate truthy are now correctly recorded as skipped instead of staying stuck in a running state. ([#18228](https://github.com/mastra-ai/mastra/pull/18228))
95
+
96
+ The server workflow and schedule run-status response schemas now include the `'skipped'` status so they stay in sync with core's `WorkflowRunStatus`.
97
+
98
+ - Updated dependencies [[`bf3fe49`](https://github.com/mastra-ai/mastra/commit/bf3fe49f9467dbbdb8f9eaf74e0f7971ffb19559), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`6ccf67b`](https://github.com/mastra-ai/mastra/commit/6ccf67bf075753754927a57bc2e1734ba2c820c5), [`825d8de`](https://github.com/mastra-ai/mastra/commit/825d8def9fa64c2bcc3d8dd6b49e09342c3ac5c7), [`ffa09e7`](https://github.com/mastra-ai/mastra/commit/ffa09e772a5c92270eabe2090fc42d45bd8ec4b7), [`461a7c5`](https://github.com/mastra-ai/mastra/commit/461a7c501449295287f4f0ee4b0b42344f39fcf8), [`4211472`](https://github.com/mastra-ai/mastra/commit/4211472a5a2bd319c60cd2e42d9109c3eef7ac1c), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`5c0df77`](https://github.com/mastra-ai/mastra/commit/5c0df776c40efa420f8c07a2f3ee66010296618e)]:
99
+ - @mastra/core@1.47.0-alpha.3
100
+
3
101
  ## 1.47.0-alpha.2
4
102
 
5
103
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { SERVER_ROUTES } from './chunk-6UL3DHZP.js';
1
+ import { SERVER_ROUTES } from './chunk-M43CP74T.js';
2
2
  import { schemaToJsonSchema } from './chunk-BRC4XSFG.js';
3
3
 
4
4
  // src/server/server-adapter/api-schema-manifest.ts
@@ -52,5 +52,5 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
52
52
  }
53
53
 
54
54
  export { buildApiSchemaManifest };
55
- //# sourceMappingURL=api-schema-manifest-YB7LBQHE.js.map
56
- //# sourceMappingURL=api-schema-manifest-YB7LBQHE.js.map
55
+ //# sourceMappingURL=api-schema-manifest-OQOZ53HZ.js.map
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AC;AAAA,GACH;AACF","file":"api-schema-manifest-YB7LBQHE.js","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"names":[],"mappings":";;;;AA2BA,SAAS,cAAc,MAAA,EAA4D;AACjF,EAAA,OAAO,MAAA,GAAS,kBAAA,CAAmB,MAAM,CAAA,GAAI,MAAA;AAC/C;AAEA,SAAS,aAAa,KAAA,EAAyC;AAC7D,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAK,KAAA,GAAwB,MAAA;AAChG;AAEA,SAAS,WAAW,MAAA,EAAkE;AACpF,EAAA,MAAM,OAAO,MAAA,EAAQ,IAAA;AACrB,EAAA,OAAO,MAAM,OAAA,CAAQ,IAAI,IAAI,IAAA,CAAK,IAAA,CAAK,OAAO,CAAA,GAAI,IAAA;AACpD;AAEA,SAAS,mBAAmB,cAAA,EAAiE;AAC3F,EAAA,IAAI,CAAC,cAAA,EAAgB,OAAO,EAAE,MAAM,SAAA,EAAU;AAE9C,EAAA,MAAM,IAAA,GAAO,WAAW,cAAc,CAAA;AACtC,EAAA,IAAI,IAAA,KAAS,OAAA,EAAS,OAAO,EAAE,MAAM,OAAA,EAAQ;AAC7C,EAAA,IAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAE,MAAM,QAAA,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AAQ,KAAA,CAAM,MAAA;AAAA,QACd,MAAM,KAAA,CAAM,IAAA;AAAA,QACZ,cAAc,KAAA,CAAM,YAAA;AAAA,QACpB,eAAA,EAAiB,aAAA,CAAc,KAAA,CAAM,eAAe,CAAA;AAAA,QACpD,gBAAA,EAAkB,aAAA,CAAc,KAAA,CAAM,gBAAgB,CAAA;AAAA,QACtD,UAAA,EAAY,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA;AAAA,QAC1C,cAAA;AAAA,QACA,aAAA,EAAe,mBAAmB,cAAc;AAAA,OAClD;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"api-schema-manifest-OQOZ53HZ.js","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMIIC4RAA_cjs = require('./chunk-MIIC4RAA.cjs');
3
+ var chunkTPZFGGU4_cjs = require('./chunk-TPZFGGU4.cjs');
4
4
  var chunkG54X6VE6_cjs = require('./chunk-G54X6VE6.cjs');
5
5
 
6
6
  // src/server/server-adapter/api-schema-manifest.ts
@@ -34,7 +34,7 @@ function inferResponseShape(responseSchema) {
34
34
  function isManifestRoute(route) {
35
35
  return route.responseType === "json" && !route.deprecated;
36
36
  }
37
- function buildApiSchemaManifest(routes = chunkMIIC4RAA_cjs.SERVER_ROUTES) {
37
+ function buildApiSchemaManifest(routes = chunkTPZFGGU4_cjs.SERVER_ROUTES) {
38
38
  return {
39
39
  version: 1,
40
40
  routes: routes.filter(isManifestRoute).map((route) => {
@@ -54,5 +54,5 @@ function buildApiSchemaManifest(routes = chunkMIIC4RAA_cjs.SERVER_ROUTES) {
54
54
  }
55
55
 
56
56
  exports.buildApiSchemaManifest = buildApiSchemaManifest;
57
- //# sourceMappingURL=api-schema-manifest-UURVUNXQ.cjs.map
58
- //# sourceMappingURL=api-schema-manifest-UURVUNXQ.cjs.map
57
+ //# sourceMappingURL=api-schema-manifest-SYCCXMOC.cjs.map
58
+ //# sourceMappingURL=api-schema-manifest-SYCCXMOC.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"names":["schemaToJsonSchema","SERVER_ROUTES"],"mappings":";;;;;;AA2BA,SAAS,cAAc,MAAA,EAA4D;AACjF,EAAA,OAAO,MAAA,GAASA,oCAAA,CAAmB,MAAM,CAAA,GAAI,MAAA;AAC/C;AAEA,SAAS,aAAa,KAAA,EAAyC;AAC7D,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAK,KAAA,GAAwB,MAAA;AAChG;AAEA,SAAS,WAAW,MAAA,EAAkE;AACpF,EAAA,MAAM,OAAO,MAAA,EAAQ,IAAA;AACrB,EAAA,OAAO,MAAM,OAAA,CAAQ,IAAI,IAAI,IAAA,CAAK,IAAA,CAAK,OAAO,CAAA,GAAI,IAAA;AACpD;AAEA,SAAS,mBAAmB,cAAA,EAAiE;AAC3F,EAAA,IAAI,CAAC,cAAA,EAAgB,OAAO,EAAE,MAAM,SAAA,EAAU;AAE9C,EAAA,MAAM,IAAA,GAAO,WAAW,cAAc,CAAA;AACtC,EAAA,IAAI,IAAA,KAAS,OAAA,EAAS,OAAO,EAAE,MAAM,OAAA,EAAQ;AAC7C,EAAA,IAAI,IAAA,KAAS,QAAA,EAAU,OAAO,EAAE,MAAM,QAAA,EAAS;A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,KAAA,CAAM,MAAA;AAAA,QACd,MAAM,KAAA,CAAM,IAAA;AAAA,QACZ,cAAc,KAAA,CAAM,YAAA;AAAA,QACpB,eAAA,EAAiB,aAAA,CAAc,KAAA,CAAM,eAAe,CAAA;AAAA,QACpD,gBAAA,EAAkB,aAAA,CAAc,KAAA,CAAM,gBAAgB,CAAA;AAAA,QACtD,UAAA,EAAY,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA;AAAA,QAC1C,cAAA;AAAA,QACA,aAAA,EAAe,mBAAmB,cAAc;AAAA,OAClD;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"api-schema-manifest-UURVUNXQ.cjs","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"names":["schemaToJsonSchema","SERVER_ROUTES"],"mappings":";;;;;;AA2BA,SAAS,cAAc,MAAA,EAA4D;AACjF,EAAA,OAAO,MAAA,GAASA,oCAAA,CAAmB,MAAM,CAAA,GAAI,MAAA;AAC/C;AAEA,SAAS,aAAa,KAAA,EAAyC;AAC7D,EAAA,OAAO,KAAA,IAAS,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAK,KAAA,GAAwB,MAAA;AAChG;AAEA,SAAS,WAAW,MAAA,EAAkE;AACpF,EAAA,MAAM,OAAO,MAAA,EAAQ,IAAA;AACrB,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,SAAS,gBAAgB,KAAA,EAA6B;AACpD,EAAA,OAAO,KAAA,CAAM,YAAA,KAAiB,MAAA,IAAU,CAAC,KAAA,CAAM,UAAA;AACjD;AAEO,SAAS,sBAAA,CAAuB,SAAiCC,+BAAA,EAAkC;AACxG,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,CAAA;AAAA,IACT,QAAQ,MAAA,CAAO,MAAA,CAAO,eAAe,CAAA,CAAE,IAAI,CAAA,KAAA,KAAS;AAClD,MAAA,MAAM,cAAA,GAAiB,aAAA,CAAc,KAAA,CAAM,cAAc,CAAA;AACzD,MAAA,OAAO;AAAA,QACL,QAAQ,KAAA,CAAM,MAAA;AAAA,QACd,MAAM,KAAA,CAAM,IAAA;AAAA,QACZ,cAAc,KAAA,CAAM,YAAA;AAAA,QACpB,eAAA,EAAiB,aAAA,CAAc,KAAA,CAAM,eAAe,CAAA;AAAA,QACpD,gBAAA,EAAkB,aAAA,CAAc,KAAA,CAAM,gBAAgB,CAAA;AAAA,QACtD,UAAA,EAAY,aAAA,CAAc,KAAA,CAAM,UAAU,CAAA;AAAA,QAC1C,cAAA;AAAA,QACA,aAAA,EAAe,mBAAmB,cAAc;AAAA,OAClD;AAAA,IACF,CAAC;AAAA,GACH;AACF","file":"api-schema-manifest-SYCCXMOC.cjs","sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema']): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema);\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema),\n queryParamSchema: convertSchema(route.queryParamSchema),\n bodySchema: convertSchema(route.bodySchema),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"]}
@@ -3,6 +3,9 @@ import { createRoute } from './chunk-BRC4XSFG.js';
3
3
  import { HTTPException } from './chunk-6QWQZI4Q.js';
4
4
  import { z } from 'zod/v4';
5
5
 
6
+ function isReservedThreadMetadataKey(key) {
7
+ return key === "currentModelId" || key === "currentModeId" || key === "observerModelId" || key === "reflectorModelId" || key === "observationThreshold" || key === "reflectionThreshold" || key === "tokenUsage" || key.startsWith("modeModelId_");
8
+ }
6
9
  function getHarnessOrThrow(mastra, harnessId) {
7
10
  const harness = mastra.getHarness(harnessId);
8
11
  if (!harness) {
@@ -10,13 +13,16 @@ function getHarnessOrThrow(mastra, harnessId) {
10
13
  }
11
14
  return harness;
12
15
  }
13
- async function getSession(harness, resourceId) {
16
+ async function getSession(harness, resourceId, tags) {
14
17
  await harness.init();
15
- return harness.createSession({ resourceId, id: resourceId, ownerId: harness.id });
18
+ return harness.createSession({ resourceId, id: resourceId, ownerId: harness.id, tags });
16
19
  }
17
20
  var harnessIdPathParams = z.object({ harnessId: z.string() });
18
21
  var sessionPathParams = z.object({ harnessId: z.string(), resourceId: z.string() });
19
- var createSessionBodySchema = z.object({ resourceId: z.string() });
22
+ var createSessionBodySchema = z.object({
23
+ resourceId: z.string(),
24
+ tags: z.record(z.string(), z.string()).optional()
25
+ });
20
26
  var sendMessageBodySchema = z.object({ message: z.string() });
21
27
  var steerBodySchema = z.object({ message: z.string() });
22
28
  var toolApprovalBodySchema = z.object({
@@ -45,7 +51,17 @@ var cloneThreadBodySchema = z.object({
45
51
  title: z.string().optional()
46
52
  });
47
53
  var listMessagesQuerySchema = z.object({ limit: z.coerce.number().optional() });
48
- var listThreadsQuerySchema = z.object({ limit: z.coerce.number().optional() });
54
+ var listThreadsQuerySchema = z.object({
55
+ limit: z.coerce.number().optional(),
56
+ tags: z.preprocess((value) => {
57
+ if (typeof value !== "string" || value.length === 0) return void 0;
58
+ try {
59
+ return JSON.parse(value);
60
+ } catch {
61
+ return void 0;
62
+ }
63
+ }, z.record(z.string(), z.string()).optional()).optional()
64
+ });
49
65
  var followUpBodySchema = z.object({ message: z.string() });
50
66
  var sendNotificationBodySchema = z.object({
51
67
  source: z.string(),
@@ -68,12 +84,34 @@ var createSessionResponseSchema = z.object({
68
84
  threadId: z.string().optional()
69
85
  });
70
86
  var ackResponseSchema = z.object({ ok: z.boolean() });
87
+ var omProgressSummarySchema = z.object({
88
+ status: z.string(),
89
+ pendingTokens: z.number(),
90
+ threshold: z.number(),
91
+ thresholdPercent: z.number(),
92
+ observationTokens: z.number(),
93
+ reflectionThreshold: z.number(),
94
+ reflectionThresholdPercent: z.number(),
95
+ /** Tokens the next observation will remove from the message window. */
96
+ projectedMessageRemoval: z.number(),
97
+ /** Tokens the next reflection is projected to save. */
98
+ projectedReflectionSavings: z.number()
99
+ });
100
+ var sessionSettingsSchema = z.object({
101
+ yolo: z.boolean(),
102
+ thinkingLevel: z.enum(["off", "low", "medium", "high", "xhigh"]),
103
+ notifications: z.enum(["off", "bell", "system", "both"]),
104
+ smartEditing: z.boolean()
105
+ });
71
106
  var sessionStateResponseSchema = z.object({
72
107
  harnessId: z.string(),
73
108
  resourceId: z.string(),
74
109
  threadId: z.string().optional(),
75
110
  modeId: z.string(),
76
- modelId: z.string()
111
+ modelId: z.string(),
112
+ omProgress: omProgressSummarySchema.optional(),
113
+ tokenUsage: z.record(z.string(), z.unknown()).optional(),
114
+ settings: sessionSettingsSchema.optional()
77
115
  });
78
116
  var listModesResponseSchema = z.object({
79
117
  modes: z.array(z.object({ id: z.string(), name: z.string().optional() }))
@@ -83,7 +121,9 @@ var listThreadsResponseSchema = z.object({
83
121
  z.object({
84
122
  id: z.string(),
85
123
  title: z.string().optional(),
86
- updatedAt: z.string().optional()
124
+ updatedAt: z.string().optional(),
125
+ /** The session scoping tags stamped on this thread (e.g. `{ projectPath }`). */
126
+ tags: z.record(z.string(), z.string()).optional()
87
127
  })
88
128
  )
89
129
  });
@@ -170,10 +210,10 @@ var CREATE_HARNESS_SESSION_ROUTE = createRoute({
170
210
  tags: ["Harness"],
171
211
  requiresAuth: true,
172
212
  requiresPermission: "harness:execute",
173
- handler: async ({ mastra, harnessId, resourceId }) => {
213
+ handler: async ({ mastra, harnessId, resourceId, tags }) => {
174
214
  try {
175
215
  const harness = getHarnessOrThrow(mastra, harnessId);
176
- const session = await getSession(harness, resourceId);
216
+ const session = await getSession(harness, resourceId, tags);
177
217
  return {
178
218
  harnessId,
179
219
  resourceId,
@@ -241,9 +281,7 @@ var STREAM_HARNESS_SESSION_ROUTE = createRoute({
241
281
  unsubscribe = session.subscribe((event) => {
242
282
  if (cleanedUp) return;
243
283
  try {
244
- controller.enqueue(`data: ${JSON.stringify(event)}
245
-
246
- `);
284
+ controller.enqueue(event);
247
285
  scheduleHeartbeat();
248
286
  } catch {
249
287
  cleanup();
@@ -460,12 +498,35 @@ var GET_HARNESS_SESSION_STATE_ROUTE = createRoute({
460
498
  try {
461
499
  const harness = getHarnessOrThrow(mastra, harnessId);
462
500
  const session = await getSession(harness, resourceId);
501
+ const ds = session.displayState.get();
502
+ const om = ds.omProgress;
503
+ const reflectionSavings = om.buffered.reflection.inputObservationTokens - om.buffered.reflection.observationTokens;
504
+ const st = session.state.get();
505
+ const oneOf = (value, allowed, fallback) => allowed.includes(value) ? value : fallback;
463
506
  return {
464
507
  harnessId,
465
508
  resourceId,
466
509
  threadId: session.thread.getId() ?? void 0,
467
510
  modeId: session.mode.get(),
468
- modelId: session.model.get()
511
+ modelId: session.model.get(),
512
+ omProgress: {
513
+ status: om.status,
514
+ pendingTokens: om.pendingTokens,
515
+ threshold: om.threshold,
516
+ thresholdPercent: om.thresholdPercent,
517
+ observationTokens: om.observationTokens,
518
+ reflectionThreshold: om.reflectionThreshold,
519
+ reflectionThresholdPercent: om.reflectionThresholdPercent,
520
+ projectedMessageRemoval: om.buffered.observations.projectedMessageRemoval,
521
+ projectedReflectionSavings: reflectionSavings > 0 ? reflectionSavings : 0
522
+ },
523
+ tokenUsage: ds.tokenUsage,
524
+ settings: {
525
+ yolo: st.yolo === true,
526
+ thinkingLevel: oneOf(st.thinkingLevel, ["off", "low", "medium", "high", "xhigh"], "off"),
527
+ notifications: oneOf(st.notifications, ["off", "bell", "system", "both"], "off"),
528
+ smartEditing: st.smartEditing !== false
529
+ }
469
530
  };
470
531
  } catch (error) {
471
532
  return handleError(error, "error reading harness session state");
@@ -502,25 +563,42 @@ var LIST_HARNESS_THREADS_ROUTE = createRoute({
502
563
  queryParamSchema: listThreadsQuerySchema,
503
564
  responseSchema: listThreadsResponseSchema,
504
565
  summary: "List session threads",
505
- description: "Lists the threads for the session\u2019s resource, most-recently-updated first. Pass `limit` to return only the newest N (e.g. for a sidebar).",
566
+ description: "Lists the threads for the session\u2019s resource, most-recently-updated first. Pass `limit` to return only the newest N (e.g. for a sidebar). Pass `tags` (a JSON-encoded object) to scope the list to threads matching every tag \u2014 e.g. `{ projectPath }` so git worktrees sharing a resourceId each see only their own threads.",
506
567
  tags: ["Harness"],
507
568
  requiresAuth: true,
508
569
  requiresPermission: "harness:read",
509
- handler: async ({ mastra, harnessId, resourceId, limit }) => {
570
+ handler: async ({ mastra, harnessId, resourceId, limit, tags }) => {
510
571
  try {
511
572
  const harness = getHarnessOrThrow(mastra, harnessId);
512
573
  const session = await getSession(harness, resourceId);
513
574
  const threads = await session.thread.list();
575
+ const getTags = (t) => {
576
+ const metadata = t.metadata ?? {};
577
+ const result = {};
578
+ for (const [key, value] of Object.entries(metadata)) {
579
+ if (typeof value === "string" && !isReservedThreadMetadataKey(key)) result[key] = value;
580
+ }
581
+ return result;
582
+ };
583
+ const tagEntries = tags ? Object.entries(tags).filter(([key]) => !isReservedThreadMetadataKey(key)) : [];
584
+ const scoped = tagEntries.length > 0 ? threads.filter((t) => {
585
+ const metadata = t.metadata ?? {};
586
+ return tagEntries.every(([key, value]) => metadata[key] === value);
587
+ }) : threads;
514
588
  const toTime = (t) => (t.updatedAt ?? t.createdAt)?.getTime() ?? 0;
515
- const sorted = [...threads].sort((a, b) => toTime(b) - toTime(a));
589
+ const sorted = [...scoped].sort((a, b) => toTime(b) - toTime(a));
516
590
  const max = Number(limit);
517
591
  const limited = Number.isFinite(max) && max > 0 ? sorted.slice(0, max) : sorted;
518
592
  return {
519
- threads: limited.map((t) => ({
520
- id: t.id,
521
- title: t.title,
522
- updatedAt: t.updatedAt instanceof Date ? t.updatedAt.toISOString() : void 0
523
- }))
593
+ threads: limited.map((t) => {
594
+ const threadTags = getTags(t);
595
+ return {
596
+ id: t.id,
597
+ title: t.title,
598
+ tags: Object.keys(threadTags).length > 0 ? threadTags : void 0,
599
+ updatedAt: t.updatedAt instanceof Date ? t.updatedAt.toISOString() : void 0
600
+ };
601
+ })
524
602
  };
525
603
  } catch (error) {
526
604
  return handleError(error, "error listing harness threads");
@@ -1099,5 +1177,5 @@ var SET_HARNESS_SESSION_STATE_ROUTE = createRoute({
1099
1177
  });
1100
1178
 
1101
1179
  export { ABORT_HARNESS_SESSION_ROUTE, CLEAR_HARNESS_GOAL_ROUTE, CLONE_HARNESS_THREAD_ROUTE, CREATE_HARNESS_SESSION_ROUTE, CREATE_HARNESS_THREAD_ROUTE, DELETE_HARNESS_THREAD_ROUTE, FOLLOW_UP_HARNESS_SESSION_ROUTE, GET_HARNESS_GOAL_ROUTE, GET_HARNESS_OM_RECORD_ROUTE, GET_HARNESS_PERMISSIONS_ROUTE, GET_HARNESS_RESOURCE_IDS_ROUTE, GET_HARNESS_SESSION_STATE_ROUTE, GET_HARNESS_WORKSPACE_STATUS_ROUTE, HARNESS_TOOL_APPROVAL_ROUTE, HARNESS_TOOL_SUSPENSION_ROUTE, LIST_HARNESSES_ROUTE, LIST_HARNESS_MODELS_ROUTE, LIST_HARNESS_MODES_ROUTE, LIST_HARNESS_THREADS_ROUTE, LIST_HARNESS_THREAD_MESSAGES_ROUTE, RENAME_HARNESS_THREAD_ROUTE, SEND_HARNESS_MESSAGE_ROUTE, SEND_HARNESS_NOTIFICATION_ROUTE, SET_HARNESS_CATEGORY_PERMISSION_ROUTE, SET_HARNESS_GOAL_ROUTE, SET_HARNESS_RESOURCE_ID_ROUTE, SET_HARNESS_SESSION_STATE_ROUTE, SET_HARNESS_TOOL_PERMISSION_ROUTE, STEER_HARNESS_SESSION_ROUTE, STREAM_HARNESS_SESSION_ROUTE, SWITCH_HARNESS_MODEL_ROUTE, SWITCH_HARNESS_MODE_ROUTE, SWITCH_HARNESS_THREAD_ROUTE, UPDATE_HARNESS_GOAL_ROUTE };
1102
- //# sourceMappingURL=chunk-PWU43QJA.js.map
1103
- //# sourceMappingURL=chunk-PWU43QJA.js.map
1180
+ //# sourceMappingURL=chunk-3WE5YAL5.js.map
1181
+ //# sourceMappingURL=chunk-3WE5YAL5.js.map