loopengine 0.3.74 → 0.3.75

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.
@@ -11,15 +11,31 @@ const CLOSE = '\u0002';
11
11
  // The agent's own writing (slackAgentText): formatted, links shown.
12
12
  const OPEN_AGENT = '\u0003';
13
13
  const CLOSE_AGENT = '\u0004';
14
- const MARKERS = /[\u0001-\u0004]/g;
14
+ const MARKERS = /[\u0001-\u0006]/g;
15
15
  const KEEP = /(```[\s\S]*?```|`[^`\n]*`|\u0001[\s\S]*?\u0002|\u0003[\s\S]*?\u0004)/;
16
+ // Where a kept piece sits while the text around it is converted.
17
+ const SLOT = '\u0005';
18
+ const SLOT_END = '\u0006';
19
+ const SLOTS = /\u0005(\d+)\u0006/g;
16
20
  export function toSlackMrkdwn(markdown) {
17
- return markdown
18
- // ~~old value~~ around protected text: the markers sit outside it.
19
- .replace(/~~(\u0001[^\u0002]*\u0002)~~/g, '~$1~')
21
+ // The kept pieces (code, someone else's text, the agent's writing) are
22
+ // set aside while the rest is converted as one, so formatting around
23
+ // them pairs up: "**Answered by <name>:**", "~~<old value>~~".
24
+ const kept = [];
25
+ const prose = markdown
20
26
  .split(KEEP)
21
- .map((part, i) => (i % 2 === 0 ? convertProse(part) : part.startsWith(OPEN_AGENT) ? agentMrkdwn(part.slice(1, -1)) : part))
22
- .join('')
27
+ .map((part, i) => {
28
+ if (i % 2 === 0)
29
+ return part;
30
+ kept.push(part);
31
+ return `${SLOT}${kept.length - 1}${SLOT_END}`;
32
+ })
33
+ .join('');
34
+ return convertProse(prose)
35
+ .replace(SLOTS, (_m, n) => {
36
+ const part = kept[Number(n)];
37
+ return part.startsWith(OPEN_AGENT) ? agentMrkdwn(part.slice(1, -1)) : part;
38
+ })
23
39
  .replace(MARKERS, '');
24
40
  }
25
41
  // A run of Markdown table lines ("| a | b |").
@@ -10,8 +10,12 @@ const CLOSE = '\u0002';
10
10
  // The agent's own writing (telegramAgentText): formatted, links shown.
11
11
  const OPEN_AGENT = '\u0003';
12
12
  const CLOSE_AGENT = '\u0004';
13
- const MARKERS = /[\u0001-\u0004]/g;
13
+ const MARKERS = /[\u0001-\u0006]/g;
14
14
  const KEEP = /(```[\s\S]*?```|`[^`\n]*`|\u0001[\s\S]*?\u0002|\u0003[\s\S]*?\u0004)/;
15
+ // Where a kept piece sits while the text around it is converted.
16
+ const SLOT = '\u0005';
17
+ const SLOT_END = '\u0006';
18
+ const SLOTS = /\u0005(\d+)\u0006/g;
15
19
  // Telegram's limit is 4096 characters of text after the tags are read;
16
20
  // cutting the Markdown well short of it keeps the tags whole.
17
21
  const MAX_MARKDOWN = 3800;
@@ -98,23 +102,33 @@ export function splitTelegramMarkdown(markdown, max = MAX_MARKDOWN - 100) {
98
102
  }
99
103
  export function toTelegramHtml(markdown) {
100
104
  const cut = markdown.length > MAX_MARKDOWN ? markdown.slice(0, MAX_MARKDOWN).trimEnd() + '\n…' : markdown;
101
- return cut
105
+ // The kept pieces (code, someone else's text, the agent's writing) are
106
+ // set aside while the rest is converted as one, so formatting around
107
+ // them pairs up: "**Question from <agent>:**" is bold.
108
+ const kept = [];
109
+ const prose = cut
102
110
  .split(KEEP)
103
111
  .map((part, i) => {
104
112
  if (i % 2 === 0)
105
- return convertProse(part);
106
- if (part.startsWith(OPEN_AGENT))
107
- return agentHtml(part.slice(1, -1));
108
- const plain = part.replace(MARKERS, '');
109
- if (part.startsWith(OPEN))
110
- return html(plain);
111
- if (part.startsWith('```'))
112
- return `<pre>${html(plain.slice(3, -3).replace(/^[\w-]*\n/, ''))}</pre>`;
113
- return `<code>${html(plain.slice(1, -1))}</code>`;
113
+ return part;
114
+ kept.push(part);
115
+ return `${SLOT}${kept.length - 1}${SLOT_END}`;
114
116
  })
115
- .join('')
117
+ .join('');
118
+ return convertProse(prose)
119
+ .replace(SLOTS, (_m, n) => keptHtml(kept[Number(n)]))
116
120
  .replace(MARKERS, '');
117
121
  }
122
+ function keptHtml(part) {
123
+ if (part.startsWith(OPEN_AGENT))
124
+ return agentHtml(part.slice(1, -1));
125
+ const plain = part.replace(MARKERS, '');
126
+ if (part.startsWith(OPEN))
127
+ return html(plain);
128
+ if (part.startsWith('```'))
129
+ return `<pre>${html(plain.slice(3, -3).replace(/^[\w-]*\n/, ''))}</pre>`;
130
+ return `<code>${html(plain.slice(1, -1))}</code>`;
131
+ }
118
132
  // A run of Markdown table lines ("| a | b |").
119
133
  const TABLE = /((?:^[ \t]*\|.*\|[ \t]*(?:\n|$)){2,})/m;
120
134
  /** The agent's Markdown: code and tables as fixed-width text, the rest
package/dist/index.d.ts CHANGED
@@ -105,7 +105,8 @@ export { readActauthConfig, addActauthRule, updateActauthRule, removeActauthRule
105
105
  export type { ActauthRuleInput, ActauthConfigView } from './web/actauth-admin.js';
106
106
  export { installAbility, upgradeAbility, removeAbility, listInstalledAbilities, backfillDependencies, configureAgentMcpTools, AbilityManifestError, AbilityVersionError, AbilityCollisionError, AbilityAlreadyInstalledError, AbilityNotInstalledError, } from './bin/ability-manager.js';
107
107
  export type { InstalledAbilityRecord, AbilityEnvDecl, UpgradeFileResult, McpToolChoice } from './bin/ability-manager.js';
108
- export { APP_CATALOG, AppToolsError, appCatalog, appServer, appTools, catalogServer, connectedApps, isAppAbility, loadAppIcons, refreshAppTools, setAppDefault, type AgentAppTools, type AppCatalogEntry, type AppTool, type AppView, type ConnectedApp, } from './core/mcp-apps.js';
108
+ export { APP_CATALOG, AppToolsError, appCatalog, appServer, appToolInputs, appTools, catalogServer, connectedApps, isAppAbility, loadAppIcons, refreshAppTools, setAppDefault, type AgentAppTools, type AppCatalogEntry, type AppTool, type AppView, type ConnectedApp, } from './core/mcp-apps.js';
109
+ export { UNATTENDED_NOTE } from './core/unattended.js';
109
110
  export { searchPublicAbilities, fetchLatestAbilityVersion } from './web/abilities-admin.js';
110
111
  export type { PublicAbilitySearchResult } from './web/abilities-admin.js';
111
112
  export { AbilitySourceError, abilityOrigin, readAbilitySources, saveAbilitySource, removeAbilitySource, listSourceAbilities, sourceTokenVar, type AbilitySource, type SourceAbility, type AbilityOrigin } from './core/ability-sources.js';
package/dist/index.js CHANGED
@@ -94,7 +94,8 @@ export { readSkill, writeSkill, deleteSkill, SkillInvalidIdError, SkillNotFoundE
94
94
  export { listDeclaredEnvVars, setEnvVar, unsetEnvVar, setAgentEnvVar, unsetAgentEnvVar, agentScopedEnvVarName, EnvVarNameError } from './web/env-admin.js';
95
95
  export { readActauthConfig, addActauthRule, updateActauthRule, removeActauthRule, setDefaultDecision, ActauthRuleExistsError, ActauthRuleNotFoundError, } from './web/actauth-admin.js';
96
96
  export { installAbility, upgradeAbility, removeAbility, listInstalledAbilities, backfillDependencies, configureAgentMcpTools, AbilityManifestError, AbilityVersionError, AbilityCollisionError, AbilityAlreadyInstalledError, AbilityNotInstalledError, } from './bin/ability-manager.js';
97
- export { APP_CATALOG, AppToolsError, appCatalog, appServer, appTools, catalogServer, connectedApps, isAppAbility, loadAppIcons, refreshAppTools, setAppDefault, } from './core/mcp-apps.js';
97
+ export { APP_CATALOG, AppToolsError, appCatalog, appServer, appToolInputs, appTools, catalogServer, connectedApps, isAppAbility, loadAppIcons, refreshAppTools, setAppDefault, } from './core/mcp-apps.js';
98
+ export { UNATTENDED_NOTE } from './core/unattended.js';
98
99
  export { searchPublicAbilities, fetchLatestAbilityVersion } from './web/abilities-admin.js';
99
100
  // Private ability sources, the workspace's own abilities and each
100
101
  // ability's details: the console's Abilities page and agent Abilities tab.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopengine",
3
- "version": "0.3.74",
3
+ "version": "0.3.75",
4
4
  "type": "module",
5
5
  "description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
6
6
  "license": "MIT",