loopengine 0.3.3 → 0.3.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.
- package/dist/core/run-events.d.ts +21 -0
- package/dist/core/run-events.js +20 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Message } from './run-agent.js';
|
|
2
|
+
export type RunEventSource = 'workflow' | 'schedule' | 'message' | 'slack' | 'telegram';
|
|
3
|
+
export interface RunEvent {
|
|
4
|
+
at: string;
|
|
5
|
+
agent: string;
|
|
6
|
+
source: RunEventSource;
|
|
7
|
+
/** The same for every report of the same job. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** workflow only: how the run started. */
|
|
10
|
+
via?: string;
|
|
11
|
+
/** message only. */
|
|
12
|
+
caller?: 'api' | 'console' | 'unknown';
|
|
13
|
+
usedTool: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type RunObserver = (event: RunEvent) => void;
|
|
16
|
+
/** Sets the one observer for this process; undefined removes it. */
|
|
17
|
+
export declare function setRunObserver(next: RunObserver | undefined): void;
|
|
18
|
+
/** Never throws: a broken observer must not fail the job. */
|
|
19
|
+
export declare function reportRun(event: Omit<RunEvent, 'at'>): void;
|
|
20
|
+
/** Whether a turn's new messages include a tool call by the agent. */
|
|
21
|
+
export declare function usedTool(newMessages: Message[]): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let observer;
|
|
2
|
+
/** Sets the one observer for this process; undefined removes it. */
|
|
3
|
+
export function setRunObserver(next) {
|
|
4
|
+
observer = next;
|
|
5
|
+
}
|
|
6
|
+
/** Never throws: a broken observer must not fail the job. */
|
|
7
|
+
export function reportRun(event) {
|
|
8
|
+
if (!observer)
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
observer({ ...event, at: new Date().toISOString() });
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
console.error('[loopengine] run observer failed:', err instanceof Error ? err.message : err);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Whether a turn's new messages include a tool call by the agent. */
|
|
18
|
+
export function usedTool(newMessages) {
|
|
19
|
+
return newMessages.some((m) => m.role === 'assistant' && Array.isArray(m.content) && m.content.some((b) => b.type === 'tool_use'));
|
|
20
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { createAgentEnv, agentDirFor, envScopeOf, type EnvScope } from '#core/ag
|
|
|
7
7
|
export { FileSecretStore, setSecretStore, getSecretStore, type SecretStore } from '#core/secret-store.js';
|
|
8
8
|
export { signProxyIdentity, verifyProxyIdentity, TRUSTED_PROXY_IDENTITY_HEADER, type ProxyIdentity } from '#core/trusted-proxy.js';
|
|
9
9
|
export { setUsageSink, recordUsage, type UsageEvent, type UsageSink } from '#core/usage.js';
|
|
10
|
+
export { setRunObserver, reportRun, usedTool, type RunEvent, type RunEventSource, type RunObserver } from '#core/run-events.js';
|
|
10
11
|
export { readNotifierFile, writeNotifierFile, removeNotifierFile, validateNotifierFile, notifierConfigFromFile, NotifierFileError, NOTIFIER_SECRET_VARS, type NotifierFile, type MessagingApprover } from '#core/notifier-file.js';
|
|
11
12
|
export { listDeliveries, recordDelivery, type NotifierDelivery } from '#core/notifier-deliveries.js';
|
|
12
13
|
export { describeNotifier } from '#core/http-notifier.js';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { createAgentEnv, agentDirFor, envScopeOf } from '#core/agent-env.js';
|
|
|
9
9
|
export { FileSecretStore, setSecretStore, getSecretStore } from '#core/secret-store.js';
|
|
10
10
|
export { signProxyIdentity, verifyProxyIdentity, TRUSTED_PROXY_IDENTITY_HEADER } from '#core/trusted-proxy.js';
|
|
11
11
|
export { setUsageSink, recordUsage } from '#core/usage.js';
|
|
12
|
+
export { setRunObserver, reportRun, usedTool } from '#core/run-events.js';
|
|
12
13
|
export { readNotifierFile, writeNotifierFile, removeNotifierFile, validateNotifierFile, notifierConfigFromFile, NotifierFileError, NOTIFIER_SECRET_VARS } from '#core/notifier-file.js';
|
|
13
14
|
export { listDeliveries, recordDelivery } from '#core/notifier-deliveries.js';
|
|
14
15
|
export { describeNotifier } from '#core/http-notifier.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loopengine",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime for tool-using AI agents with a transparent ReAct loop.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"dist/core/trusted-proxy.d.ts",
|
|
47
47
|
"dist/core/usage.js",
|
|
48
48
|
"dist/core/usage.d.ts",
|
|
49
|
+
"dist/core/run-events.js",
|
|
50
|
+
"dist/core/run-events.d.ts",
|
|
49
51
|
"dist/core/email-senders.js",
|
|
50
52
|
"dist/core/email-senders.d.ts",
|
|
51
53
|
"dist/core/notifier-file.js",
|