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
  }
@@ -43573,7 +43573,15 @@ Each subdirectory of this folder is one mini app:
43573
43573
  manifest.json - { "title": string, "description"?: string, "icon"?: string,
43574
43574
  "tools"?: [{ "name", "description", "inputSchema" }] }
43575
43575
  index.html - markup only (full HTML document); do NOT reference app.js
43576
- app.js - app logic; injected automatically into the page
43576
+ app.ts - app logic (TypeScript, PREFERRED); injected automatically
43577
+ into the page as compiled JS
43578
+ app.js - legacy plain-JS logic; used only when app.ts is absent
43579
+
43580
+ The pane compiles app.ts on every change (strict mode, lib dom). Compile and
43581
+ type errors are shown in the app tab \u2014 check them after every edit and fix
43582
+ them before finishing. window.AgentPane is typed via ambient declarations
43583
+ (getState/setState/createSession/submitTurn/onToolCall/...); no import
43584
+ needed.
43577
43585
 
43578
43586
  App state does NOT live in this folder \u2014 it is stored in the pane database
43579
43587
  (app_instances table) and reached with getState()/setState().
@@ -43737,7 +43745,126 @@ function deleteAppInstances(appId) {
43737
43745
  import fs3 from "node:fs";
43738
43746
 
43739
43747
  // src/apps/headless-runtime.ts
43748
+ import vm2 from "node:vm";
43749
+
43750
+ // src/apps/app-compile.ts
43740
43751
  import vm from "node:vm";
43752
+ import ts from "typescript";
43753
+ var APP_TS = "app.ts";
43754
+ var BRIDGE_DTS_FILE = "agentpane.d.ts";
43755
+ var BRIDGE_DTS = `/** AgentPane bridge \u2014 typed contract for mini apps (ambient, no import). */
43756
+ interface AgentPaneAppInfo { id: string; title?: string }
43757
+ interface AgentPaneState { pinned: boolean; data: Record<string, unknown> | null }
43758
+ interface AgentPaneSessionInfo { id: string; title?: string | null }
43759
+ interface AgentPaneCreateSessionOptions { title?: string; runtime_type?: string; model?: string; cwd?: string }
43760
+ interface AgentPaneTurnPayload { turnId?: string; response?: string | null; error?: string }
43761
+ interface AgentPaneDeltaPayload { sessionId?: string; turnId?: string; itemId?: string; delta?: string }
43762
+ interface AgentPaneToolCallPayload { callId: string; tool: string; name: string; args: Record<string, unknown> }
43763
+
43764
+ declare const AgentPane: {
43765
+ getApp(): Promise<AgentPaneAppInfo>;
43766
+ getState(): Promise<AgentPaneState>;
43767
+ setState(data: Record<string, unknown> | null): Promise<AgentPaneState>;
43768
+ createSession(opts?: AgentPaneCreateSessionOptions): Promise<AgentPaneSessionInfo>;
43769
+ submitTurn(sessionId: string, prompt: string): Promise<unknown>;
43770
+ onTurnCompleted(cb: (event: 'turn:completed' | 'turn:failed', payload: AgentPaneTurnPayload | null) => void): void;
43771
+ onTurnDelta(cb: (payload: AgentPaneDeltaPayload) => void): void;
43772
+ onToolCall(cb: (payload: AgentPaneToolCallPayload) => void): void;
43773
+ onStateChanged(cb: (payload: unknown) => void): void;
43774
+ resolveToolCall(callId: string, result?: unknown): Promise<{ ok: boolean }>;
43775
+ };
43776
+ `;
43777
+ var cache = /* @__PURE__ */ new Map();
43778
+ function invalidateCompiledApp(appId) {
43779
+ if (!appId) cache.clear();
43780
+ else cache.delete(appId);
43781
+ }
43782
+ function tsDiagnosticToFile(file, d) {
43783
+ if (!d.file) return null;
43784
+ const pos = d.file.getLineAndCharacterOfPosition(d.start ?? 0);
43785
+ return {
43786
+ severity: d.category === ts.DiagnosticCategory.Error ? "error" : "warning",
43787
+ file,
43788
+ line: pos.line + 1,
43789
+ column: pos.character + 1,
43790
+ message: ts.flattenDiagnosticMessageText(d.messageText, "\n")
43791
+ };
43792
+ }
43793
+ function typeCheckAppTs(source) {
43794
+ const options = {
43795
+ noEmit: true,
43796
+ target: ts.ScriptTarget.ES2020,
43797
+ module: ts.ModuleKind.None,
43798
+ lib: ["lib.es2020.d.ts", "lib.dom.d.ts"],
43799
+ strict: true,
43800
+ skipLibCheck: true
43801
+ };
43802
+ const host = ts.createCompilerHost(options);
43803
+ const origReadFile = host.readFile.bind(host);
43804
+ const origFileExists = host.fileExists.bind(host);
43805
+ host.readFile = (fname) => {
43806
+ if (fname === APP_TS) return source;
43807
+ if (fname === BRIDGE_DTS_FILE) return BRIDGE_DTS;
43808
+ return origReadFile(fname);
43809
+ };
43810
+ host.fileExists = (fname) => fname === APP_TS || fname === BRIDGE_DTS_FILE ? true : origFileExists(fname);
43811
+ host.writeFile = () => {
43812
+ };
43813
+ const program = ts.createProgram([APP_TS, BRIDGE_DTS_FILE], options, host);
43814
+ const appFile = program.getSourceFile(APP_TS);
43815
+ if (!appFile) return [];
43816
+ return [...program.getSyntacticDiagnostics(appFile), ...program.getSemanticDiagnostics(appFile)].map((d) => tsDiagnosticToFile(APP_TS, d)).filter((d) => d !== null);
43817
+ }
43818
+ function checkJsSyntax(js) {
43819
+ try {
43820
+ new vm.Script(js, { filename: "app.js" });
43821
+ return [];
43822
+ } catch (err) {
43823
+ const stack = err.stack ?? "";
43824
+ const m = stack.match(/app\.js:(\d+)/);
43825
+ return [
43826
+ {
43827
+ severity: "error",
43828
+ file: "app.js",
43829
+ line: m ? Number(m[1]) : 0,
43830
+ column: 0,
43831
+ message: err.message
43832
+ }
43833
+ ];
43834
+ }
43835
+ }
43836
+ function compileAppJs(appId) {
43837
+ const cached = cache.get(appId);
43838
+ if (cached) return cached;
43839
+ const tsSource = readAppFile(appId, APP_TS);
43840
+ let result;
43841
+ if (tsSource.trim()) {
43842
+ const transpiled = ts.transpileModule(tsSource, {
43843
+ compilerOptions: { target: ts.ScriptTarget.ES2020, module: ts.ModuleKind.None },
43844
+ reportDiagnostics: true,
43845
+ fileName: APP_TS
43846
+ });
43847
+ const syntaxDiags = (transpiled.diagnostics ?? []).map((d) => tsDiagnosticToFile(APP_TS, d)).filter((d) => d !== null);
43848
+ const blocked = syntaxDiags.some((d) => d.severity === "error");
43849
+ result = {
43850
+ js: blocked ? "" : transpiled.outputText,
43851
+ sourceFile: "app.ts",
43852
+ diagnostics: blocked ? syntaxDiags : [...syntaxDiags, ...typeCheckAppTs(tsSource)]
43853
+ };
43854
+ } else {
43855
+ const js = readAppFile(appId, "app.js");
43856
+ if (!js.trim()) {
43857
+ result = { js: "", sourceFile: null, diagnostics: [] };
43858
+ } else {
43859
+ const syntaxDiags = checkJsSyntax(js);
43860
+ result = { js: syntaxDiags.length ? "" : js, sourceFile: "app.js", diagnostics: syntaxDiags };
43861
+ }
43862
+ }
43863
+ cache.set(appId, result);
43864
+ return result;
43865
+ }
43866
+
43867
+ // src/apps/headless-runtime.ts
43741
43868
  var HEADLESS_TOOL_TIMEOUT_MS = Number(process.env.AGENT_PANE_TOOL_TIMEOUT_MS ?? 3e4);
43742
43869
  function stub() {
43743
43870
  const fn = function stub2() {
@@ -43765,7 +43892,7 @@ function getHeadlessToolHandler(appId, workspace = "") {
43765
43892
  const key = runtimeKey(appId, workspace);
43766
43893
  const cached = runtimes.get(key);
43767
43894
  if (cached) return cached.handler;
43768
- const js = readAppFile(appId, "app.js");
43895
+ const js = compileAppJs(appId).js;
43769
43896
  if (!js.trim()) return null;
43770
43897
  const manifest = readManifest(appId);
43771
43898
  let handler = null;
@@ -43820,8 +43947,8 @@ function getHeadlessToolHandler(appId, workspace = "") {
43820
43947
  sandbox.window = windowObj;
43821
43948
  sandbox.self = windowObj;
43822
43949
  try {
43823
- const context = vm.createContext(sandbox);
43824
- vm.runInContext(js, context, { filename: `${appId}/app.js` });
43950
+ const context = vm2.createContext(sandbox);
43951
+ vm2.runInContext(js, context, { filename: `${appId}/app.js` });
43825
43952
  } catch (err) {
43826
43953
  console.warn(`[headless:${appId}] app.js load failed: ${err.message}`);
43827
43954
  return null;
@@ -43864,6 +43991,7 @@ function resolveHeadlessToolCall(callId, result) {
43864
43991
  return true;
43865
43992
  }
43866
43993
  function invalidateHeadlessRuntime(appId) {
43994
+ invalidateCompiledApp(appId);
43867
43995
  if (!appId) {
43868
43996
  runtimes.clear();
43869
43997
  return;
@@ -43968,19 +44096,24 @@ var SKELETON_HTML = `<!DOCTYPE html>
43968
44096
  </body>
43969
44097
  </html>
43970
44098
  `;
43971
- var SKELETON_JS = `// Skeleton mini app. window.AgentPane is the pane bridge:
44099
+ var SKELETON_TS = `// Skeleton mini app (TypeScript). window.AgentPane is the typed pane bridge:
43972
44100
  // getState() / setState(data) persistent state (survives reloads)
43973
44101
  // createSession / submitTurn talk to an agent session
43974
44102
  // onTurnCompleted / onToolCall react to agent events
43975
- var ui = { ready: false };
44103
+ interface Ui {
44104
+ ready: boolean;
44105
+ data: Record<string, unknown>;
44106
+ }
44107
+
44108
+ const ui: Ui = { ready: false, data: {} };
43976
44109
 
43977
- function render() {
43978
- document.getElementById('out').textContent =
43979
- ui.ready ? 'State: ' + JSON.stringify(ui.data) : 'Loading\u2026';
44110
+ function render(): void {
44111
+ const out = document.getElementById('out');
44112
+ if (out) out.textContent = ui.ready ? 'State: ' + JSON.stringify(ui.data) : 'Loading\u2026';
43980
44113
  }
43981
44114
 
43982
- (async function init() {
43983
- var state = await AgentPane.getState();
44115
+ (async function init(): Promise<void> {
44116
+ const state = await AgentPane.getState();
43984
44117
  ui.data = (state && state.data) || {};
43985
44118
  ui.ready = true;
43986
44119
  render();
@@ -44092,7 +44225,7 @@ async function registerAppRoutes(fastify, opts) {
44092
44225
  )
44093
44226
  );
44094
44227
  fs4.writeFileSync(path5.join(dir, "index.html"), SKELETON_HTML.replaceAll("__TITLE__", cleanTitle2));
44095
- fs4.writeFileSync(path5.join(dir, "app.js"), SKELETON_JS);
44228
+ fs4.writeFileSync(path5.join(dir, "app.ts"), SKELETON_TS);
44096
44229
  return { ok: true, id };
44097
44230
  }
44098
44231
  );
@@ -44188,10 +44321,13 @@ async function registerAppRoutes(fastify, opts) {
44188
44321
  if (!APP_ID_RE.test(id)) return reply.code(400).send({ error: "Invalid app id" });
44189
44322
  const manifest = readManifest(id);
44190
44323
  if (!manifest) return reply.code(404).send({ error: "App not found" });
44324
+ const compiled = compileAppJs(id);
44191
44325
  return {
44192
44326
  manifest,
44193
44327
  html: readAppFile(id, "index.html"),
44194
- js: readAppFile(id, "app.js")
44328
+ js: compiled.js,
44329
+ sourceFile: compiled.sourceFile,
44330
+ diagnostics: compiled.diagnostics
44195
44331
  };
44196
44332
  });
44197
44333
  fastify.get(
@@ -46296,7 +46432,7 @@ async function startService(daemon, projectPath) {
46296
46432
  throw new Error(`Daemon failed to start backend for ${projectPath}: ${daemonErrorMessage(err)}`);
46297
46433
  }
46298
46434
  }
46299
- function cache(absPath, service) {
46435
+ function cache2(absPath, service) {
46300
46436
  const resolved = {
46301
46437
  baseUrl: serviceBaseUrl(service),
46302
46438
  port: service.port,
@@ -46329,22 +46465,22 @@ async function resolveBackendUrl(projectPath, opts = {}) {
46329
46465
  const match = coveringService(services, absPath);
46330
46466
  if (match && match.status === "running") {
46331
46467
  if (await backendHealthy(serviceBaseUrl(match), match.path)) {
46332
- return cache(absPath, match);
46468
+ return cache2(absPath, match);
46333
46469
  }
46334
46470
  if (!autoStart) return null;
46335
46471
  await restartService(daemon, match.name);
46336
46472
  await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
46337
- return cache(absPath, match);
46473
+ return cache2(absPath, match);
46338
46474
  }
46339
46475
  if (!autoStart) return null;
46340
46476
  if (match) {
46341
46477
  await restartService(daemon, match.name);
46342
46478
  await waitForHealthy(serviceBaseUrl(match), match.name, match.path);
46343
- return cache(absPath, match);
46479
+ return cache2(absPath, match);
46344
46480
  }
46345
46481
  const service = await startService(daemon, absPath);
46346
46482
  await waitForHealthy(serviceBaseUrl(service), service.name, absPath);
46347
- return cache(absPath, service);
46483
+ return cache2(absPath, service);
46348
46484
  }
46349
46485
 
46350
46486
  // src/repoburg/action-mapping.ts