Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/packed-runtime-boundaries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'agent-bundle': patch
---

Keep the public API importable without optional runtime or React peers, and
keep the packed event journey's request-context probe within native hook
output fields.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Agent, agent, type JsonValue } from '@agent-bundle/runtime';
import { Agent, agent } from '@agent-bundle/runtime';
import type { AgentEventRouteProps } from 'agent-bundle';

export default async function AfterTool({ canonical }: AgentEventRouteProps) {
Expand All @@ -8,12 +8,13 @@ export default async function AfterTool({ canonical }: AgentEventRouteProps) {
id: notice.id,
message: notice.content.root.kind === 'text' ? notice.content.root.text : '',
}));
const actor: JsonValue = context.actor.state === 'available'
? { source: context.actor.source, state: context.actor.state, value: { id: context.actor.value.id } }
: { reason: context.actor.reason, state: context.actor.state };
const actorContext = context.actor.state === 'available'
? `actor available:${context.actor.source}:${context.actor.value.id}`
: `actor unavailable:${context.actor.reason}`;
return (
<Agent.Result value={{ actor }}>
<Agent.Result>
<Agent.Markdown>{`Observed ${canonical.event} from ${canonical.provenance.host}.`}</Agent.Markdown>
<Agent.Context>{actorContext}</Agent.Context>
{notices.map((notice) => (
<Agent.Context key={notice.id}>{`notice ${notice.id}: ${notice.message}`}</Agent.Context>
))}
Expand Down
26 changes: 19 additions & 7 deletions packages/agent-bundle/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { mkdtemp, rm } from 'node:fs/promises';
import { join, resolve } from 'node:path';

import {
AGENT_STATE_DEFAULT_BUDGETS,
type AgentStateBudgets,
} from '@agent-bundle/runtime/state';

import { capabilityIsSupported } from './adapters/capability-state.ts';
import { createDefaultRegistry, TargetRegistry } from './adapters/registry.ts';
import type { TargetArtifactEntry, TargetHookEntry } from './adapters/types.ts';
Expand Down Expand Up @@ -264,14 +259,21 @@ export interface InspectOptions extends ProjectOptions {

export type StateInspectionDriver = 'memory' | 'sqlite';

export interface StateInspectionBudgets {
readonly maxCommitMs: number;
readonly maxEventBytes: number;
readonly maxRevisions: number;
readonly maxStateBytes: number;
}

export type StateInspection =
| {
readonly declared: false;
}
| {
readonly budgets:
| {
readonly resolved: AgentStateBudgets;
readonly resolved: StateInspectionBudgets;
readonly source: 'declared' | 'defaults';
}
| {
Expand Down Expand Up @@ -528,6 +530,16 @@ const durableStateLocation =
const noticeLedgerInspection =
'Generated runtimes co-mount the notice ledger store at the same lifetime under reserved id @agent-bundle/runtime/agent-notice-ledger/v1.';

// Keep static inspection independent of the optional runtime peer. The
// cross-package inspection test compares these policy defaults with the
// runtime export so the two package boundaries cannot drift silently.
const agentStateDefaultBudgets: StateInspectionBudgets = Object.freeze({
maxCommitMs: 5_000,
maxEventBytes: 262_144,
maxRevisions: 100_000,
maxStateBytes: 1_048_576,
});

const stateDriver = (
lifetime: NonNullable<NormalizedPlugin['state']>['lifetime'],
): StateInspectionDriver => {
Expand All @@ -552,7 +564,7 @@ const inspectState = (model: NormalizedPlugin): StateInspection => {
? Object.freeze({ source: 'dynamic' })
: Object.freeze({
resolved: Object.freeze({
...AGENT_STATE_DEFAULT_BUDGETS,
...agentStateDefaultBudgets,
...(definition.budgets?.declared ?? {}),
}),
source: definition.budgets === undefined ? 'defaults' : 'declared',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
createCanonicalEventProps,
projectEventDocument,
validateNativeEventEnvelope,
} from '../../events/project.ts';
} from '../../events/projection.ts';
import {
canonicalAgentEvents,
type CanonicalAgentEvent,
Expand Down
Loading
Loading