repoburg 1.3.238 → 1.3.240

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 (168) hide show
  1. package/agent-pane/backend/dist/index.js +184 -48
  2. package/agent-pane/backend/dist/server.js +184 -48
  3. package/agent-pane/frontend/dist/assets/{index-DzSfNOM7.js → index-CBTsbWig.js} +100 -82
  4. package/agent-pane/frontend/dist/assets/{index-DoOFz9GF.css → index-DNe6bagG.css} +1 -1
  5. package/agent-pane/frontend/dist/index.html +2 -2
  6. package/backend/dist/bin/metadata-migrate.ts +99 -0
  7. package/backend/dist/bin/metadata-validate.ts +112 -0
  8. package/backend/dist/src/agents/agents.module.js +0 -3
  9. package/backend/dist/src/agents/agents.module.js.map +1 -1
  10. package/backend/dist/src/agents/agents.service.d.ts +7 -5
  11. package/backend/dist/src/agents/agents.service.js +65 -39
  12. package/backend/dist/src/agents/agents.service.js.map +1 -1
  13. package/backend/dist/src/app.module.js +3 -0
  14. package/backend/dist/src/app.module.js.map +1 -1
  15. package/backend/dist/src/application-state/application-state.module.js +1 -4
  16. package/backend/dist/src/application-state/application-state.module.js.map +1 -1
  17. package/backend/dist/src/application-state/application-state.service.d.ts +3 -2
  18. package/backend/dist/src/application-state/application-state.service.js +7 -5
  19. package/backend/dist/src/application-state/application-state.service.js.map +1 -1
  20. package/backend/dist/src/bin/metadata-migrate.d.ts +2 -0
  21. package/backend/dist/src/bin/metadata-migrate.js +70 -0
  22. package/backend/dist/src/bin/metadata-migrate.js.map +1 -0
  23. package/backend/dist/src/bin/metadata-validate.d.ts +2 -0
  24. package/backend/dist/src/bin/metadata-validate.js +87 -0
  25. package/backend/dist/src/bin/metadata-validate.js.map +1 -0
  26. package/backend/dist/src/context-generation/context-generation.module.js +0 -3
  27. package/backend/dist/src/context-generation/context-generation.module.js.map +1 -1
  28. package/backend/dist/src/context-generation/context-generation.service.d.ts +3 -4
  29. package/backend/dist/src/context-generation/context-generation.service.js +11 -20
  30. package/backend/dist/src/context-generation/context-generation.service.js.map +1 -1
  31. package/backend/dist/src/context-snippets/context-snippets.module.js +1 -7
  32. package/backend/dist/src/context-snippets/context-snippets.module.js.map +1 -1
  33. package/backend/dist/src/context-snippets/context-snippets.service.d.ts +2 -2
  34. package/backend/dist/src/context-snippets/context-snippets.service.js +5 -7
  35. package/backend/dist/src/context-snippets/context-snippets.service.js.map +1 -1
  36. package/backend/dist/src/context-templates/context-templates.module.js +1 -7
  37. package/backend/dist/src/context-templates/context-templates.module.js.map +1 -1
  38. package/backend/dist/src/context-templates/context-templates.service.d.ts +8 -5
  39. package/backend/dist/src/context-templates/context-templates.service.js +46 -75
  40. package/backend/dist/src/context-templates/context-templates.service.js.map +1 -1
  41. package/backend/dist/src/core-entities/agent.entity.js +0 -15
  42. package/backend/dist/src/core-entities/agent.entity.js.map +1 -1
  43. package/backend/dist/src/core-entities/context-template.entity.d.ts +0 -5
  44. package/backend/dist/src/core-entities/context-template.entity.js +0 -26
  45. package/backend/dist/src/core-entities/context-template.entity.js.map +1 -1
  46. package/backend/dist/src/core-entities/session-input.entity.js +0 -5
  47. package/backend/dist/src/core-entities/session-input.entity.js.map +1 -1
  48. package/backend/dist/src/core-entities/session.entity.js +0 -20
  49. package/backend/dist/src/core-entities/session.entity.js.map +1 -1
  50. package/backend/dist/src/core-entities/system-prompt.entity.d.ts +0 -2
  51. package/backend/dist/src/core-entities/system-prompt.entity.js +0 -9
  52. package/backend/dist/src/core-entities/system-prompt.entity.js.map +1 -1
  53. package/backend/dist/src/custom-snippets/custom-snippets.module.js +1 -3
  54. package/backend/dist/src/custom-snippets/custom-snippets.module.js.map +1 -1
  55. package/backend/dist/src/custom-snippets/custom-snippets.service.d.ts +2 -2
  56. package/backend/dist/src/custom-snippets/custom-snippets.service.js +6 -9
  57. package/backend/dist/src/custom-snippets/custom-snippets.service.js.map +1 -1
  58. package/backend/dist/src/custom-variables/custom-variables.module.js +1 -3
  59. package/backend/dist/src/custom-variables/custom-variables.module.js.map +1 -1
  60. package/backend/dist/src/custom-variables/custom-variables.service.d.ts +2 -2
  61. package/backend/dist/src/custom-variables/custom-variables.service.js +10 -12
  62. package/backend/dist/src/custom-variables/custom-variables.service.js.map +1 -1
  63. package/backend/dist/src/interactive-chat/chat.service.d.ts +4 -1
  64. package/backend/dist/src/interactive-chat/chat.service.js +11 -7
  65. package/backend/dist/src/interactive-chat/chat.service.js.map +1 -1
  66. package/backend/dist/src/llm-orchestration/action-handlers/get-session-history.handler.d.ts +3 -2
  67. package/backend/dist/src/llm-orchestration/action-handlers/get-session-history.handler.js +16 -9
  68. package/backend/dist/src/llm-orchestration/action-handlers/get-session-history.handler.js.map +1 -1
  69. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js +1 -1
  70. package/backend/dist/src/llm-orchestration/llm-orchestration.module.js.map +1 -1
  71. package/backend/dist/src/main.js +3 -0
  72. package/backend/dist/src/main.js.map +1 -1
  73. package/backend/dist/src/mcp/marketplace/marketplace.module.js +1 -8
  74. package/backend/dist/src/mcp/marketplace/marketplace.module.js.map +1 -1
  75. package/backend/dist/src/mcp/marketplace/marketplace.service.d.ts +3 -3
  76. package/backend/dist/src/mcp/marketplace/marketplace.service.js +14 -17
  77. package/backend/dist/src/mcp/marketplace/marketplace.service.js.map +1 -1
  78. package/backend/dist/src/mcp/mcp.module.js +1 -3
  79. package/backend/dist/src/mcp/mcp.module.js.map +1 -1
  80. package/backend/dist/src/mcp/mcp.service.d.ts +6 -5
  81. package/backend/dist/src/mcp/mcp.service.js +71 -55
  82. package/backend/dist/src/mcp/mcp.service.js.map +1 -1
  83. package/backend/dist/src/metadata-store/metadata-migration.d.ts +34 -0
  84. package/backend/dist/src/metadata-store/metadata-migration.js +151 -0
  85. package/backend/dist/src/metadata-store/metadata-migration.js.map +1 -0
  86. package/backend/dist/src/metadata-store/metadata-migration.service.d.ts +7 -0
  87. package/backend/dist/src/metadata-store/metadata-migration.service.js +46 -0
  88. package/backend/dist/src/metadata-store/metadata-migration.service.js.map +1 -0
  89. package/backend/dist/src/metadata-store/metadata-store.module.d.ts +2 -0
  90. package/backend/dist/src/metadata-store/metadata-store.module.js +79 -0
  91. package/backend/dist/src/metadata-store/metadata-store.module.js.map +1 -0
  92. package/backend/dist/src/metadata-store/metadata-store.service.d.ts +42 -0
  93. package/backend/dist/src/metadata-store/metadata-store.service.js +277 -0
  94. package/backend/dist/src/metadata-store/metadata-store.service.js.map +1 -0
  95. package/backend/dist/src/metadata-store/metadata-store.tokens.d.ts +1 -0
  96. package/backend/dist/src/metadata-store/metadata-store.tokens.js +7 -0
  97. package/backend/dist/src/metadata-store/metadata-store.tokens.js.map +1 -0
  98. package/backend/dist/src/metadata-store/metadata-store.types.d.ts +21 -0
  99. package/backend/dist/src/metadata-store/metadata-store.types.js +3 -0
  100. package/backend/dist/src/metadata-store/metadata-store.types.js.map +1 -0
  101. package/backend/dist/src/metadata-store/metadata-store.utils.d.ts +8 -0
  102. package/backend/dist/src/metadata-store/metadata-store.utils.js +37 -0
  103. package/backend/dist/src/metadata-store/metadata-store.utils.js.map +1 -0
  104. package/backend/dist/src/metadata-store/schemas/metadata-schemas.d.ts +101 -0
  105. package/backend/dist/src/metadata-store/schemas/metadata-schemas.js +407 -0
  106. package/backend/dist/src/metadata-store/schemas/metadata-schemas.js.map +1 -0
  107. package/backend/dist/src/metadata-store/store-configs.d.ts +13 -0
  108. package/backend/dist/src/metadata-store/store-configs.js +108 -0
  109. package/backend/dist/src/metadata-store/store-configs.js.map +1 -0
  110. package/backend/dist/src/seeding/agent-seeding.service.d.ts +3 -3
  111. package/backend/dist/src/seeding/agent-seeding.service.js +22 -22
  112. package/backend/dist/src/seeding/agent-seeding.service.js.map +1 -1
  113. package/backend/dist/src/seeding/context-template-seeding.service.js +5 -2
  114. package/backend/dist/src/seeding/context-template-seeding.service.js.map +1 -1
  115. package/backend/dist/src/seeding/mcp-config-seeding.service.d.ts +3 -3
  116. package/backend/dist/src/seeding/mcp-config-seeding.service.js +9 -11
  117. package/backend/dist/src/seeding/mcp-config-seeding.service.js.map +1 -1
  118. package/backend/dist/src/seeding/seeding.module.js +5 -9
  119. package/backend/dist/src/seeding/seeding.module.js.map +1 -1
  120. package/backend/dist/src/seeding/sub-agent-seeding.service.d.ts +3 -3
  121. package/backend/dist/src/seeding/sub-agent-seeding.service.js +23 -23
  122. package/backend/dist/src/seeding/sub-agent-seeding.service.js.map +1 -1
  123. package/backend/dist/src/seeding/system-prompt-seeding.service.js +6 -2
  124. package/backend/dist/src/seeding/system-prompt-seeding.service.js.map +1 -1
  125. package/backend/dist/src/seeding/tool-hook-seeding.service.d.ts +2 -2
  126. package/backend/dist/src/seeding/tool-hook-seeding.service.js +4 -5
  127. package/backend/dist/src/seeding/tool-hook-seeding.service.js.map +1 -1
  128. package/backend/dist/src/session-followup/session-followup.module.js +2 -2
  129. package/backend/dist/src/session-followup/session-followup.module.js.map +1 -1
  130. package/backend/dist/src/session-followup/session-followup.service.d.ts +3 -2
  131. package/backend/dist/src/session-followup/session-followup.service.js +10 -9
  132. package/backend/dist/src/session-followup/session-followup.service.js.map +1 -1
  133. package/backend/dist/src/session-inputs/session-inputs.module.js +1 -7
  134. package/backend/dist/src/session-inputs/session-inputs.module.js.map +1 -1
  135. package/backend/dist/src/session-inputs/session-inputs.service.d.ts +4 -2
  136. package/backend/dist/src/session-inputs/session-inputs.service.js +31 -15
  137. package/backend/dist/src/session-inputs/session-inputs.service.js.map +1 -1
  138. package/backend/dist/src/session-transfer/session-transfer.module.js +1 -7
  139. package/backend/dist/src/session-transfer/session-transfer.module.js.map +1 -1
  140. package/backend/dist/src/session-transfer/session-transfer.service.d.ts +3 -2
  141. package/backend/dist/src/session-transfer/session-transfer.service.js +12 -5
  142. package/backend/dist/src/session-transfer/session-transfer.service.js.map +1 -1
  143. package/backend/dist/src/sessions/sessions.module.js +0 -2
  144. package/backend/dist/src/sessions/sessions.module.js.map +1 -1
  145. package/backend/dist/src/sessions/sessions.service.d.ts +9 -3
  146. package/backend/dist/src/sessions/sessions.service.js +87 -39
  147. package/backend/dist/src/sessions/sessions.service.js.map +1 -1
  148. package/backend/dist/src/sub-agents/sub-agent.entity.js +0 -15
  149. package/backend/dist/src/sub-agents/sub-agent.entity.js.map +1 -1
  150. package/backend/dist/src/sub-agents/sub-agents.module.js +1 -8
  151. package/backend/dist/src/sub-agents/sub-agents.module.js.map +1 -1
  152. package/backend/dist/src/sub-agents/sub-agents.service.d.ts +7 -3
  153. package/backend/dist/src/sub-agents/sub-agents.service.js +61 -35
  154. package/backend/dist/src/sub-agents/sub-agents.service.js.map +1 -1
  155. package/backend/dist/src/system-prompts/system-prompts.module.js +0 -3
  156. package/backend/dist/src/system-prompts/system-prompts.module.js.map +1 -1
  157. package/backend/dist/src/system-prompts/system-prompts.service.d.ts +7 -4
  158. package/backend/dist/src/system-prompts/system-prompts.service.js +23 -28
  159. package/backend/dist/src/system-prompts/system-prompts.service.js.map +1 -1
  160. package/backend/dist/src/tool-hooks/tool-hooks.module.js +1 -3
  161. package/backend/dist/src/tool-hooks/tool-hooks.module.js.map +1 -1
  162. package/backend/dist/src/tool-hooks/tool-hooks.service.d.ts +2 -2
  163. package/backend/dist/src/tool-hooks/tool-hooks.service.js +5 -7
  164. package/backend/dist/src/tool-hooks/tool-hooks.service.js.map +1 -1
  165. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  166. package/backend/package.json +2 -0
  167. package/miniapp-typesafe-verified.png +0 -0
  168. package/package.json +1 -1
@@ -76,7 +76,7 @@ var require_queue = __commonJS({
76
76
  if (!(_concurrency >= 1)) {
77
77
  throw new Error("fastqueue concurrency must be equal to or greater than 1");
78
78
  }
79
- var cache2 = reusify(Task);
79
+ var cache3 = reusify(Task);
80
80
  var queueHead = null;
81
81
  var queueTail = null;
82
82
  var _running = 0;
@@ -155,7 +155,7 @@ var require_queue = __commonJS({
155
155
  return _running === 0 && self.length() === 0;
156
156
  }
157
157
  function push(value, done) {
158
- var current = cache2.get();
158
+ var current = cache3.get();
159
159
  current.context = context;
160
160
  current.release = release;
161
161
  current.value = value;
@@ -176,7 +176,7 @@ var require_queue = __commonJS({
176
176
  }
177
177
  }
178
178
  function unshift(value, done) {
179
- var current = cache2.get();
179
+ var current = cache3.get();
180
180
  current.context = context;
181
181
  current.release = release;
182
182
  current.value = value;
@@ -198,7 +198,7 @@ var require_queue = __commonJS({
198
198
  }
199
199
  function release(holder) {
200
200
  if (holder) {
201
- cache2.release(holder);
201
+ cache3.release(holder);
202
202
  }
203
203
  var next = queueHead;
204
204
  if (next && _running <= _concurrency) {
@@ -3985,7 +3985,7 @@ var require_content_type = __commonJS({
3985
3985
  var quotedPairReg = /\\([\t\u0020-\u00ff])/gu;
3986
3986
  var typeNameReg = /^[\w!#$%&'*+.^`|~-]+$/;
3987
3987
  var subtypeNameReg = /^[\w!#$%&'*+.^`|~-]+\s*$/;
3988
- var cache2 = new Lru(100);
3988
+ var cache3 = new Lru(100);
3989
3989
  var ContentType = class _ContentType {
3990
3990
  #valid = false;
3991
3991
  #empty = true;
@@ -3999,7 +3999,7 @@ var require_content_type = __commonJS({
3999
3999
  * @type {Lru<ContentType>}
4000
4000
  */
4001
4001
  static get cache() {
4002
- return cache2;
4002
+ return cache3;
4003
4003
  }
4004
4004
  /**
4005
4005
  * Create a ContentType instance from a header value. If the value has been
@@ -4008,10 +4008,10 @@ var require_content_type = __commonJS({
4008
4008
  * @returns {ContentType | undefined}
4009
4009
  */
4010
4010
  static from(headerValue) {
4011
- let contentType = cache2.get(headerValue);
4011
+ let contentType = cache3.get(headerValue);
4012
4012
  if (contentType !== void 0) return contentType;
4013
4013
  contentType = new _ContentType(headerValue);
4014
- cache2.set(headerValue, contentType);
4014
+ cache3.set(headerValue, contentType);
4015
4015
  return contentType;
4016
4016
  }
4017
4017
  constructor(headerValue) {
@@ -8982,12 +8982,12 @@ var require_levels = __commonJS({
8982
8982
  function genLsCache(instance2) {
8983
8983
  const formatter = instance2[formattersSym].level;
8984
8984
  const { labels } = instance2.levels;
8985
- const cache2 = {};
8985
+ const cache3 = {};
8986
8986
  for (const label in labels) {
8987
8987
  const level = formatter(labels[label], Number(label));
8988
- cache2[label] = JSON.stringify(level).slice(0, -1);
8988
+ cache3[label] = JSON.stringify(level).slice(0, -1);
8989
8989
  }
8990
- instance2[lsCacheSym] = cache2;
8990
+ instance2[lsCacheSym] = cache3;
8991
8991
  return instance2;
8992
8992
  }
8993
8993
  function isStandardLevel(level, useOnlyCustomLevels) {
@@ -15405,8 +15405,8 @@ var require_dataType = __commonJS({
15405
15405
  return types;
15406
15406
  }
15407
15407
  exports.getSchemaTypes = getSchemaTypes;
15408
- function getJSONTypes(ts) {
15409
- const types = Array.isArray(ts) ? ts : ts ? [ts] : [];
15408
+ function getJSONTypes(ts2) {
15409
+ const types = Array.isArray(ts2) ? ts2 : ts2 ? [ts2] : [];
15410
15410
  if (types.every(rules_1.isJSONType))
15411
15411
  return types;
15412
15412
  throw new Error("type must be JSONType or JSONType[]: " + types.join(","));
@@ -16448,18 +16448,18 @@ var require_validate = __commonJS({
16448
16448
  });
16449
16449
  narrowSchemaTypes(it, types);
16450
16450
  }
16451
- function checkMultipleTypes(it, ts) {
16452
- if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
16451
+ function checkMultipleTypes(it, ts2) {
16452
+ if (ts2.length > 1 && !(ts2.length === 2 && ts2.includes("null"))) {
16453
16453
  strictTypesError(it, "use allowUnionTypes to allow union type keyword");
16454
16454
  }
16455
16455
  }
16456
- function checkKeywordTypes(it, ts) {
16456
+ function checkKeywordTypes(it, ts2) {
16457
16457
  const rules = it.self.RULES.all;
16458
16458
  for (const keyword in rules) {
16459
16459
  const rule = rules[keyword];
16460
16460
  if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
16461
16461
  const { type } = rule.definition;
16462
- if (type.length && !type.some((t) => hasApplicableType(ts, t))) {
16462
+ if (type.length && !type.some((t) => hasApplicableType(ts2, t))) {
16463
16463
  strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`);
16464
16464
  }
16465
16465
  }
@@ -16468,18 +16468,18 @@ var require_validate = __commonJS({
16468
16468
  function hasApplicableType(schTs, kwdT) {
16469
16469
  return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
16470
16470
  }
16471
- function includesType(ts, t) {
16472
- return ts.includes(t) || t === "integer" && ts.includes("number");
16471
+ function includesType(ts2, t) {
16472
+ return ts2.includes(t) || t === "integer" && ts2.includes("number");
16473
16473
  }
16474
16474
  function narrowSchemaTypes(it, withTypes) {
16475
- const ts = [];
16475
+ const ts2 = [];
16476
16476
  for (const t of it.dataTypes) {
16477
16477
  if (includesType(withTypes, t))
16478
- ts.push(t);
16478
+ ts2.push(t);
16479
16479
  else if (withTypes.includes("integer") && t === "number")
16480
- ts.push("integer");
16480
+ ts2.push("integer");
16481
16481
  }
16482
- it.dataTypes = ts;
16482
+ it.dataTypes = ts2;
16483
16483
  }
16484
16484
  function strictTypesError(it, msg) {
16485
16485
  const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
@@ -28885,7 +28885,7 @@ var require_range = __commonJS({
28885
28885
  range = range.replace(BUILDSTRIPRE, "");
28886
28886
  const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
28887
28887
  const memoKey = memoOpts + ":" + range;
28888
- const cached = cache2.get(memoKey);
28888
+ const cached = cache3.get(memoKey);
28889
28889
  if (cached) {
28890
28890
  return cached;
28891
28891
  }
@@ -28919,7 +28919,7 @@ var require_range = __commonJS({
28919
28919
  rangeMap.delete("");
28920
28920
  }
28921
28921
  const result = [...rangeMap.values()];
28922
- cache2.set(memoKey, result);
28922
+ cache3.set(memoKey, result);
28923
28923
  return result;
28924
28924
  }
28925
28925
  intersects(range, options) {
@@ -28958,7 +28958,7 @@ var require_range = __commonJS({
28958
28958
  };
28959
28959
  module.exports = Range;
28960
28960
  var LRU = require_lrucache();
28961
- var cache2 = new LRU();
28961
+ var cache3 = new LRU();
28962
28962
  var parseOptions = require_parse_options();
28963
28963
  var Comparator = require_comparator();
28964
28964
  var debug = require_debug2();
@@ -29908,12 +29908,12 @@ var require_plugin_utils = __commonJS({
29908
29908
  if (display) {
29909
29909
  return display;
29910
29910
  }
29911
- const cache2 = __require.cache;
29912
- if (cache2) {
29913
- const keys = Object.keys(cache2);
29911
+ const cache3 = __require.cache;
29912
+ if (cache3) {
29913
+ const keys = Object.keys(cache3);
29914
29914
  for (let i = 0; i < keys.length; i++) {
29915
29915
  const key = keys[i];
29916
- if (cache2[key].exports === func) {
29916
+ if (cache3[key].exports === func) {
29917
29917
  return key;
29918
29918
  }
29919
29919
  }
@@ -43560,7 +43560,15 @@ Each subdirectory of this folder is one mini app:
43560
43560
  manifest.json - { "title": string, "description"?: string, "icon"?: string,
43561
43561
  "tools"?: [{ "name", "description", "inputSchema" }] }
43562
43562
  index.html - markup only (full HTML document); do NOT reference app.js
43563
- app.js - app logic; injected automatically into the page
43563
+ app.ts - app logic (TypeScript, PREFERRED); injected automatically
43564
+ into the page as compiled JS
43565
+ app.js - legacy plain-JS logic; used only when app.ts is absent
43566
+
43567
+ The pane compiles app.ts on every change (strict mode, lib dom). Compile and
43568
+ type errors are shown in the app tab \u2014 check them after every edit and fix
43569
+ them before finishing. window.AgentPane is typed via ambient declarations
43570
+ (getState/setState/createSession/submitTurn/onToolCall/...); no import
43571
+ needed.
43564
43572
 
43565
43573
  App state does NOT live in this folder \u2014 it is stored in the pane database
43566
43574
  (app_instances table) and reached with getState()/setState().
@@ -43724,7 +43732,126 @@ function deleteAppInstances(appId) {
43724
43732
  import fs3 from "node:fs";
43725
43733
 
43726
43734
  // src/apps/headless-runtime.ts
43735
+ import vm2 from "node:vm";
43736
+
43737
+ // src/apps/app-compile.ts
43727
43738
  import vm from "node:vm";
43739
+ import ts from "typescript";
43740
+ var APP_TS = "app.ts";
43741
+ var BRIDGE_DTS_FILE = "agentpane.d.ts";
43742
+ var BRIDGE_DTS = `/** AgentPane bridge \u2014 typed contract for mini apps (ambient, no import). */
43743
+ interface AgentPaneAppInfo { id: string; title?: string }
43744
+ interface AgentPaneState { pinned: boolean; data: Record<string, unknown> | null }
43745
+ interface AgentPaneSessionInfo { id: string; title?: string | null }
43746
+ interface AgentPaneCreateSessionOptions { title?: string; runtime_type?: string; model?: string; cwd?: string }
43747
+ interface AgentPaneTurnPayload { turnId?: string; response?: string | null; error?: string }
43748
+ interface AgentPaneDeltaPayload { sessionId?: string; turnId?: string; itemId?: string; delta?: string }
43749
+ interface AgentPaneToolCallPayload { callId: string; tool: string; name: string; args: Record<string, unknown> }
43750
+
43751
+ declare const AgentPane: {
43752
+ getApp(): Promise<AgentPaneAppInfo>;
43753
+ getState(): Promise<AgentPaneState>;
43754
+ setState(data: Record<string, unknown> | null): Promise<AgentPaneState>;
43755
+ createSession(opts?: AgentPaneCreateSessionOptions): Promise<AgentPaneSessionInfo>;
43756
+ submitTurn(sessionId: string, prompt: string): Promise<unknown>;
43757
+ onTurnCompleted(cb: (event: 'turn:completed' | 'turn:failed', payload: AgentPaneTurnPayload | null) => void): void;
43758
+ onTurnDelta(cb: (payload: AgentPaneDeltaPayload) => void): void;
43759
+ onToolCall(cb: (payload: AgentPaneToolCallPayload) => void): void;
43760
+ onStateChanged(cb: (payload: unknown) => void): void;
43761
+ resolveToolCall(callId: string, result?: unknown): Promise<{ ok: boolean }>;
43762
+ };
43763
+ `;
43764
+ var cache = /* @__PURE__ */ new Map();
43765
+ function invalidateCompiledApp(appId) {
43766
+ if (!appId) cache.clear();
43767
+ else cache.delete(appId);
43768
+ }
43769
+ function tsDiagnosticToFile(file, d) {
43770
+ if (!d.file) return null;
43771
+ const pos = d.file.getLineAndCharacterOfPosition(d.start ?? 0);
43772
+ return {
43773
+ severity: d.category === ts.DiagnosticCategory.Error ? "error" : "warning",
43774
+ file,
43775
+ line: pos.line + 1,
43776
+ column: pos.character + 1,
43777
+ message: ts.flattenDiagnosticMessageText(d.messageText, "\n")
43778
+ };
43779
+ }
43780
+ function typeCheckAppTs(source) {
43781
+ const options = {
43782
+ noEmit: true,
43783
+ target: ts.ScriptTarget.ES2020,
43784
+ module: ts.ModuleKind.None,
43785
+ lib: ["lib.es2020.d.ts", "lib.dom.d.ts"],
43786
+ strict: true,
43787
+ skipLibCheck: true
43788
+ };
43789
+ const host = ts.createCompilerHost(options);
43790
+ const origReadFile = host.readFile.bind(host);
43791
+ const origFileExists = host.fileExists.bind(host);
43792
+ host.readFile = (fname) => {
43793
+ if (fname === APP_TS) return source;
43794
+ if (fname === BRIDGE_DTS_FILE) return BRIDGE_DTS;
43795
+ return origReadFile(fname);
43796
+ };
43797
+ host.fileExists = (fname) => fname === APP_TS || fname === BRIDGE_DTS_FILE ? true : origFileExists(fname);
43798
+ host.writeFile = () => {
43799
+ };
43800
+ const program = ts.createProgram([APP_TS, BRIDGE_DTS_FILE], options, host);
43801
+ const appFile = program.getSourceFile(APP_TS);
43802
+ if (!appFile) return [];
43803
+ return [...program.getSyntacticDiagnostics(appFile), ...program.getSemanticDiagnostics(appFile)].map((d) => tsDiagnosticToFile(APP_TS, d)).filter((d) => d !== null);
43804
+ }
43805
+ function checkJsSyntax(js) {
43806
+ try {
43807
+ new vm.Script(js, { filename: "app.js" });
43808
+ return [];
43809
+ } catch (err) {
43810
+ const stack = err.stack ?? "";
43811
+ const m = stack.match(/app\.js:(\d+)/);
43812
+ return [
43813
+ {
43814
+ severity: "error",
43815
+ file: "app.js",
43816
+ line: m ? Number(m[1]) : 0,
43817
+ column: 0,
43818
+ message: err.message
43819
+ }
43820
+ ];
43821
+ }
43822
+ }
43823
+ function compileAppJs(appId) {
43824
+ const cached = cache.get(appId);
43825
+ if (cached) return cached;
43826
+ const tsSource = readAppFile(appId, APP_TS);
43827
+ let result;
43828
+ if (tsSource.trim()) {
43829
+ const transpiled = ts.transpileModule(tsSource, {
43830
+ compilerOptions: { target: ts.ScriptTarget.ES2020, module: ts.ModuleKind.None },
43831
+ reportDiagnostics: true,
43832
+ fileName: APP_TS
43833
+ });
43834
+ const syntaxDiags = (transpiled.diagnostics ?? []).map((d) => tsDiagnosticToFile(APP_TS, d)).filter((d) => d !== null);
43835
+ const blocked = syntaxDiags.some((d) => d.severity === "error");
43836
+ result = {
43837
+ js: blocked ? "" : transpiled.outputText,
43838
+ sourceFile: "app.ts",
43839
+ diagnostics: blocked ? syntaxDiags : [...syntaxDiags, ...typeCheckAppTs(tsSource)]
43840
+ };
43841
+ } else {
43842
+ const js = readAppFile(appId, "app.js");
43843
+ if (!js.trim()) {
43844
+ result = { js: "", sourceFile: null, diagnostics: [] };
43845
+ } else {
43846
+ const syntaxDiags = checkJsSyntax(js);
43847
+ result = { js: syntaxDiags.length ? "" : js, sourceFile: "app.js", diagnostics: syntaxDiags };
43848
+ }
43849
+ }
43850
+ cache.set(appId, result);
43851
+ return result;
43852
+ }
43853
+
43854
+ // src/apps/headless-runtime.ts
43728
43855
  var HEADLESS_TOOL_TIMEOUT_MS = Number(process.env.AGENT_PANE_TOOL_TIMEOUT_MS ?? 3e4);
43729
43856
  function stub() {
43730
43857
  const fn = function stub2() {
@@ -43752,7 +43879,7 @@ function getHeadlessToolHandler(appId, workspace = "") {
43752
43879
  const key = runtimeKey(appId, workspace);
43753
43880
  const cached = runtimes.get(key);
43754
43881
  if (cached) return cached.handler;
43755
- const js = readAppFile(appId, "app.js");
43882
+ const js = compileAppJs(appId).js;
43756
43883
  if (!js.trim()) return null;
43757
43884
  const manifest = readManifest(appId);
43758
43885
  let handler = null;
@@ -43807,8 +43934,8 @@ function getHeadlessToolHandler(appId, workspace = "") {
43807
43934
  sandbox.window = windowObj;
43808
43935
  sandbox.self = windowObj;
43809
43936
  try {
43810
- const context = vm.createContext(sandbox);
43811
- vm.runInContext(js, context, { filename: `${appId}/app.js` });
43937
+ const context = vm2.createContext(sandbox);
43938
+ vm2.runInContext(js, context, { filename: `${appId}/app.js` });
43812
43939
  } catch (err) {
43813
43940
  console.warn(`[headless:${appId}] app.js load failed: ${err.message}`);
43814
43941
  return null;
@@ -43851,6 +43978,7 @@ function resolveHeadlessToolCall(callId, result) {
43851
43978
  return true;
43852
43979
  }
43853
43980
  function invalidateHeadlessRuntime(appId) {
43981
+ invalidateCompiledApp(appId);
43854
43982
  if (!appId) {
43855
43983
  runtimes.clear();
43856
43984
  return;
@@ -43955,19 +44083,24 @@ var SKELETON_HTML = `<!DOCTYPE html>
43955
44083
  </body>
43956
44084
  </html>
43957
44085
  `;
43958
- var SKELETON_JS = `// Skeleton mini app. window.AgentPane is the pane bridge:
44086
+ var SKELETON_TS = `// Skeleton mini app (TypeScript). window.AgentPane is the typed pane bridge:
43959
44087
  // getState() / setState(data) persistent state (survives reloads)
43960
44088
  // createSession / submitTurn talk to an agent session
43961
44089
  // onTurnCompleted / onToolCall react to agent events
43962
- var ui = { ready: false };
44090
+ interface Ui {
44091
+ ready: boolean;
44092
+ data: Record<string, unknown>;
44093
+ }
44094
+
44095
+ const ui: Ui = { ready: false, data: {} };
43963
44096
 
43964
- function render() {
43965
- document.getElementById('out').textContent =
43966
- ui.ready ? 'State: ' + JSON.stringify(ui.data) : 'Loading\u2026';
44097
+ function render(): void {
44098
+ const out = document.getElementById('out');
44099
+ if (out) out.textContent = ui.ready ? 'State: ' + JSON.stringify(ui.data) : 'Loading\u2026';
43967
44100
  }
43968
44101
 
43969
- (async function init() {
43970
- var state = await AgentPane.getState();
44102
+ (async function init(): Promise<void> {
44103
+ const state = await AgentPane.getState();
43971
44104
  ui.data = (state && state.data) || {};
43972
44105
  ui.ready = true;
43973
44106
  render();
@@ -44079,7 +44212,7 @@ async function registerAppRoutes(fastify, opts) {
44079
44212
  )
44080
44213
  );
44081
44214
  fs4.writeFileSync(path5.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
44082
- fs4.writeFileSync(path5.join(dir, "app.js"), SKELETON_JS);
44215
+ fs4.writeFileSync(path5.join(dir, "app.ts"), SKELETON_TS);
44083
44216
  return { ok: true, id };
44084
44217
  }
44085
44218
  );
@@ -44175,10 +44308,13 @@ async function registerAppRoutes(fastify, opts) {
44175
44308
  if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
44176
44309
  const manifest = readManifest(id);
44177
44310
  if (!manifest) return reply.code(404).send({ error: "App not found" });
44311
+ const compiled = compileAppJs(id);
44178
44312
  return {
44179
44313
  manifest,
44180
44314
  html: readAppFile(id, "index.html"),
44181
- js: readAppFile(id, "app.js")
44315
+ js: compiled.js,
44316
+ sourceFile: compiled.sourceFile,
44317
+ diagnostics: compiled.diagnostics
44182
44318
  };
44183
44319
  });
44184
44320
  fastify.get(
@@ -46283,7 +46419,7 @@ async function startService(daemon, projectPath) {
46283
46419
  throw new Error(`Daemon failed to start backend for ${projectPath}: ${daemonErrorMessage(err)}`);
46284
46420
  }
46285
46421
  }
46286
- function cache(absPath, service) {
46422
+ function cache2(absPath, service) {
46287
46423
  const resolved = {
46288
46424
  baseUrl: serviceBaseUrl(service),
46289
46425
  port: service.port,
@@ -46316,22 +46452,22 @@ async function resolveBackendUrl(projectPath, opts = {}) {
46316
46452
  const match = coveringService(services, absPath);
46317
46453
  if (match && match.status === "running") {
46318
46454
  if (await backendHealthy(serviceBaseUrl(match), match.path)) {
46319
- return cache(absPath, match);
46455
+ return cache2(absPath, match);
46320
46456
  }
46321
46457
  if (!autoStart) return null;
46322
46458
  await restartService(daemon, match.name);
46323
46459
  await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
46324
- return cache(absPath, match);
46460
+ return cache2(absPath, match);
46325
46461
  }
46326
46462
  if (!autoStart) return null;
46327
46463
  if (match) {
46328
46464
  await restartService(daemon, match.name);
46329
46465
  await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
46330
- return cache(absPath, match);
46466
+ return cache2(absPath, match);
46331
46467
  }
46332
46468
  const service = await startService(daemon, absPath);
46333
46469
  await waitForHealthy(serviceBaseUrl(service), service.name, absPath);
46334
- return cache(absPath, service);
46470
+ return cache2(absPath, service);
46335
46471
  }
46336
46472
 
46337
46473
  // src/repoburg/action-mapping.ts