@agent-native/core 0.71.0 → 0.72.0
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +38 -0
- package/corpus/core/docs/content/actions.md +23 -0
- package/corpus/core/docs/content/audit-log.md +111 -0
- package/corpus/core/package.json +2 -1
- package/corpus/core/src/action.ts +80 -1
- package/corpus/core/src/agent/production-agent.ts +27 -0
- package/corpus/core/src/agent/run-store.ts +14 -0
- package/corpus/core/src/application-state/store.ts +5 -0
- package/corpus/core/src/audit/actions/get-audit-event.ts +23 -0
- package/corpus/core/src/audit/actions/list-audit-events.ts +65 -0
- package/corpus/core/src/audit/cleanup-job.ts +100 -0
- package/corpus/core/src/audit/config.ts +91 -0
- package/corpus/core/src/audit/index.ts +43 -0
- package/corpus/core/src/audit/record.ts +143 -0
- package/corpus/core/src/audit/redact.ts +109 -0
- package/corpus/core/src/audit/store.ts +244 -0
- package/corpus/core/src/audit/types.ts +125 -0
- package/corpus/core/src/chat-threads/store.ts +10 -0
- package/corpus/core/src/client/AssistantChat.tsx +6 -0
- package/corpus/core/src/client/chat/repo-helpers.ts +38 -0
- package/corpus/core/src/db/client.ts +4 -0
- package/corpus/core/src/db/widen-columns.ts +75 -0
- package/corpus/core/src/mcp/build-server.ts +1 -0
- package/corpus/core/src/oauth-tokens/store.ts +6 -0
- package/corpus/core/src/provider-api/custom-registry.ts +8 -0
- package/corpus/core/src/resources/store.ts +10 -0
- package/corpus/core/src/scripts/runner.ts +6 -3
- package/corpus/core/src/server/action-discovery.ts +6 -0
- package/corpus/core/src/server/action-routes.ts +1 -0
- package/corpus/core/src/server/auth.ts +5 -0
- package/corpus/core/src/server/core-routes-plugin.ts +14 -0
- package/corpus/core/src/server/security-headers.ts +9 -6
- package/corpus/core/src/settings/store.ts +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +93 -0
- package/corpus/core/src/usage/store.ts +6 -0
- package/corpus/templates/calendar/app/components/calendar/GoogleConnectBanner.tsx +60 -6
- package/corpus/templates/calendar/changelog/2026-06-23-added-a-heads-up-explaining-google-s-app-not-verified-screen.md +6 -0
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +20 -43
- package/corpus/templates/clips/app/components/recorder/recording-toolbar.tsx +5 -1
- package/corpus/templates/clips/app/lib/countdown-audio-cue.ts +3 -51
- package/corpus/templates/clips/changelog/2026-06-23-public-clips-now-play-inline-in-slack-connect-a-workspac.md +6 -0
- package/corpus/templates/clips/chrome-extension/PERMISSIONS.md +72 -0
- package/corpus/templates/clips/chrome-extension/public/manifest.json +1 -10
- package/corpus/templates/clips/chrome-extension/src/background.ts +34 -1
- package/corpus/templates/clips/chrome-extension/src/content-script.ts +138 -11
- package/corpus/templates/clips/chrome-extension/src/offscreen.ts +50 -33
- package/corpus/templates/clips/chrome-extension/src/overlay.css +11 -27
- package/corpus/templates/clips/chrome-extension/src/overlay.html +7 -1
- package/corpus/templates/clips/chrome-extension/src/overlay.ts +33 -38
- package/corpus/templates/clips/chrome-extension/src/popup.ts +6 -24
- package/corpus/templates/clips/chrome-extension/vite.config.ts +5 -0
- package/corpus/templates/clips/server/lib/media-permissions.ts +5 -1
- package/corpus/templates/clips/shared/recording-audio.ts +62 -0
- package/corpus/templates/clips/shared/recording-core.ts +94 -0
- package/dist/action.d.ts +31 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +45 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/context-xray/schema.d.ts +1 -1
- package/dist/agent/observational-memory/schema.d.ts +1 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +28 -0
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +14 -0
- package/dist/agent/run-store.js.map +1 -1
- package/dist/application-state/store.d.ts.map +1 -1
- package/dist/application-state/store.js +5 -0
- package/dist/application-state/store.js.map +1 -1
- package/dist/audit/actions/get-audit-event.d.ts +11 -0
- package/dist/audit/actions/get-audit-event.d.ts.map +1 -0
- package/dist/audit/actions/get-audit-event.js +22 -0
- package/dist/audit/actions/get-audit-event.js.map +1 -0
- package/dist/audit/actions/list-audit-events.d.ts +22 -0
- package/dist/audit/actions/list-audit-events.d.ts.map +1 -0
- package/dist/audit/actions/list-audit-events.js +61 -0
- package/dist/audit/actions/list-audit-events.js.map +1 -0
- package/dist/audit/cleanup-job.d.ts +12 -0
- package/dist/audit/cleanup-job.d.ts.map +1 -0
- package/dist/audit/cleanup-job.js +93 -0
- package/dist/audit/cleanup-job.js.map +1 -0
- package/dist/audit/config.d.ts +30 -0
- package/dist/audit/config.d.ts.map +1 -0
- package/dist/audit/config.js +65 -0
- package/dist/audit/config.js.map +1 -0
- package/dist/audit/index.d.ts +13 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +6 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/record.d.ts +24 -0
- package/dist/audit/record.d.ts.map +1 -0
- package/dist/audit/record.js +106 -0
- package/dist/audit/record.js.map +1 -0
- package/dist/audit/redact.d.ts +28 -0
- package/dist/audit/redact.d.ts.map +1 -0
- package/dist/audit/redact.js +109 -0
- package/dist/audit/redact.js.map +1 -0
- package/dist/audit/store.d.ts +14 -0
- package/dist/audit/store.d.ts.map +1 -0
- package/dist/audit/store.js +219 -0
- package/dist/audit/store.js.map +1 -0
- package/dist/audit/types.d.ts +114 -0
- package/dist/audit/types.d.ts.map +1 -0
- package/dist/audit/types.js +15 -0
- package/dist/audit/types.js.map +1 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +10 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +6 -1
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/chat/repo-helpers.d.ts +16 -0
- package/dist/client/chat/repo-helpers.d.ts.map +1 -1
- package/dist/client/chat/repo-helpers.js +40 -0
- package/dist/client/chat/repo-helpers.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +3 -0
- package/dist/db/client.js.map +1 -1
- package/dist/db/widen-columns.d.ts +39 -0
- package/dist/db/widen-columns.d.ts.map +1 -0
- package/dist/db/widen-columns.js +73 -0
- package/dist/db/widen-columns.js.map +1 -0
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +1 -0
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/oauth-tokens/store.d.ts.map +1 -1
- package/dist/oauth-tokens/store.js +6 -0
- package/dist/oauth-tokens/store.js.map +1 -1
- package/dist/provider-api/custom-registry.d.ts.map +1 -1
- package/dist/provider-api/custom-registry.js +8 -0
- package/dist/provider-api/custom-registry.js.map +1 -1
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +9 -0
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/runner.js +4 -3
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +6 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +1 -0
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +5 -0
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +13 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/security-headers.d.ts +8 -5
- package/dist/server/security-headers.d.ts.map +1 -1
- package/dist/server/security-headers.js +9 -6
- package/dist/server/security-headers.js.map +1 -1
- package/dist/settings/store.d.ts.map +1 -1
- package/dist/settings/store.js +6 -0
- package/dist/settings/store.js.map +1 -1
- package/dist/templates/workspace-core/.agents/skills/audit-log/SKILL.md +93 -0
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +5 -0
- package/dist/usage/store.js.map +1 -1
- package/docs/content/actions.md +23 -0
- package/docs/content/audit-log.md +111 -0
- package/package.json +2 -1
- package/src/templates/workspace-core/.agents/skills/audit-log/SKILL.md +93 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical Clips "ready" chime, shared by every recorder surface so they
|
|
3
|
+
* all sound identical:
|
|
4
|
+
* - the web app recorder (app/lib/countdown-audio-cue.ts)
|
|
5
|
+
* - the Chrome extension (chrome-extension/src/offscreen.ts)
|
|
6
|
+
* - mirrors the desktop app's start cue
|
|
7
|
+
*
|
|
8
|
+
* Framework-free Web Audio — safe to import anywhere; the functions only touch
|
|
9
|
+
* `window`/`AudioContext` when called, so importing the module is SSR-safe.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Schedule the "ready" chime on an already-running {@link AudioContext}: a soft
|
|
14
|
+
* rising two-note (D5 → A5) with a faint high shimmer (A6). Each voice has a
|
|
15
|
+
* fast attack and a smooth exponential tail so it reads as a gentle
|
|
16
|
+
* confirmation rather than a harsh beep. Kept under ~380ms so it lands cleanly
|
|
17
|
+
* just as capture begins. The caller owns the context lifecycle; resolves once
|
|
18
|
+
* the last voice has finished.
|
|
19
|
+
*/
|
|
20
|
+
export function scheduleReadyChime(ctx: AudioContext): Promise<void> {
|
|
21
|
+
return new Promise<void>((resolve) => {
|
|
22
|
+
const t0 = ctx.currentTime + 0.005;
|
|
23
|
+
const voices = [
|
|
24
|
+
{ freq: 587.33, at: 0.0, dur: 0.22, peak: 0.06 }, // D5
|
|
25
|
+
{ freq: 880.0, at: 0.06, dur: 0.26, peak: 0.075 }, // A5
|
|
26
|
+
{ freq: 1760.0, at: 0.065, dur: 0.14, peak: 0.02 }, // A6 shimmer
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
let lastStop = t0;
|
|
30
|
+
for (const voice of voices) {
|
|
31
|
+
const startAt = t0 + voice.at;
|
|
32
|
+
const stopAt = startAt + voice.dur;
|
|
33
|
+
lastStop = Math.max(lastStop, stopAt);
|
|
34
|
+
|
|
35
|
+
const oscillator = ctx.createOscillator();
|
|
36
|
+
oscillator.type = "sine";
|
|
37
|
+
oscillator.frequency.setValueAtTime(voice.freq, startAt);
|
|
38
|
+
|
|
39
|
+
const gain = ctx.createGain();
|
|
40
|
+
gain.gain.setValueAtTime(0.0001, startAt);
|
|
41
|
+
gain.gain.exponentialRampToValueAtTime(voice.peak, startAt + 0.012);
|
|
42
|
+
gain.gain.exponentialRampToValueAtTime(0.0001, stopAt);
|
|
43
|
+
|
|
44
|
+
oscillator.connect(gain);
|
|
45
|
+
gain.connect(ctx.destination);
|
|
46
|
+
|
|
47
|
+
oscillator.start(startAt);
|
|
48
|
+
oscillator.stop(stopAt + 0.02);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let resolved = false;
|
|
52
|
+
const finish = (): void => {
|
|
53
|
+
if (resolved) return;
|
|
54
|
+
resolved = true;
|
|
55
|
+
resolve();
|
|
56
|
+
};
|
|
57
|
+
window.setTimeout(
|
|
58
|
+
finish,
|
|
59
|
+
Math.ceil((lastStop - ctx.currentTime) * 1000) + 60,
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-agnostic recording primitives shared by BOTH recorders:
|
|
3
|
+
* - the web app recorder (app/components/recorder/recorder-engine.ts)
|
|
4
|
+
* - the Chrome extension (chrome-extension/src/offscreen.ts)
|
|
5
|
+
*
|
|
6
|
+
* Keep this free of React, chrome.*, Node-only APIs, and any DOM beyond the
|
|
7
|
+
* media types (MediaRecorder, URLSearchParams) so both build targets — the
|
|
8
|
+
* Vite app build and the extension's separate Vite build — can import it.
|
|
9
|
+
*
|
|
10
|
+
* The two recorders intentionally keep their own *orchestration* and *upload
|
|
11
|
+
* strategy* (the extension streams each timeslice chunk from an offscreen
|
|
12
|
+
* document that survives navigation; the web app assembles + slices on stop with
|
|
13
|
+
* retry/compression). What MUST stay identical is the on-the-wire contract with
|
|
14
|
+
* the server's chunk-upload route and the MediaRecorder codec choice — that's
|
|
15
|
+
* what lives here.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** MediaRecorder codecs to try, best-supported first.
|
|
19
|
+
*
|
|
20
|
+
* vp8 is listed before vp9 because some display-capture streams report vp9
|
|
21
|
+
* support but reject the encoder configuration; vp8 is the most broadly
|
|
22
|
+
* accepted. MP4/avc1 is the Safari/WebKit fallback. */
|
|
23
|
+
export function pickMimeTypeCandidates(): string[] {
|
|
24
|
+
return [
|
|
25
|
+
"video/webm;codecs=vp8,opus",
|
|
26
|
+
"video/webm;codecs=vp9,opus",
|
|
27
|
+
"video/webm;codecs=vp8",
|
|
28
|
+
"video/webm;codecs=vp9",
|
|
29
|
+
"video/webm",
|
|
30
|
+
"video/mp4;codecs=avc1",
|
|
31
|
+
"video/mp4",
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** First supported codec from {@link pickMimeTypeCandidates}, or "" to let the
|
|
36
|
+
* browser pick its own default (callers should treat "" as "omit mimeType"). */
|
|
37
|
+
export function pickMimeType(): string {
|
|
38
|
+
if (typeof MediaRecorder === "undefined") return "video/webm";
|
|
39
|
+
for (const type of pickMimeTypeCandidates()) {
|
|
40
|
+
try {
|
|
41
|
+
if (MediaRecorder.isTypeSupported(type)) return type;
|
|
42
|
+
} catch {
|
|
43
|
+
// isTypeSupported can throw on some builds — treat as unsupported.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Query params understood by the chunk-upload route
|
|
50
|
+
* (`/api/uploads/:id/chunk`). This is the on-the-wire contract — the route in
|
|
51
|
+
* `server/routes/api/uploads/[recordingId]/chunk.post.ts` reads exactly these. */
|
|
52
|
+
export type ChunkUploadParams = {
|
|
53
|
+
index: number;
|
|
54
|
+
total?: number;
|
|
55
|
+
isFinal?: boolean;
|
|
56
|
+
mimeType?: string;
|
|
57
|
+
durationMs?: number;
|
|
58
|
+
width?: number;
|
|
59
|
+
height?: number;
|
|
60
|
+
hasAudio?: boolean;
|
|
61
|
+
hasCamera?: boolean;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** Encode {@link ChunkUploadParams} as the chunk-upload query string. Booleans
|
|
65
|
+
* become `1`/`0` and `durationMs` is rounded — matching what the route parses. */
|
|
66
|
+
export function chunkUploadQuery(params: ChunkUploadParams): string {
|
|
67
|
+
const q = new URLSearchParams();
|
|
68
|
+
q.set("index", String(params.index));
|
|
69
|
+
if (params.total !== undefined) q.set("total", String(params.total));
|
|
70
|
+
q.set("isFinal", params.isFinal ? "1" : "0");
|
|
71
|
+
if (params.mimeType) q.set("mimeType", params.mimeType);
|
|
72
|
+
if (params.durationMs !== undefined) {
|
|
73
|
+
q.set("durationMs", String(Math.round(params.durationMs)));
|
|
74
|
+
}
|
|
75
|
+
if (params.width !== undefined) q.set("width", String(params.width));
|
|
76
|
+
if (params.height !== undefined) q.set("height", String(params.height));
|
|
77
|
+
if (params.hasAudio !== undefined) {
|
|
78
|
+
q.set("hasAudio", params.hasAudio ? "1" : "0");
|
|
79
|
+
}
|
|
80
|
+
if (params.hasCamera !== undefined) {
|
|
81
|
+
q.set("hasCamera", params.hasCamera ? "1" : "0");
|
|
82
|
+
}
|
|
83
|
+
return q.toString();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Full chunk-upload URL: `<chunkBaseUrl>?<encoded params>`. `chunkBaseUrl` is
|
|
87
|
+
* the per-recording endpoint (e.g. `/api/uploads/<id>/chunk` or its absolute
|
|
88
|
+
* form) with no existing query string. */
|
|
89
|
+
export function chunkUploadUrl(
|
|
90
|
+
chunkBaseUrl: string,
|
|
91
|
+
params: ChunkUploadParams,
|
|
92
|
+
): string {
|
|
93
|
+
return `${chunkBaseUrl}?${chunkUploadQuery(params)}`;
|
|
94
|
+
}
|
package/dist/action.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentChatAttachment, AgentChatEvent } from "./agent/types.js";
|
|
2
2
|
import { type ActionChatUIConfig } from "./action-ui.js";
|
|
3
|
+
import type { ActionAuditConfig } from "./audit/types.js";
|
|
3
4
|
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
5
|
/**
|
|
5
6
|
* How an action's `run` was invoked. Tagged at each dispatch site so the action
|
|
@@ -66,6 +67,21 @@ export interface ActionRunContext {
|
|
|
66
67
|
* attaching an `"abort"` listener is always safe.
|
|
67
68
|
*/
|
|
68
69
|
signal?: AbortSignal;
|
|
70
|
+
/**
|
|
71
|
+
* Name of the action being invoked (the registry key, e.g.
|
|
72
|
+
* `delete-recording`). Set at each dispatch site so cross-cutting concerns —
|
|
73
|
+
* notably the audit log — can attribute the call. `undefined` for direct
|
|
74
|
+
* programmatic `run()` calls that bypass the dispatcher.
|
|
75
|
+
*/
|
|
76
|
+
actionName?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Agent conversation thread + turn that triggered this call, populated only
|
|
79
|
+
* inside the agent tool loop (`caller: "tool"`). Lets the audit log link a
|
|
80
|
+
* mutation to the specific agent run/turn that caused it. `undefined` on
|
|
81
|
+
* every human/programmatic surface.
|
|
82
|
+
*/
|
|
83
|
+
threadId?: string;
|
|
84
|
+
turnId?: string;
|
|
69
85
|
}
|
|
70
86
|
export interface AgentActionStopOptions {
|
|
71
87
|
/** Optional stable code surfaced in run metadata and tests. */
|
|
@@ -315,6 +331,14 @@ interface DefineActionWithSchema<TSchema extends StandardSchemaV1, TReturn = any
|
|
|
315
331
|
* as "approval required" (fail closed).
|
|
316
332
|
*/
|
|
317
333
|
needsApproval?: boolean | ((args: StandardSchemaV1.InferOutput<TSchema>, ctx?: ActionRunContext) => boolean | Promise<boolean>);
|
|
334
|
+
/**
|
|
335
|
+
* Audit-log configuration. **Default-on for mutating actions** — you only
|
|
336
|
+
* need this to tune capture: declare the mutated `target` (so the change
|
|
337
|
+
* shows up in the owner's audit trail) and/or a `summary`, opt a read-only
|
|
338
|
+
* action in via `onRead`, or opt a noisy action out via `enabled: false`.
|
|
339
|
+
* See the `audit-log` skill.
|
|
340
|
+
*/
|
|
341
|
+
audit?: ActionAuditConfig;
|
|
318
342
|
}
|
|
319
343
|
interface DefineActionWithParams<TParams extends Record<string, ParameterSchema> | undefined = Record<string, ParameterSchema> | undefined, TReturn = any> {
|
|
320
344
|
description: string;
|
|
@@ -362,6 +386,9 @@ interface DefineActionWithParams<TParams extends Record<string, ParameterSchema>
|
|
|
362
386
|
/** Opt-in human-in-the-loop approval gate (default off). See the schema
|
|
363
387
|
* overload above for full semantics. */
|
|
364
388
|
needsApproval?: boolean | ((args: InferParams<TParams>, ctx?: ActionRunContext) => boolean | Promise<boolean>);
|
|
389
|
+
/** Audit-log configuration (default-on for mutations). See the schema
|
|
390
|
+
* overload above and the `audit-log` skill. */
|
|
391
|
+
audit?: ActionAuditConfig;
|
|
365
392
|
}
|
|
366
393
|
/**
|
|
367
394
|
* Opaque typed wrapper returned by `defineAction`. The type parameters carry
|
|
@@ -406,6 +433,10 @@ export interface ActionDefinition<TInput, TReturn> {
|
|
|
406
433
|
* agent loop emits `approval_required` and pauses instead of executing this
|
|
407
434
|
* action until a human approves the specific call. */
|
|
408
435
|
readonly needsApproval?: boolean | ((args: TInput, ctx?: ActionRunContext) => boolean | Promise<boolean>);
|
|
436
|
+
/** Resolved audit-log configuration. Present only when the caller passed
|
|
437
|
+
* `audit`. The audit capture wrapper is baked into `run`; this field is for
|
|
438
|
+
* introspection. */
|
|
439
|
+
readonly audit?: ActionAuditConfig;
|
|
409
440
|
}
|
|
410
441
|
/**
|
|
411
442
|
* Define an agent action. Place in `actions/` directory — auto-discovered by the framework.
|
package/dist/action.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":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C,GAC/D,gBAAgB,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AACnE,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,EAC3D,OAAO,EAEP,OAAO,EAAE,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,GAChD,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
package/dist/action.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeActionChatUIConfig, } from "./action-ui.js";
|
|
2
|
+
import { normalizeAuditConfig, resolveAuditAttach } from "./audit/config.js";
|
|
2
3
|
/**
|
|
3
4
|
* Throw from an action when the agent should stop the current turn instead of
|
|
4
5
|
* feeding the failure back to the model for another retry.
|
|
@@ -74,6 +75,15 @@ export function defineAction(options) {
|
|
|
74
75
|
: inferredReadOnly
|
|
75
76
|
? true
|
|
76
77
|
: undefined;
|
|
78
|
+
// Audit: wrap the validated run so every mutating call records an audit
|
|
79
|
+
// event (who/what/when/from-where, and for the agent which run). Default-on
|
|
80
|
+
// for mutations; read-only actions opt in via `audit.onRead`. The wrapper
|
|
81
|
+
// lazily imports the DB-touching recorder so `action.ts` keeps no static DB
|
|
82
|
+
// dependency.
|
|
83
|
+
const auditConfig = normalizeAuditConfig(options.audit);
|
|
84
|
+
const finalRun = resolveAuditAttach(auditConfig, readOnly)
|
|
85
|
+
? wrapRunWithAudit(run, auditConfig)
|
|
86
|
+
: run;
|
|
77
87
|
// toolCallable: thread through whatever the caller declared. We DO NOT
|
|
78
88
|
// default to `true` here — the absence of an explicit field is meaningful
|
|
79
89
|
// to the tools bridge: it lets us emit a one-shot warning when an action
|
|
@@ -122,7 +132,7 @@ export function defineAction(options) {
|
|
|
122
132
|
description: options.description,
|
|
123
133
|
parameters: toolParameters,
|
|
124
134
|
},
|
|
125
|
-
run,
|
|
135
|
+
run: finalRun,
|
|
126
136
|
...(hasSchema ? { schema: options.schema } : {}),
|
|
127
137
|
...(options.http !== undefined ? { http: options.http } : {}),
|
|
128
138
|
...(typeof options.requiresAuth === "boolean"
|
|
@@ -149,6 +159,40 @@ export function defineAction(options) {
|
|
|
149
159
|
typeof options.needsApproval === "function"
|
|
150
160
|
? { needsApproval: options.needsApproval }
|
|
151
161
|
: {}),
|
|
162
|
+
...(auditConfig ? { audit: auditConfig } : {}),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Wrap an action's (already input/output-validated) run so each call records an
|
|
167
|
+
* audit event after it resolves — on success and on error. Best-effort: the
|
|
168
|
+
* recorder swallows its own failures and the original result/throw is always
|
|
169
|
+
* preserved, so auditing can never change an action's behavior. The DB-touching
|
|
170
|
+
* recorder is imported lazily so merely defining an action pulls in no DB code.
|
|
171
|
+
*/
|
|
172
|
+
function wrapRunWithAudit(run, auditConfig) {
|
|
173
|
+
return async function auditedRun(args, ctx) {
|
|
174
|
+
let result;
|
|
175
|
+
let error;
|
|
176
|
+
let threw = false;
|
|
177
|
+
try {
|
|
178
|
+
result = await run(args, ctx);
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
error = err;
|
|
182
|
+
threw = true;
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
const { recordActionAudit } = await import("./audit/record.js");
|
|
186
|
+
await recordActionAudit(threw
|
|
187
|
+
? { config: auditConfig, args, ctx, status: "error", error }
|
|
188
|
+
: { config: auditConfig, args, ctx, status: "success", result });
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// Recorder failed to load/run — never affect the action.
|
|
192
|
+
}
|
|
193
|
+
if (threw)
|
|
194
|
+
throw error;
|
|
195
|
+
return result;
|
|
152
196
|
};
|
|
153
197
|
}
|
|
154
198
|
// ---------------------------------------------------------------------------
|