@slopus/happy-agent-base 0.0.0 → 0.0.2
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/LICENSE +21 -0
- package/README.md +640 -15
- package/dist/Agent.d.ts +86 -0
- package/dist/Agent.d.ts.map +1 -0
- package/dist/Agent.js +326 -0
- package/dist/Agent.js.map +1 -0
- package/dist/AgentBase.d.ts +340 -0
- package/dist/AgentBase.d.ts.map +1 -0
- package/dist/AgentBase.js +2295 -0
- package/dist/AgentBase.js.map +1 -0
- package/dist/AgentBaseHooks.d.ts +156 -0
- package/dist/AgentBaseHooks.d.ts.map +1 -0
- package/dist/AgentBaseHooks.js +2 -0
- package/dist/AgentBaseHooks.js.map +1 -0
- package/dist/AgentBasePending.d.ts +49 -0
- package/dist/AgentBasePending.d.ts.map +1 -0
- package/dist/AgentBasePending.js +73 -0
- package/dist/AgentBasePending.js.map +1 -0
- package/dist/AgentBaseState.d.ts +13 -0
- package/dist/AgentBaseState.d.ts.map +1 -0
- package/dist/AgentBaseState.js +2 -0
- package/dist/AgentBaseState.js.map +1 -0
- package/dist/AgentBaseStoreLock.d.ts +16 -0
- package/dist/AgentBaseStoreLock.d.ts.map +1 -0
- package/dist/AgentBaseStoreLock.js +37 -0
- package/dist/AgentBaseStoreLock.js.map +1 -0
- package/dist/AgentConfig.d.ts +67 -0
- package/dist/AgentConfig.d.ts.map +1 -0
- package/dist/AgentConfig.js +81 -0
- package/dist/AgentConfig.js.map +1 -0
- package/dist/AgentContexts.d.ts +40 -0
- package/dist/AgentContexts.d.ts.map +1 -0
- package/dist/AgentContexts.js +70 -0
- package/dist/AgentContexts.js.map +1 -0
- package/dist/AgentFeature.d.ts +119 -0
- package/dist/AgentFeature.d.ts.map +1 -0
- package/dist/AgentFeature.js +2 -0
- package/dist/AgentFeature.js.map +1 -0
- package/dist/AgentFeatureAction.d.ts +16 -0
- package/dist/AgentFeatureAction.d.ts.map +1 -0
- package/dist/AgentFeatureAction.js +2 -0
- package/dist/AgentFeatureAction.js.map +1 -0
- package/dist/AgentKV.d.ts +63 -0
- package/dist/AgentKV.d.ts.map +1 -0
- package/dist/AgentKV.js +122 -0
- package/dist/AgentKV.js.map +1 -0
- package/dist/AgentModel.d.ts +17 -0
- package/dist/AgentModel.d.ts.map +1 -0
- package/dist/AgentModel.js +2 -0
- package/dist/AgentModel.js.map +1 -0
- package/dist/AgentPersistence.d.ts +95 -0
- package/dist/AgentPersistence.d.ts.map +1 -0
- package/dist/AgentPersistence.js +2 -0
- package/dist/AgentPersistence.js.map +1 -0
- package/dist/AgentProviders.d.ts +22 -0
- package/dist/AgentProviders.d.ts.map +1 -0
- package/dist/AgentProviders.js +35 -0
- package/dist/AgentProviders.js.map +1 -0
- package/dist/AgentRef.d.ts +41 -0
- package/dist/AgentRef.d.ts.map +1 -0
- package/dist/AgentRef.js +60 -0
- package/dist/AgentRef.js.map +1 -0
- package/dist/AgentStorage.d.ts +19 -0
- package/dist/AgentStorage.d.ts.map +1 -0
- package/dist/AgentStorage.js +16 -0
- package/dist/AgentStorage.js.map +1 -0
- package/dist/AgentSystem.d.ts +50 -0
- package/dist/AgentSystem.d.ts.map +1 -0
- package/dist/AgentSystem.js +2 -0
- package/dist/AgentSystem.js.map +1 -0
- package/dist/AgentSystemContext.d.ts +15 -0
- package/dist/AgentSystemContext.d.ts.map +1 -0
- package/dist/AgentSystemContext.js +20 -0
- package/dist/AgentSystemContext.js.map +1 -0
- package/dist/AgentSystemLocal.d.ts +103 -0
- package/dist/AgentSystemLocal.d.ts.map +1 -0
- package/dist/AgentSystemLocal.js +282 -0
- package/dist/AgentSystemLocal.js.map +1 -0
- package/dist/AgentSystemRef.d.ts +56 -0
- package/dist/AgentSystemRef.d.ts.map +1 -0
- package/dist/AgentSystemRef.js +75 -0
- package/dist/AgentSystemRef.js.map +1 -0
- package/dist/AgentTaskContext.d.ts +17 -0
- package/dist/AgentTaskContext.d.ts.map +1 -0
- package/dist/AgentTaskContext.js +26 -0
- package/dist/AgentTaskContext.js.map +1 -0
- package/dist/AgentTool.d.ts +87 -0
- package/dist/AgentTool.d.ts.map +1 -0
- package/dist/AgentTool.js +5 -0
- package/dist/AgentTool.js.map +1 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +62 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +185 -0
- package/dist/models.js.map +1 -0
- package/package.json +44 -37
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { release } from "node:os";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { createContextNamespace } from "@steve.kite/stdlib";
|
|
4
|
+
/** The operating systems Node reports, mirroring `NodeJS.Platform`. */
|
|
5
|
+
export const agentPlatformSchema = Type.Union([
|
|
6
|
+
Type.Literal("aix"),
|
|
7
|
+
Type.Literal("android"),
|
|
8
|
+
Type.Literal("cygwin"),
|
|
9
|
+
Type.Literal("darwin"),
|
|
10
|
+
Type.Literal("freebsd"),
|
|
11
|
+
Type.Literal("haiku"),
|
|
12
|
+
Type.Literal("linux"),
|
|
13
|
+
Type.Literal("netbsd"),
|
|
14
|
+
Type.Literal("openbsd"),
|
|
15
|
+
Type.Literal("sunos"),
|
|
16
|
+
Type.Literal("win32"),
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* The settings one feature was configured with. The agent never looks inside: a feature owns
|
|
20
|
+
* the shape of its own entry and validates it against its own schema.
|
|
21
|
+
*/
|
|
22
|
+
export const agentFeatureConfigSchema = Type.Record(Type.String(), Type.Unknown());
|
|
23
|
+
/**
|
|
24
|
+
* The machine an agent works on. It is all or nothing: an agent either knows its environment
|
|
25
|
+
* completely or not at all, so nothing it is told about the machine is ever half-true.
|
|
26
|
+
*/
|
|
27
|
+
export const agentEnvironmentSchema = Type.Object({
|
|
28
|
+
/** The operating system release, as a human-readable version string. */
|
|
29
|
+
osVersion: Type.String(),
|
|
30
|
+
/** The operating system the agent runs on. */
|
|
31
|
+
platform: agentPlatformSchema,
|
|
32
|
+
/** The absolute path the agent's work is rooted at. */
|
|
33
|
+
workingDirectory: Type.String(),
|
|
34
|
+
/** The shell the agent's commands run in, such as `/bin/zsh`. */
|
|
35
|
+
shell: Type.String(),
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* What an agent was created with: the environment it works on, when it has one, and one opaque
|
|
39
|
+
* settings map per feature, keyed by the feature's name. The configuration is static for the
|
|
40
|
+
* agent's whole life and is persisted when the agent is created, so a later process resolves
|
|
41
|
+
* the very same agent it was created as.
|
|
42
|
+
*/
|
|
43
|
+
export const agentConfigSchema = Type.Object({
|
|
44
|
+
/** The machine this agent was told it works on, when it was told anything at all. */
|
|
45
|
+
environment: Type.Optional(agentEnvironmentSchema),
|
|
46
|
+
/** Per-feature settings, keyed by feature name; each entry is opaque to the agent. */
|
|
47
|
+
features: Type.Optional(Type.Record(Type.String(), agentFeatureConfigSchema)),
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* The environment this process is running in, ready to be handed to an agent at creation. The
|
|
51
|
+
* platform is typed, so a Node release reporting an unknown platform fails to compile rather
|
|
52
|
+
* than slipping into a persisted configuration; an unset `SHELL` reports as no shell at all.
|
|
53
|
+
*/
|
|
54
|
+
export function currentAgentEnvironment() {
|
|
55
|
+
const platform = process.platform;
|
|
56
|
+
return {
|
|
57
|
+
osVersion: release(),
|
|
58
|
+
platform,
|
|
59
|
+
workingDirectory: process.cwd(),
|
|
60
|
+
shell: process.env.SHELL ?? "",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** The context slot the agent's configuration is carried in, unset until an agent attaches one. */
|
|
64
|
+
const configNamespace = createContextNamespace("happyAgentBase.agentConfig", undefined);
|
|
65
|
+
/** Carry the configuration an agent was created with; every hook and tool reads it back. */
|
|
66
|
+
export function withAgentConfig(ctx, config) {
|
|
67
|
+
return configNamespace.set(ctx, config);
|
|
68
|
+
}
|
|
69
|
+
/** The configuration of the agent owning this context, when one was attached. */
|
|
70
|
+
export function agentConfig(ctx) {
|
|
71
|
+
return configNamespace.get(ctx);
|
|
72
|
+
}
|
|
73
|
+
/** The environment of the agent owning this context, when it was created with one. */
|
|
74
|
+
export function agentEnvironment(ctx) {
|
|
75
|
+
return configNamespace.get(ctx)?.environment;
|
|
76
|
+
}
|
|
77
|
+
/** The opaque settings the named feature was configured with, if it was configured at all. */
|
|
78
|
+
export function agentFeatureConfig(ctx, name) {
|
|
79
|
+
return configNamespace.get(ctx)?.features?.[name];
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=AgentConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentConfig.js","sourceRoot":"","sources":["../sources/AgentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAgB,MAAM,oBAAoB,CAAC;AAE1E,uEAAuE;AACvE,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1C,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IACnB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;CACxB,CAAC,C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EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,GAAY;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,GAAY;IACzC,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;AACjD,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,kBAAkB,CAAC,GAAY,EAAE,IAAY;IACzD,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SessionReasoningEffort, SessionServiceTier } from "@slopus/happy-providers";
|
|
2
|
+
import { type Context } from "@steve.kite/stdlib";
|
|
3
|
+
import type { AgentKV } from "./AgentKV.js";
|
|
4
|
+
/**
|
|
5
|
+
* Derive the agent's context carrying its ID, provider ID, model, effort, and service tier — all
|
|
6
|
+
* serializable values. The agent applies this once at construction, so hooks and tool executions
|
|
7
|
+
* can read the values back through the accessors below. The ID is what lets one feature instance
|
|
8
|
+
* serve every agent in a collection: a shared feature learns which agent a hook is running for
|
|
9
|
+
* from the context rather than from something it was constructed with.
|
|
10
|
+
*/
|
|
11
|
+
export declare function withAgentContext(ctx: Context, values: {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly provider: string;
|
|
14
|
+
readonly model?: string | undefined;
|
|
15
|
+
readonly effort?: SessionReasoningEffort | undefined;
|
|
16
|
+
readonly serviceTier?: SessionServiceTier | undefined;
|
|
17
|
+
}): Context;
|
|
18
|
+
/** The ID of the agent owning this context. */
|
|
19
|
+
export declare function agentId(ctx: Context): string | undefined;
|
|
20
|
+
/** The model configured for the agent owning this context, when one was set. */
|
|
21
|
+
export declare function agentModel(ctx: Context): string | undefined;
|
|
22
|
+
/** The reasoning effort configured for the agent owning this context, when one was set. */
|
|
23
|
+
export declare function agentEffort(ctx: Context): SessionReasoningEffort | undefined;
|
|
24
|
+
/** The registry ID of the provider of the agent owning this context. */
|
|
25
|
+
export declare function agentProvider(ctx: Context): string | undefined;
|
|
26
|
+
/** The service tier configured for the agent owning this context, when one was set. */
|
|
27
|
+
export declare function agentServiceTier(ctx: Context): SessionServiceTier | undefined;
|
|
28
|
+
/** Carry a scoped key-value store on the context, replacing any store carried before. */
|
|
29
|
+
export declare function withAgentKV(ctx: Context, kv: AgentKV): Context;
|
|
30
|
+
/** The scoped key-value store carried on this context, when the agent attached one. */
|
|
31
|
+
export declare function agentKV(ctx: Context): AgentKV | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Carry the store belonging to the run in progress, replacing any run store carried before. What
|
|
34
|
+
* it holds lives exactly as long as the work does: the agent erases the whole scope in the
|
|
35
|
+
* transaction that settles it, so nothing written here outlives the run that wrote it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function withAgentRunKV(ctx: Context, kv: AgentKV): Context;
|
|
38
|
+
/** The run's own store carried on this context, when the agent attached one. */
|
|
39
|
+
export declare function agentRunKV(ctx: Context): AgentKV | undefined;
|
|
40
|
+
//# sourceMappingURL=AgentContexts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentContexts.d.ts","sourceRoot":"","sources":["../sources/AgentContexts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAuB5C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC5B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE;IACJ,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CACzD,GACF,OAAO,CAMT;AAED,+CAA+C;AAC/C,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAExD;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE3D;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,sBAAsB,GAAG,SAAS,CAE5E;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAE7E;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAE9D;AAED,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAEjE;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAE5D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createContextNamespace } from "@steve.kite/stdlib";
|
|
2
|
+
/** Backing storage for `agentId`: the ID of the agent owning a context. */
|
|
3
|
+
const idNamespace = createContextNamespace("agentId", undefined);
|
|
4
|
+
/** Backing storage for `agentModel`: the model configured for the agent, when one was set. */
|
|
5
|
+
const modelNamespace = createContextNamespace("agentModel", undefined);
|
|
6
|
+
/** Backing storage for `agentEffort`: the reasoning effort configured, when one was set. */
|
|
7
|
+
const effortNamespace = createContextNamespace("agentEffort", undefined);
|
|
8
|
+
/** Backing storage for `agentProvider`: the registry ID of the provider owning a context. */
|
|
9
|
+
const providerNamespace = createContextNamespace("agentProvider", undefined);
|
|
10
|
+
/** Backing storage for `agentServiceTier`: the service tier configured, when one was set. */
|
|
11
|
+
const serviceTierNamespace = createContextNamespace("agentServiceTier", undefined);
|
|
12
|
+
/** Backing storage for `agentKV`: the scoped key-value store carried on a context. */
|
|
13
|
+
const kvNamespace = createContextNamespace("agentKV", undefined);
|
|
14
|
+
/** Backing storage for `agentRunKV`: the run's own store, erased when the agent settles. */
|
|
15
|
+
const runKVNamespace = createContextNamespace("agentRunKV", undefined);
|
|
16
|
+
/**
|
|
17
|
+
* Derive the agent's context carrying its ID, provider ID, model, effort, and service tier — all
|
|
18
|
+
* serializable values. The agent applies this once at construction, so hooks and tool executions
|
|
19
|
+
* can read the values back through the accessors below. The ID is what lets one feature instance
|
|
20
|
+
* serve every agent in a collection: a shared feature learns which agent a hook is running for
|
|
21
|
+
* from the context rather than from something it was constructed with.
|
|
22
|
+
*/
|
|
23
|
+
export function withAgentContext(ctx, values) {
|
|
24
|
+
const withId = idNamespace.set(ctx, values.id);
|
|
25
|
+
const withProvider = providerNamespace.set(withId, values.provider);
|
|
26
|
+
const withModel = modelNamespace.set(withProvider, values.model);
|
|
27
|
+
const withEffort = effortNamespace.set(withModel, values.effort);
|
|
28
|
+
return serviceTierNamespace.set(withEffort, values.serviceTier);
|
|
29
|
+
}
|
|
30
|
+
/** The ID of the agent owning this context. */
|
|
31
|
+
export function agentId(ctx) {
|
|
32
|
+
return idNamespace.get(ctx);
|
|
33
|
+
}
|
|
34
|
+
/** The model configured for the agent owning this context, when one was set. */
|
|
35
|
+
export function agentModel(ctx) {
|
|
36
|
+
return modelNamespace.get(ctx);
|
|
37
|
+
}
|
|
38
|
+
/** The reasoning effort configured for the agent owning this context, when one was set. */
|
|
39
|
+
export function agentEffort(ctx) {
|
|
40
|
+
return effortNamespace.get(ctx);
|
|
41
|
+
}
|
|
42
|
+
/** The registry ID of the provider of the agent owning this context. */
|
|
43
|
+
export function agentProvider(ctx) {
|
|
44
|
+
return providerNamespace.get(ctx);
|
|
45
|
+
}
|
|
46
|
+
/** The service tier configured for the agent owning this context, when one was set. */
|
|
47
|
+
export function agentServiceTier(ctx) {
|
|
48
|
+
return serviceTierNamespace.get(ctx);
|
|
49
|
+
}
|
|
50
|
+
/** Carry a scoped key-value store on the context, replacing any store carried before. */
|
|
51
|
+
export function withAgentKV(ctx, kv) {
|
|
52
|
+
return kvNamespace.set(ctx, kv);
|
|
53
|
+
}
|
|
54
|
+
/** The scoped key-value store carried on this context, when the agent attached one. */
|
|
55
|
+
export function agentKV(ctx) {
|
|
56
|
+
return kvNamespace.get(ctx);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Carry the store belonging to the run in progress, replacing any run store carried before. What
|
|
60
|
+
* it holds lives exactly as long as the work does: the agent erases the whole scope in the
|
|
61
|
+
* transaction that settles it, so nothing written here outlives the run that wrote it.
|
|
62
|
+
*/
|
|
63
|
+
export function withAgentRunKV(ctx, kv) {
|
|
64
|
+
return runKVNamespace.set(ctx, kv);
|
|
65
|
+
}
|
|
66
|
+
/** The run's own store carried on this context, when the agent attached one. */
|
|
67
|
+
export function agentRunKV(ctx) {
|
|
68
|
+
return runKVNamespace.get(ctx);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=AgentContexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentContexts.js","sourceRoot":"","sources":["../sources/AgentContexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAgB,MAAM,oBAAoB,CAAC;AAI1E,2EAA2E;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AED,gFAAgF;AAChF,MAAM,UAAU,UAAU,CAAC,GAAY;IACnC,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,WAAW,CAAC,GAAY;IACpC,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACpC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,GAAY;IACtC,OAAO,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,gBAAgB,CAAC,GAAY;IACzC,OAAO,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,WAAW,CAAC,GAAY,EAAE,EAAW;IACjD,OAAO,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,OAAO,CAAC,GAAY;IAChC,OAAO,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,EAAW;IACpD,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACvC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,UAAU,CAAC,GAAY;IACnC,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ProviderModelCompatibilityType, SessionEvent, SessionReasoningEffort, SessionServiceTier, SessionSystemMessage } from "@slopus/happy-providers";
|
|
2
|
+
import type { Context } from "@steve.kite/stdlib";
|
|
3
|
+
import type { AgentBaseInference, AgentBaseModelChange, AgentBaseToolExecution, AgentBaseTurn, AgentBaseTurnStart, MaybePromise } from "./AgentBaseHooks.js";
|
|
4
|
+
import type { AgentFeatureAction } from "./AgentFeatureAction.js";
|
|
5
|
+
import type { AgentKV } from "./AgentKV.js";
|
|
6
|
+
import type { AnyAgentTool } from "./AgentTool.js";
|
|
7
|
+
/**
|
|
8
|
+
* The agent a hook is serving, in full. One feature instance serves every agent in a collection,
|
|
9
|
+
* so this — rather than anything the feature was constructed with — is what tells it whose turn
|
|
10
|
+
* it is looking at, and what that agent is about to run on.
|
|
11
|
+
*/
|
|
12
|
+
export interface AgentFeatureAgent {
|
|
13
|
+
/** The system-generated identity of the agent, stable for its whole life. */
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** The registry ID of the provider in force, which one agent may switch between. */
|
|
16
|
+
readonly provider: string;
|
|
17
|
+
/**
|
|
18
|
+
* What kind of provider that ID is registered as — `"claude"`, `"codex"`, and so on. It is
|
|
19
|
+
* the vendor shape a feature has to reason about when a provider ID alone says nothing, and
|
|
20
|
+
* is absent when the ID is not registered.
|
|
21
|
+
*/
|
|
22
|
+
readonly providerKind: ProviderModelCompatibilityType | undefined;
|
|
23
|
+
/** The model in force, absent when none was ever selected. */
|
|
24
|
+
readonly model: string | undefined;
|
|
25
|
+
/** The reasoning effort in force, absent when none was ever selected. */
|
|
26
|
+
readonly effort: SessionReasoningEffort | undefined;
|
|
27
|
+
/** The service tier in force, absent when none was ever selected. */
|
|
28
|
+
readonly tier: SessionServiceTier | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What every hook of a feature is handed alongside the context: which agent it is running for,
|
|
32
|
+
* and the three stores it may write to, each with its own lifetime.
|
|
33
|
+
*
|
|
34
|
+
* They are passed rather than read off the context because a feature's own dependencies are not
|
|
35
|
+
* ambient state to be looked up: a hook is given exactly what it is entitled to, and cannot be
|
|
36
|
+
* handed a context that quietly means a different agent.
|
|
37
|
+
*/
|
|
38
|
+
export interface AgentFeatureScope {
|
|
39
|
+
/** The agent this hook is running for, and the selection it is running on. */
|
|
40
|
+
readonly agent: AgentFeatureAgent;
|
|
41
|
+
/**
|
|
42
|
+
* The feature's durable store for this one agent, scoped to `feature.<name>`. It belongs to
|
|
43
|
+
* the agent's conversation: it outlives every run, and it is cleared when the identity is
|
|
44
|
+
* created again. Renaming a feature orphans everything it stored here.
|
|
45
|
+
*/
|
|
46
|
+
readonly kv: AgentKV;
|
|
47
|
+
/**
|
|
48
|
+
* The feature's durable store shared by every agent in the collection, and outliving all of
|
|
49
|
+
* them. Work one agent owes another lives here, since an agent's own store belongs to its
|
|
50
|
+
* conversation alone.
|
|
51
|
+
*/
|
|
52
|
+
readonly sharedKV: AgentKV;
|
|
53
|
+
/**
|
|
54
|
+
* The feature's store for the run in progress, erased in the transaction that settles the
|
|
55
|
+
* agent. It is where a feature keeps what only makes sense while the agent is working, so a
|
|
56
|
+
* crash mid-run leaves notes a resumed run can read, and a finished run leaves none at all.
|
|
57
|
+
*/
|
|
58
|
+
readonly runKV: AgentKV;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* One independent capability of an `Agent`: a feature implements any subset of the agent hooks,
|
|
62
|
+
* and the agent merges every feature's implementations into the singular hooks its internal
|
|
63
|
+
* `AgentBase` runs with. The hook contracts are the same as `AgentBaseHooks`; see there for
|
|
64
|
+
* when each hook fires and what its return value means.
|
|
65
|
+
*
|
|
66
|
+
* Every hook receives the agent's context first and its own `AgentFeatureScope` second.
|
|
67
|
+
*/
|
|
68
|
+
export interface AgentFeature<Tool extends AnyAgentTool = AnyAgentTool> {
|
|
69
|
+
/**
|
|
70
|
+
* A stable identifier for the feature. Its persisted key-value entries live under this
|
|
71
|
+
* name, so renaming a feature orphans everything it stored.
|
|
72
|
+
*/
|
|
73
|
+
readonly name: string;
|
|
74
|
+
/** Observes every session event; must never fail or delay the run. */
|
|
75
|
+
readonly onEvent?: (ctx: Context, scope: AgentFeatureScope, event: SessionEvent) => void;
|
|
76
|
+
/** Merged after the base state and every earlier feature's instructions, in feature order. */
|
|
77
|
+
readonly instructions?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<string>;
|
|
78
|
+
/** Merged after the base state and every earlier feature's tools, in feature order. */
|
|
79
|
+
readonly tools?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<readonly Tool[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Wraps validated tool execution. Features compose as nested middleware in array order.
|
|
82
|
+
* See `AgentBaseHooks.aroundToolExecution` for the continuation contract.
|
|
83
|
+
*/
|
|
84
|
+
readonly aroundToolExecution?: (ctx: Context, scope: AgentFeatureScope, execution: AgentBaseToolExecution) => MaybePromise<unknown>;
|
|
85
|
+
/** The first feature that returns a handoff message wins the reset injection. */
|
|
86
|
+
readonly modelChanged?: (ctx: Context, scope: AgentFeatureScope, change: AgentBaseModelChange) => MaybePromise<SessionSystemMessage | undefined>;
|
|
87
|
+
/** Called when the loop leaves the settled state and begins working. */
|
|
88
|
+
readonly beforeAgentLoop?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Receives the measured size of the context the turn is about to run on. Actions from every
|
|
91
|
+
* feature are concatenated and applied before the turn's first inference.
|
|
92
|
+
*/
|
|
93
|
+
readonly beforeTurn?: (ctx: Context, scope: AgentFeatureScope, turn: AgentBaseTurnStart) => MaybePromise<readonly AgentFeatureAction[] | undefined>;
|
|
94
|
+
/** Called immediately before each inference request. */
|
|
95
|
+
readonly beforeInference?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
96
|
+
/** Receives how the response ended and the token counts the provider measured for it. */
|
|
97
|
+
readonly afterInference?: (ctx: Context, scope: AgentFeatureScope, inference: AgentBaseInference) => MaybePromise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Receives the token counts the turn's last measured response reported. Actions from every
|
|
100
|
+
* feature are concatenated and applied together.
|
|
101
|
+
*/
|
|
102
|
+
readonly afterTurn?: (ctx: Context, scope: AgentFeatureScope, turn: AgentBaseTurn) => MaybePromise<readonly AgentFeatureAction[] | undefined>;
|
|
103
|
+
/** Actions from every feature are concatenated and applied together. */
|
|
104
|
+
readonly afterAgentLoop?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<readonly AgentFeatureAction[] | undefined>;
|
|
105
|
+
/**
|
|
106
|
+
* Called inside the transaction that records the agent as settled. The feature's stores write
|
|
107
|
+
* into that transaction, so what a feature concludes about the run and the fact that the run
|
|
108
|
+
* is over become durable together. The `Transact` suffix is what marks a hook as running
|
|
109
|
+
* inside a transaction. The run store is erased by that same transaction, so this is the last
|
|
110
|
+
* chance to keep any part of what the run wrote about itself.
|
|
111
|
+
*
|
|
112
|
+
* Unlike the observing hooks, a failure here is not contained: it rolls the settlement back
|
|
113
|
+
* along with everything every feature wrote, and the agent stays recorded as working.
|
|
114
|
+
*/
|
|
115
|
+
readonly afterAgentSettledTransact?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
116
|
+
/** Called once after the loop has fully settled and no feature reopened it. */
|
|
117
|
+
readonly afterAgentSettled?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=AgentFeature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentFeature.d.ts","sourceRoot":"","sources":["../sources/AgentFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,8BAA8B,EAC9B,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EACR,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;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IAAI,EAAE,aAAa,KAClB,YAAY,CAAC,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAAC,CAAC;IAC7D,wEAAwE;IACxE,QAAQ,CAAC,cAAc,CAAC,EAAE,CACtB,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,iBAAiB,KACvB,YAAY,CAAC,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAAC,CAAC;IAC7D;;;;;;;;;OASG;IACH,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CACjC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,iBAAiB,KACvB,YAAY,CAAC,IAAI,CAAC,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAC/F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentFeature.js","sourceRoot":"","sources":["../sources/AgentFeature.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionUserMessage } from "@slopus/happy-providers";
|
|
2
|
+
/**
|
|
3
|
+
* What a lifecycle hook can ask the agent to do next: queue a steering or sent message through
|
|
4
|
+
* the ordinary durable queues, or trigger a compaction. An action drives the loop exactly like
|
|
5
|
+
* an external call to `steer`, `send`, or `compact` would.
|
|
6
|
+
*/
|
|
7
|
+
export type AgentFeatureAction = {
|
|
8
|
+
readonly type: "steer";
|
|
9
|
+
readonly message: SessionUserMessage;
|
|
10
|
+
} | {
|
|
11
|
+
readonly type: "send";
|
|
12
|
+
readonly message: SessionUserMessage;
|
|
13
|
+
} | {
|
|
14
|
+
readonly type: "compact";
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=AgentFeatureAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentFeatureAction.d.ts","sourceRoot":"","sources":["../sources/AgentFeatureAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,GAChE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,GAC/D;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentFeatureAction.js","sourceRoot":"","sources":["../sources/AgentFeatureAction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Context } from "@steve.kite/stdlib";
|
|
2
|
+
import type { AgentPersistence } from "./AgentPersistence.js";
|
|
3
|
+
/**
|
|
4
|
+
* A key-value store scoped under one prefix of the agent's sorted store. The agent carries a
|
|
5
|
+
* session-scoped instance on its context, and narrows it for each caller: a feature works
|
|
6
|
+
* under its own name, a tool execution under its call ID. Keys are always relative to the
|
|
7
|
+
* scope — a holder can neither see nor touch anything outside it. Segments join with `.`.
|
|
8
|
+
*
|
|
9
|
+
* The object is nothing but a scope: every operation runs on the context it is given, so which
|
|
10
|
+
* transaction a write joins and how long the handle stays usable are both decided by that
|
|
11
|
+
* context and never by the handle.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AgentKV {
|
|
14
|
+
#private;
|
|
15
|
+
/** The absolute key prefix of this scope, ending with the separator. */
|
|
16
|
+
readonly prefix: string;
|
|
17
|
+
/** Build a scope over `prefix` of `persistence`. */
|
|
18
|
+
constructor(persistence: AgentPersistence, prefix: string);
|
|
19
|
+
/**
|
|
20
|
+
* A narrower store under `segments` within this scope. Each segment is exactly one level:
|
|
21
|
+
* a dot inside a segment is escaped, so the scope `alpha.beta` cannot be reached through
|
|
22
|
+
* the scope `alpha` under the relative key `beta.…`, and two scopes stay distinct whenever
|
|
23
|
+
* their segment lists differ.
|
|
24
|
+
*/
|
|
25
|
+
scoped(...segments: readonly string[]): AgentKV;
|
|
26
|
+
/** The stored value, or undefined when the key is absent. */
|
|
27
|
+
read(ctx: Context, key: string): Promise<unknown>;
|
|
28
|
+
/** Every entry under the scope — or under `prefix` within it — with scope-relative keys. */
|
|
29
|
+
list(ctx: Context, prefix?: string): Promise<readonly {
|
|
30
|
+
readonly key: string;
|
|
31
|
+
readonly value: unknown;
|
|
32
|
+
}[]>;
|
|
33
|
+
/** Store the value under `key`, replacing whatever was there before. */
|
|
34
|
+
write(ctx: Context, key: string, value: unknown): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Read, decide, and write, so the value the updater sees is exactly the value it replaces.
|
|
37
|
+
* One store has one owner, so nothing else can write between the read and the write. An
|
|
38
|
+
* updater that throws leaves the stored value untouched.
|
|
39
|
+
*/
|
|
40
|
+
update<Value>(ctx: Context, key: string, updater: (current: unknown) => Value | Promise<Value>): Promise<Value>;
|
|
41
|
+
/**
|
|
42
|
+
* Run work as one atomic step of the underlying store: everything it writes commits together,
|
|
43
|
+
* and a thrown error leaves the store exactly as it was. The work is given this same scope and
|
|
44
|
+
* the transaction's context, whose lifetime ends when the work returns, so a transaction
|
|
45
|
+
* cannot be written into after it has committed.
|
|
46
|
+
*/
|
|
47
|
+
transaction<Result>(ctx: Context, work: (kv: AgentKV, txCtx: Context) => Promise<Result>): Promise<Result>;
|
|
48
|
+
/**
|
|
49
|
+
* Claim a key: writes only when it is absent, and answers whether this caller claimed it.
|
|
50
|
+
* Two callers racing for one key cannot both be told they wrote it.
|
|
51
|
+
*/
|
|
52
|
+
writeIfAbsent(ctx: Context, key: string, value: unknown): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Remove every entry in this scope, including the ones its narrower scopes wrote. This is how
|
|
55
|
+
* a store whose lifetime has ended is disposed of — the run store when the agent settles — so
|
|
56
|
+
* it runs as one operation of the underlying store and joins a transaction like any other
|
|
57
|
+
* write.
|
|
58
|
+
*/
|
|
59
|
+
clear(ctx: Context): Promise<void>;
|
|
60
|
+
/** Remove the entry stored under `key`, if any. */
|
|
61
|
+
delete(ctx: Context, key: string): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=AgentKV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentKV.d.ts","sourceRoot":"","sources":["../sources/AgentKV.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAe9D;;;;;;;;;GASG;AACH,qBAAa,OAAO;;IAChB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAKxB,oDAAoD;IACpD,YAAY,WAAW,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAGxD;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAK9C;IAED,6DAA6D;IACvD,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKtD;IAED,4FAA4F;IACtF,IAAI,CACN,GAAG,EAAE,OAAO,EACZ,MAAM,SAAK,GACZ,OAAO,CAAC,SAAS;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAIvE;IAED,wEAAwE;IAClE,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAGpE;IAED;;;;OAIG;IACG,MAAM,CAAC,KAAK,EACd,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GACtD,OAAO,CAAC,KAAK,CAAC,CAQhB;IAED;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EACpB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,GACvD,OAAO,CAAC,MAAM,CAAC,CAWjB;IAED;;;OAGG;IACG,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAG/E;IAED;;;;;OAKG;IACG,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvC;IAED,mDAAmD;IAC7C,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrD;CACJ"}
|
package/dist/AgentKV.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { withLifetime } from "@steve.kite/stdlib";
|
|
2
|
+
/**
|
|
3
|
+
* Refuse a store operation whose context has already ended. What a holder of a store may do is
|
|
4
|
+
* decided by the context it is given rather than by the object: a store used inside a transaction,
|
|
5
|
+
* or handed to a tool for the length of its turn, keeps working exactly as long as that work
|
|
6
|
+
* does. Using it afterwards is a mistake in the caller, and says so instead of quietly writing
|
|
7
|
+
* into a transaction that has committed or a turn that was cancelled.
|
|
8
|
+
*/
|
|
9
|
+
function assertLive(ctx) {
|
|
10
|
+
if (ctx.lifetime?.aborted === true) {
|
|
11
|
+
throw new Error("The store cannot be used: the work its context belongs to has ended.");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A key-value store scoped under one prefix of the agent's sorted store. The agent carries a
|
|
16
|
+
* session-scoped instance on its context, and narrows it for each caller: a feature works
|
|
17
|
+
* under its own name, a tool execution under its call ID. Keys are always relative to the
|
|
18
|
+
* scope — a holder can neither see nor touch anything outside it. Segments join with `.`.
|
|
19
|
+
*
|
|
20
|
+
* The object is nothing but a scope: every operation runs on the context it is given, so which
|
|
21
|
+
* transaction a write joins and how long the handle stays usable are both decided by that
|
|
22
|
+
* context and never by the handle.
|
|
23
|
+
*/
|
|
24
|
+
export class AgentKV {
|
|
25
|
+
/** The absolute key prefix of this scope, ending with the separator. */
|
|
26
|
+
prefix;
|
|
27
|
+
/** The append-only store this scope reads and writes through. */
|
|
28
|
+
#persistence;
|
|
29
|
+
/** Build a scope over `prefix` of `persistence`. */
|
|
30
|
+
constructor(persistence, prefix) {
|
|
31
|
+
this.#persistence = persistence;
|
|
32
|
+
this.prefix = prefix;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A narrower store under `segments` within this scope. Each segment is exactly one level:
|
|
36
|
+
* a dot inside a segment is escaped, so the scope `alpha.beta` cannot be reached through
|
|
37
|
+
* the scope `alpha` under the relative key `beta.…`, and two scopes stay distinct whenever
|
|
38
|
+
* their segment lists differ.
|
|
39
|
+
*/
|
|
40
|
+
scoped(...segments) {
|
|
41
|
+
const escaped = segments.map((segment) => segment.replaceAll("%", "%25").replaceAll(".", "%2E"));
|
|
42
|
+
return new AgentKV(this.#persistence, `${this.prefix}${escaped.join(".")}.`);
|
|
43
|
+
}
|
|
44
|
+
/** The stored value, or undefined when the key is absent. */
|
|
45
|
+
async read(ctx, key) {
|
|
46
|
+
assertLive(ctx);
|
|
47
|
+
const full = `${this.prefix}${key}`;
|
|
48
|
+
const entries = await this.#persistence.readValues(ctx, full);
|
|
49
|
+
return entries.find((entry) => entry.key === full)?.value;
|
|
50
|
+
}
|
|
51
|
+
/** Every entry under the scope — or under `prefix` within it — with scope-relative keys. */
|
|
52
|
+
async list(ctx, prefix = "") {
|
|
53
|
+
assertLive(ctx);
|
|
54
|
+
const entries = await this.#persistence.readValues(ctx, `${this.prefix}${prefix}`);
|
|
55
|
+
return entries.map(({ key, value }) => ({ key: key.slice(this.prefix.length), value }));
|
|
56
|
+
}
|
|
57
|
+
/** Store the value under `key`, replacing whatever was there before. */
|
|
58
|
+
async write(ctx, key, value) {
|
|
59
|
+
assertLive(ctx);
|
|
60
|
+
await this.#persistence.writeValue(ctx, `${this.prefix}${key}`, value);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read, decide, and write, so the value the updater sees is exactly the value it replaces.
|
|
64
|
+
* One store has one owner, so nothing else can write between the read and the write. An
|
|
65
|
+
* updater that throws leaves the stored value untouched.
|
|
66
|
+
*/
|
|
67
|
+
async update(ctx, key, updater) {
|
|
68
|
+
assertLive(ctx);
|
|
69
|
+
const full = `${this.prefix}${key}`;
|
|
70
|
+
const entries = await this.#persistence.readValues(ctx, full);
|
|
71
|
+
const current = entries.find((entry) => entry.key === full)?.value;
|
|
72
|
+
const next = await updater(current);
|
|
73
|
+
await this.#persistence.writeValue(ctx, full, next);
|
|
74
|
+
return next;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Run work as one atomic step of the underlying store: everything it writes commits together,
|
|
78
|
+
* and a thrown error leaves the store exactly as it was. The work is given this same scope and
|
|
79
|
+
* the transaction's context, whose lifetime ends when the work returns, so a transaction
|
|
80
|
+
* cannot be written into after it has committed.
|
|
81
|
+
*/
|
|
82
|
+
async transaction(ctx, work) {
|
|
83
|
+
assertLive(ctx);
|
|
84
|
+
return await this.#persistence.transaction(ctx, async (txCtx) => {
|
|
85
|
+
const committed = new AbortController();
|
|
86
|
+
const liveCtx = withLifetime(txCtx, committed.signal);
|
|
87
|
+
try {
|
|
88
|
+
return await work(this, liveCtx);
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
committed.abort();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Claim a key: writes only when it is absent, and answers whether this caller claimed it.
|
|
97
|
+
* Two callers racing for one key cannot both be told they wrote it.
|
|
98
|
+
*/
|
|
99
|
+
async writeIfAbsent(ctx, key, value) {
|
|
100
|
+
assertLive(ctx);
|
|
101
|
+
return await this.#persistence.writeValueIfAbsent(ctx, `${this.prefix}${key}`, value);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Remove every entry in this scope, including the ones its narrower scopes wrote. This is how
|
|
105
|
+
* a store whose lifetime has ended is disposed of — the run store when the agent settles — so
|
|
106
|
+
* it runs as one operation of the underlying store and joins a transaction like any other
|
|
107
|
+
* write.
|
|
108
|
+
*/
|
|
109
|
+
async clear(ctx) {
|
|
110
|
+
assertLive(ctx);
|
|
111
|
+
const entries = await this.#persistence.readValues(ctx, this.prefix);
|
|
112
|
+
for (const entry of entries) {
|
|
113
|
+
await this.#persistence.deleteValue(ctx, entry.key);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** Remove the entry stored under `key`, if any. */
|
|
117
|
+
async delete(ctx, key) {
|
|
118
|
+
assertLive(ctx);
|
|
119
|
+
await this.#persistence.deleteValue(ctx, `${this.prefix}${key}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=AgentKV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentKV.js","sourceRoot":"","sources":["../sources/AgentKV.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AAIhE;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,GAAY;IAC5B,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC5F,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,OAAO;IAChB,wEA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ffort, SessionServiceTier } from "@slopus/happy-providers";
|
|
2
|
+
/** One provider/model route available to agents and subagents. */
|
|
3
|
+
export interface AgentModel {
|
|
4
|
+
/** The registry ID of the provider this route is served through. */
|
|
5
|
+
readonly providerId: string;
|
|
6
|
+
/** The model identifier as the provider knows it. */
|
|
7
|
+
readonly id: string;
|
|
8
|
+
/** Human-readable label shown in the model picker. */
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** Reasoning efforts this model accepts, in picker order. */
|
|
11
|
+
readonly effortLevels: readonly SessionReasoningEffort[];
|
|
12
|
+
/** The effort used when nothing more specific was requested. */
|
|
13
|
+
readonly defaultEffort: SessionReasoningEffort;
|
|
14
|
+
/** Service tiers this model accepts, when the provider offers a choice. */
|
|
15
|
+
readonly serviceTiers?: readonly SessionServiceTier[];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=AgentModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentModel.d.ts","sourceRoot":"","sources":["../sources/AgentModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE1F,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACvB,oEAAoE;IACpE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,SAAS,sBAAsB,EAAE,CAAC;IACzD,gEAAgE;IAChE,QAAQ,CAAC,aAAa,EAAE,sBAAsB,CAAC;IAC/C,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentModel.js","sourceRoot":"","sources":["../sources/AgentModel.ts"],"names":[],"mappings":""}
|