Skip to content
Open
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
130 changes: 129 additions & 1 deletion packages/agent-core-v2/docs/state-manifest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,48 @@ export interface SessionStateSnapshot {
readonly skillActive?: boolean;
readonly productName?: string;
readonly replyStyleGuide?: string;
readonly agentsMdStatus?: 'missing' | 'empty' | 'present';
[key: string]: unknown;
}) => string;
readonly renderSystemPrompt?: (context: /* AgentProfileContext — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly cwd?: string;
readonly cwdListing?: string;
readonly agentsMd?: string;
readonly additionalDirsInfo?: string;
readonly osKind?: string;
readonly shellName?: string;
readonly shellPath?: string;
readonly now?: string;
readonly skills?: string;
readonly skillActive?: boolean;
readonly productName?: string;
readonly replyStyleGuide?: string;
readonly agentsMdStatus?: 'missing' | 'empty' | 'present';
[key: string]: unknown;
}) => /* SystemPromptRenderResult — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly text: string;
readonly environment: /* EnvironmentDisclosureSnapshot — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly cwd: string;
readonly date: {
readonly disclosed: true;
readonly value: {
readonly localDate: string;
readonly timeZone: string;
};
} | {
readonly disclosed: false;
};
readonly agentsMd: {
readonly disclosed: true;
readonly value: {
readonly fingerprint: string;
readonly status: /* AgentsMdStatus — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ 'missing' | 'empty' | 'present';
};
} | {
readonly disclosed: false;
};
};
};
readonly promptPrefix?: (ctx: /* AgentProfilePromptPrefixContext — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly cwd: string;
readonly runner: /* ISessionProcessRunner — packages/agent-core-v2/src/session/process/processRunner.ts */ {
Expand Down Expand Up @@ -268,8 +308,48 @@ export interface SessionStateSnapshot {
readonly skillActive?: boolean;
readonly productName?: string;
readonly replyStyleGuide?: string;
readonly agentsMdStatus?: 'missing' | 'empty' | 'present';
[key: string]: unknown;
}) => string;
readonly renderSystemPrompt?: (context: /* AgentProfileContext — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly cwd?: string;
readonly cwdListing?: string;
readonly agentsMd?: string;
readonly additionalDirsInfo?: string;
readonly osKind?: string;
readonly shellName?: string;
readonly shellPath?: string;
readonly now?: string;
readonly skills?: string;
readonly skillActive?: boolean;
readonly productName?: string;
readonly replyStyleGuide?: string;
readonly agentsMdStatus?: 'missing' | 'empty' | 'present';
[key: string]: unknown;
}) => /* SystemPromptRenderResult — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly text: string;
readonly environment: /* EnvironmentDisclosureSnapshot — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly cwd: string;
readonly date: {
readonly disclosed: true;
readonly value: {
readonly localDate: string;
readonly timeZone: string;
};
} | {
readonly disclosed: false;
};
readonly agentsMd: {
readonly disclosed: true;
readonly value: {
readonly fingerprint: string;
readonly status: /* AgentsMdStatus — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ 'missing' | 'empty' | 'present';
};
} | {
readonly disclosed: false;
};
};
};
readonly promptPrefix?: (ctx: /* AgentProfilePromptPrefixContext — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ {
readonly cwd: string;
readonly runner: /* ISessionProcessRunner — packages/agent-core-v2/src/session/process/processRunner.ts */ {
Expand Down Expand Up @@ -582,6 +662,10 @@ export interface SessionStateSnapshot {
}[];
getKimiSkillsDescription: () => string;
getModelSkillListing: () => string;
getModelSkillDisclosure: () => /* ModelSkillDisclosure — packages/agent-core-v2/src/app/skillCatalog/types.ts */ {
readonly names: readonly string[];
readonly listing: string;
};
};
// src/session/sessionToolPolicy/sessionToolPolicyService.ts
'sessionToolPolicy.state': /* SessionToolPolicyState — packages/agent-core-v2/src/session/sessionToolPolicy/sessionToolPolicyService.ts */ {
Expand Down Expand Up @@ -658,6 +742,17 @@ export interface SessionStateSnapshot {
readonly kind: 'injection';
readonly variant: string;
readonly ownerPromptId?: string;
readonly disclosure?: {
readonly kind: 'date';
readonly renderGeneration: number;
readonly localDate: string;
readonly timeZone: string;
} | {
readonly kind: 'agents_md';
readonly renderGeneration: number;
readonly fingerprint: string;
readonly status: /* AgentsMdStatus — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ 'missing' | 'empty' | 'present';
};
} | /* ShellCommandOrigin — packages/agent-core-v2/src/agent/contextMemory/types.ts */ {
readonly kind: 'shell_command';
readonly phase: 'input' | 'output';
Expand Down Expand Up @@ -734,6 +829,17 @@ export interface AgentStateSnapshot {
readonly kind: 'injection';
readonly variant: string;
readonly ownerPromptId?: string;
readonly disclosure?: {
readonly kind: 'date';
readonly renderGeneration: number;
readonly localDate: string;
readonly timeZone: string;
} | {
readonly kind: 'agents_md';
readonly renderGeneration: number;
readonly fingerprint: string;
readonly status: /* AgentsMdStatus — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ 'missing' | 'empty' | 'present';
};
} | /* ShellCommandOrigin — packages/agent-core-v2/src/agent/contextMemory/types.ts */ {
readonly kind: 'shell_command';
readonly phase: 'input' | 'output';
Expand Down Expand Up @@ -858,6 +964,17 @@ export interface AgentStateSnapshot {
readonly kind: 'injection';
readonly variant: string;
readonly ownerPromptId?: string;
readonly disclosure?: {
readonly kind: 'date';
readonly renderGeneration: number;
readonly localDate: string;
readonly timeZone: string;
} | {
readonly kind: 'agents_md';
readonly renderGeneration: number;
readonly fingerprint: string;
readonly status: /* AgentsMdStatus — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ 'missing' | 'empty' | 'present';
};
} | /* ShellCommandOrigin — packages/agent-core-v2/src/agent/contextMemory/types.ts */ {
readonly kind: 'shell_command';
readonly phase: 'input' | 'output';
Expand Down Expand Up @@ -914,6 +1031,17 @@ export interface AgentStateSnapshot {
readonly kind: 'injection';
readonly variant: string;
readonly ownerPromptId?: string;
readonly disclosure?: {
readonly kind: 'date';
readonly renderGeneration: number;
readonly localDate: string;
readonly timeZone: string;
} | {
readonly kind: 'agents_md';
readonly renderGeneration: number;
readonly fingerprint: string;
readonly status: /* AgentsMdStatus — packages/agent-core-v2/src/app/agentProfileCatalog/agentProfileCatalog.ts */ 'missing' | 'empty' | 'present';
};
} | /* ShellCommandOrigin — packages/agent-core-v2/src/agent/contextMemory/types.ts */ {
readonly kind: 'shell_command';
readonly phase: 'input' | 'output';
Expand Down Expand Up @@ -1010,7 +1138,7 @@ export interface AgentStateSnapshot {
'llmRequester.lastConfigLogSignature': string | undefined;
'llmRequester.mediaDegradedTurns': Set<number>;
'llmRequester.mediaStrippedTurns': Map<number, /* MediaStripSnapshot — packages/agent-core-v2/src/agent/contextProjector/contextProjector.ts */ {
readonly "__@mediaStripSnapshotBrand@2671": undefined;
readonly "__@mediaStripSnapshotBrand@2724": undefined;
}>;
'llmRequester.turnConfigs': Map<number, /* TurnRequestConfig — packages/agent-core-v2/src/agent/llmRequester/llmRequesterService.ts */ {
readonly resolved: /* ProfileModelContext — packages/agent-core-v2/src/agent/profile/profile.ts */ {
Expand Down
47 changes: 42 additions & 5 deletions packages/agent-core-v2/docs/wire-manifest.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// owning model offloads inline media to blob storage), cross-reducers
// (foreign models that also reduce this record on dispatch and replay).

// Index (44 record types)
// Index (46 record types)
// config.update profile persisted src/agent/profile/profileOps.ts
// context_size.measured contextSize transient src/agent/contextSize/contextSizeOps.ts
// context.append_loop_event contextMemory persisted src/agent/contextMemory/contextOps.ts
Expand Down Expand Up @@ -51,8 +51,10 @@
// plan_mode.enter plan persisted src/agent/plan/planOps.ts
// plan_mode.exit plan persisted src/agent/plan/planOps.ts
// plan.revision plan persisted src/agent/plan/planOps.ts
// plugin.session_start.set_baseline agentPlugin persisted src/agent/plugin/agentPluginOps.ts
// profile.bind profile persisted src/agent/profile/profileOps.ts
// skill.activate skill transient src/agent/skill/skillOps.ts
// skill.disclosure.set skillDisclosure persisted src/agent/skillDisclosure/skillDisclosureOps.ts
// swarm_mode.enter swarm persisted src/agent/swarm/swarmOps.ts
// swarm_mode.exit swarm persisted src/agent/swarm/swarmOps.ts
// task.started task persisted src/agent/task/taskOps.ts
Expand Down Expand Up @@ -81,6 +83,13 @@ interface ConfigUpdatePayload {
/** ThinkingEffort */
thinkingLevel?: 'off' | 'on' | (string & {});
systemPrompt?: string;
/** EnvironmentDisclosureSnapshot */
environmentDisclosure?: {
cwd: string;
date: { disclosed: true, value: { localDate: string, timeZone: string } } | { disclosed: false };
agentsMd: { disclosed: true, value: { fingerprint: string, status: 'missing' | 'empty' | 'present' } } | { disclosed: false };
};
renderGeneration?: number;
disallowedTools?: string[];
}

Expand All @@ -105,7 +114,7 @@ interface ContextAppendLoopEventPayload {
}

/**
* model: contextMemory · persisted · blobs · cross-reducers: plan, goalForkNotice, task.notificationDelivery, todo
* model: contextMemory · persisted · blobs · cross-reducers: plan, goalForkNotice, task.notificationDelivery, agentPlugin, todo
* owner: src/agent/contextMemory/contextOps.ts
*/
interface ContextAppendMessagePayload {
Expand Down Expand Up @@ -140,22 +149,22 @@ interface ContextAppendMessagePayload {
}

/**
* model: contextMemory · persisted · blobs · cross-reducers: plan, task.notificationDelivery, todo
* model: contextMemory · persisted · blobs · cross-reducers: plan, task.notificationDelivery, agentPlugin, todo
* owner: src/agent/contextMemory/contextOps.ts
* shared base: ...contextCompactionBaseShape
*/
type ContextApplyCompactionPayload = { _name: 'context.apply_compaction'; } & ({ summary: string, compactedCount: number, contextSummary?: string } | { contextSummary: string, compactedCount: number, summary?: string } | { summary: ContextMessage, count: number, compactedCount?: number });

/**
* model: contextMemory · persisted · blobs · cross-reducers: plan, task.notificationDelivery, todo
* model: contextMemory · persisted · blobs · cross-reducers: plan, task.notificationDelivery, agentPlugin, todo
* owner: src/agent/contextMemory/contextOps.ts
*/
interface ContextClearPayload {
_name: 'context.clear';
}

/**
* model: contextMemory · persisted · blobs · cross-reducers: plan, task.notificationDelivery, todo
* model: contextMemory · persisted · blobs · cross-reducers: plan, task.notificationDelivery, agentPlugin, todo
* owner: src/agent/contextMemory/contextOps.ts
*/
interface ContextUndoPayload {
Expand Down Expand Up @@ -439,6 +448,16 @@ interface PlanRevisionPayload {
bytes: number;
}

/**
* model: agentPlugin · persisted
* owner: src/agent/plugin/agentPluginOps.ts
*/
interface PluginSessionStartSetBaselinePayload {
_name: 'plugin.session_start.set_baseline';
fingerprint: string;
active: boolean;
}

/**
* model: profile · persisted · cross-reducers: profile.activeTools
* owner: src/agent/profile/profileOps.ts
Expand All @@ -451,6 +470,13 @@ interface ProfileBindPayload {
/** ThinkingEffort */
thinkingEffort: 'off' | 'on' | (string & {});
systemPrompt: string;
/** EnvironmentDisclosureSnapshot */
environmentDisclosure?: {
cwd: string;
date: { disclosed: true, value: { localDate: string, timeZone: string } } | { disclosed: false };
agentsMd: { disclosed: true, value: { fingerprint: string, status: 'missing' | 'empty' | 'present' } } | { disclosed: false };
};
renderGeneration?: number;
activeToolNames?: string[];
disallowedTools: string[];
subagents?: string[];
Expand All @@ -475,6 +501,15 @@ interface SkillActivatePayload {
};
}

/**
* model: skillDisclosure · persisted
* owner: src/agent/skillDisclosure/skillDisclosureOps.ts
*/
interface SkillDisclosureSetPayload {
_name: 'skill.disclosure.set';
names: string[];
}

/**
* model: swarm · persisted · toEvent
* owner: src/agent/swarm/swarmOps.ts
Expand Down Expand Up @@ -644,8 +679,10 @@ interface WirePayloadMap {
"plan_mode.enter": PlanModeEnterPayload;
"plan_mode.exit": PlanModeExitPayload;
"plan.revision": PlanRevisionPayload;
"plugin.session_start.set_baseline": PluginSessionStartSetBaselinePayload;
"profile.bind": ProfileBindPayload;
"skill.activate": SkillActivatePayload;
"skill.disclosure.set": SkillDisclosureSetPayload;
"swarm_mode.enter": SwarmModeEnterPayload;
"swarm_mode.exit": SwarmModeExitPayload;
"task.started": TaskStartedPayload;
Expand Down
10 changes: 6 additions & 4 deletions packages/agent-core-v2/scripts/check-domain-layers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@

import { readFileSync, readdirSync, statSync } from 'node:fs';
import { dirname, join, relative, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const __dirname = import.meta.dirname;
const PKG_ROOT = resolve(__dirname, '..');
export const SRC_ROOT = join(PKG_ROOT, 'src');
const TEST_ROOT = join(PKG_ROOT, 'test');
Expand Down Expand Up @@ -142,6 +141,7 @@ const DOMAIN_LAYER = new Map([
['model', 2],
['sessionIndex', 2],
['sessionStore', 2],
['pathWatch', 2],
// L3 — registries & capabilities
['tool', 3],
['skill', 3],
Expand Down Expand Up @@ -191,6 +191,8 @@ const DOMAIN_LAYER = new Map([
['contextInjector', 4],
['agentPlugin', 4],
['systemReminder', 4],
['skillDisclosure', 4],
['dateChange', 4],
['contextProjector', 4],
['contextSize', 4],
['fullCompaction', 4],
Expand Down Expand Up @@ -343,7 +345,7 @@ function kosongInfoOf(absPath) {
const segments = rel.split(/[\\/]/);
if (segments[0] !== 'kosong') return undefined;
const sub = segments[1];
const last = segments[segments.length - 1] ?? '';
const last = segments.at(-1) ?? '';
return {
// A file directly under `src/kosong/` has no subdomain.
sub: sub === undefined || sub.endsWith('.ts') ? undefined : sub,
Expand Down Expand Up @@ -763,7 +765,7 @@ function main() {
return 1;
}

const isMain = process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
const isMain = process.argv[1] && resolve(process.argv[1]) === import.meta.filename;
if (isMain) {
process.exit(main());
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createDecorator } from "#/_base/di/instantiation";
import type { IDisposable } from "#/_base/di/lifecycle";
import type { ContentPart } from "#/kosong/contract/message";
import type { ContextInjectionDisclosure } from '#/agent/contextMemory/types';

export interface ContextInjectionContext {
readonly injectedPositions: readonly number[];
Expand All @@ -10,9 +11,18 @@ export interface ContextInjectionContext {

export type ContextInjectionContent = string | readonly ContentPart[];

export interface ContextInjectionResult {
readonly content: ContextInjectionContent;
readonly disclosure?: ContextInjectionDisclosure;
}

export type ContextInjectionProvider = (
context: ContextInjectionContext,
) => ContextInjectionContent | undefined | Promise<ContextInjectionContent | undefined>;
) =>
| ContextInjectionContent
| ContextInjectionResult
| undefined
| Promise<ContextInjectionContent | ContextInjectionResult | undefined>;

export interface IAgentContextInjectorService {
readonly _serviceBrand: undefined;
Expand Down
Loading