@slopus/happy-agent-base 0.0.4 → 0.0.6

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.
Files changed (52) hide show
  1. package/README.md +35 -1
  2. package/dist/Agent.d.ts +3 -0
  3. package/dist/Agent.d.ts.map +1 -1
  4. package/dist/Agent.js +56 -20
  5. package/dist/Agent.js.map +1 -1
  6. package/dist/AgentBase.d.ts +36 -0
  7. package/dist/AgentBase.d.ts.map +1 -1
  8. package/dist/AgentBase.js +376 -58
  9. package/dist/AgentBase.js.map +1 -1
  10. package/dist/AgentBaseHooks.d.ts +166 -20
  11. package/dist/AgentBaseHooks.d.ts.map +1 -1
  12. package/dist/AgentConfig.d.ts +12 -5
  13. package/dist/AgentConfig.d.ts.map +1 -1
  14. package/dist/AgentConfig.js +25 -5
  15. package/dist/AgentConfig.js.map +1 -1
  16. package/dist/AgentContexts.d.ts +19 -5
  17. package/dist/AgentContexts.d.ts.map +1 -1
  18. package/dist/AgentContexts.js +26 -6
  19. package/dist/AgentContexts.js.map +1 -1
  20. package/dist/AgentFeature.d.ts +48 -10
  21. package/dist/AgentFeature.d.ts.map +1 -1
  22. package/dist/AgentFeatureAction.d.ts +5 -0
  23. package/dist/AgentFeatureAction.d.ts.map +1 -1
  24. package/dist/AgentMetadata.d.ts +37 -0
  25. package/dist/AgentMetadata.d.ts.map +1 -0
  26. package/dist/AgentMetadata.js +74 -0
  27. package/dist/AgentMetadata.js.map +1 -0
  28. package/dist/AgentPermissionMode.d.ts +27 -0
  29. package/dist/AgentPermissionMode.d.ts.map +1 -0
  30. package/dist/AgentPermissionMode.js +48 -0
  31. package/dist/AgentPermissionMode.js.map +1 -0
  32. package/dist/AgentPersistence.d.ts +14 -4
  33. package/dist/AgentPersistence.d.ts.map +1 -1
  34. package/dist/AgentRef.d.ts +6 -1
  35. package/dist/AgentRef.d.ts.map +1 -1
  36. package/dist/AgentRef.js +8 -1
  37. package/dist/AgentRef.js.map +1 -1
  38. package/dist/AgentSystem.d.ts +26 -7
  39. package/dist/AgentSystem.d.ts.map +1 -1
  40. package/dist/AgentSystemLocal.d.ts +14 -8
  41. package/dist/AgentSystemLocal.d.ts.map +1 -1
  42. package/dist/AgentSystemLocal.js +108 -32
  43. package/dist/AgentSystemLocal.js.map +1 -1
  44. package/dist/AgentSystemRef.d.ts +14 -5
  45. package/dist/AgentSystemRef.d.ts.map +1 -1
  46. package/dist/AgentSystemRef.js +25 -6
  47. package/dist/AgentSystemRef.js.map +1 -1
  48. package/dist/index.d.ts +6 -4
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +5 -3
  51. package/dist/index.js.map +1 -1
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AgentConfig.d.ts","sourceRoot":"","sources":["../sources/AgentConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAA0B,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE1E,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,kjBAY9B,CAAC;AAEH,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE/D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,gHAA6C,CAAC;AAEnF,0EAA0E;AAC1E,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,sBAAsB;IAC/B,wEAAwE;;IAExE,8CAA8C;;IAE9C,uDAAuD;;IAEvD,iEAAiE;;EAEnE,CAAC;AAEH,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;IAC1B,qFAAqF;;QApBrF,wEAAwE;;QAExE,8CAA8C;;QAE9C,uD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D;;IAEvD,iEAAiE;;EAEnE,CAAC;AAEH,wEAAwE;AACxE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;IAC1B,qFAAqF;;QApBrF,wEAAwE;;QAExE,8CAA8C;;QAE9C,uDAAuD;;QAEvD,iEAAiE;;;IAgBjE,sFAAsF;;IAEtF,sFAAsF;;;;EAExF,CAAC;AAEH,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAe3D;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,gBAAgB,CAQ1D;AAQD,kFAAkF;AAClF,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAE1E;AAED,iFAAiF;AACjF,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAEjE;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAE3E;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAErE;AAED,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE7F"}
@@ -1,6 +1,8 @@
1
1
  import { release } from "node:os";
2
2
  import { Type } from "@sinclair/typebox";
3
+ import { Value } from "@sinclair/typebox/value";
3
4
  import { createContextNamespace } from "@steve.kite/stdlib";
5
+ import { agentMetadataSchema, ownAgentMetadata } from "./AgentMetadata.js";
4
6
  /** The operating systems Node reports, mirroring `NodeJS.Platform`. */
5
7
  export const agentPlatformSchema = Type.Union([
6
8
  Type.Literal("aix"),
@@ -35,17 +37,31 @@ export const agentEnvironmentSchema = Type.Object({
35
37
  shell: Type.String(),
36
38
  });
37
39
  /**
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.
40
+ * What an agent was created with: the environment it works on, when it has one, one opaque
41
+ * settings map per feature, and descriptive metadata. Environment and feature settings stay
42
+ * fixed; metadata changes only through the agent metadata API, which shallow-merges updates and
43
+ * persists the resulting complete configuration.
42
44
  */
43
45
  export const agentConfigSchema = Type.Object({
44
46
  /** The machine this agent was told it works on, when it was told anything at all. */
45
47
  environment: Type.Optional(agentEnvironmentSchema),
46
48
  /** Per-feature settings, keyed by feature name; each entry is opaque to the agent. */
47
49
  features: Type.Optional(Type.Record(Type.String(), agentFeatureConfigSchema)),
50
+ /** Immutable descriptive metadata, replaced only through a merged metadata update. */
51
+ metadata: Type.Optional(agentMetadataSchema),
48
52
  });
53
+ /** @internal Validate and own one configuration while deeply freezing its metadata. */
54
+ export function ownAgentConfig(config) {
55
+ if (!Value.Check(agentConfigSchema, config)) {
56
+ throw new Error("The agent configuration is not valid.");
57
+ }
58
+ const cloned = structuredClone(config);
59
+ const metadata = ownAgentMetadata(cloned.metadata);
60
+ return {
61
+ ...cloned,
62
+ ...(metadata === undefined ? {} : { metadata }),
63
+ };
64
+ }
49
65
  /**
50
66
  * The environment this process is running in, ready to be handed to an agent at creation. The
51
67
  * platform is typed, so a Node release reporting an unknown platform fails to compile rather
@@ -62,7 +78,7 @@ export function currentAgentEnvironment() {
62
78
  }
63
79
  /** The context slot the agent's configuration is carried in, unset until an agent attaches one. */
64
80
  const configNamespace = createContextNamespace("happyAgentBase.agentConfig", undefined);
65
- /** Carry the configuration an agent was created with; every hook and tool reads it back. */
81
+ /** Carry the agent's current configuration; every hook and tool reads it back. */
66
82
  export function withAgentConfig(ctx, config) {
67
83
  return configNamespace.set(ctx, config);
68
84
  }
@@ -74,6 +90,10 @@ export function agentConfig(ctx) {
74
90
  export function agentEnvironment(ctx) {
75
91
  return configNamespace.get(ctx)?.environment;
76
92
  }
93
+ /** The immutable metadata describing the agent owning this context, when it has any. */
94
+ export function agentMetadata(ctx) {
95
+ return configNamespace.get(ctx)?.metadata;
96
+ }
77
97
  /** The opaque settings the named feature was configured with, if it was configured at all. */
78
98
  export function agentFeatureConfig(ctx, name) {
79
99
  return configNamespace.get(ctx)?.features?.[name];
@@ -1 +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,CAAC;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAKnF;;;GAG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AAC,EAAE,QAAQ,EAAE,CAAC;KAClD,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACnC,MAAM,QAAQ,GAAkB,OAAO,CAAC,QAAQ,CAAC;IACjD,OAAO;QACH,SAAS,EAAE,OAAO,EAAE;QACpB,QAAQ;QACR,gBAAgB,EAAE,OAAO,CAAC,GAAG,EAAE;QAC/B,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;KACjC,CAAC;AACN,CAAC;AAED,mGAAmG;AACnG,MAAM,eAAe,GAAG,sBAAsB,CAC1C,4BAA4B,EAC5B,SAAS,CACZ,CAAC;AAEF,kFAAkF;AAClF,MAAM,UAAU,eAAe,CAAC,GAAY,EAAE,MAAmB;IAC7D,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,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,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAAC,GAAY;IACtC,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;AAC9C,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"}
@@ -1,12 +1,13 @@
1
1
  import type { SessionReasoningEffort, SessionServiceTier } from "@slopus/happy-providers";
2
2
  import { type Context } from "@steve.kite/stdlib";
3
3
  import type { AgentKV } from "./AgentKV.js";
4
+ import { type AgentPermissionMode } from "./AgentPermissionMode.js";
4
5
  /**
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.
6
+ * Derive the agent's context carrying its ID, provider ID, model, effort, service tier, and
7
+ * permission mode — all serializable values. The agent applies this once at construction, so hooks
8
+ * and tool executions can read the values back through the accessors below. The ID is what lets one
9
+ * feature instance serve every agent in a collection: a shared feature learns which agent a hook is
10
+ * running for from the context rather than from something it was constructed with.
10
11
  */
11
12
  export declare function withAgentContext(ctx: Context, values: {
12
13
  readonly id: string;
@@ -14,6 +15,7 @@ export declare function withAgentContext(ctx: Context, values: {
14
15
  readonly model?: string | undefined;
15
16
  readonly effort?: SessionReasoningEffort | undefined;
16
17
  readonly serviceTier?: SessionServiceTier | undefined;
18
+ readonly permissionMode: AgentPermissionMode;
17
19
  }): Context;
18
20
  /** The ID of the agent owning this context. */
19
21
  export declare function agentId(ctx: Context): string | undefined;
@@ -25,6 +27,18 @@ export declare function agentEffort(ctx: Context): SessionReasoningEffort | unde
25
27
  export declare function agentProvider(ctx: Context): string | undefined;
26
28
  /** The service tier configured for the agent owning this context, when one was set. */
27
29
  export declare function agentServiceTier(ctx: Context): SessionServiceTier | undefined;
30
+ /**
31
+ * How much the work on this context may touch. It is the mode the agent is running in, unless a
32
+ * narrower scope replaced it for one execution.
33
+ */
34
+ export declare function agentPermissionMode(ctx: Context): AgentPermissionMode;
35
+ /**
36
+ * Run one stretch of work under another mode. This is how an allowed Auto action is lent the access
37
+ * it was reviewed for: the work derived from this context sees the wider mode, and everything
38
+ * outside it goes on seeing the agent's own. Deriving from a context the agent handed out is what
39
+ * keeps the rest of that context — the agent's identity, its stores, its lifetime — intact.
40
+ */
41
+ export declare function withAgentPermissionMode(ctx: Context, mode: AgentPermissionMode): Context;
28
42
  /** Carry a scoped key-value store on the context, replacing any store carried before. */
29
43
  export declare function withAgentKV(ctx: Context, kv: AgentKV): Context;
30
44
  /** The scoped key-value store carried on this context, when the agent attached one. */
@@ -1 +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,SA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AS,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;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,mBAAmB,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAExF;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"}
@@ -1,4 +1,5 @@
1
1
  import { createContextNamespace } from "@steve.kite/stdlib";
2
+ import { DEFAULT_AGENT_PERMISSION_MODE } from "./AgentPermissionMode.js";
2
3
  /** Backing storage for `agentId`: the ID of the agent owning a context. */
3
4
  const idNamespace = createContextNamespace("agentId", undefined);
4
5
  /** Backing storage for `agentModel`: the model configured for the agent, when one was set. */
@@ -9,23 +10,26 @@ const effortNamespace = createContextNamespace("agentEffort", undefined);
9
10
  const providerNamespace = createContextNamespace("agentProvider", undefined);
10
11
  /** Backing storage for `agentServiceTier`: the service tier configured, when one was set. */
11
12
  const serviceTierNamespace = createContextNamespace("agentServiceTier", undefined);
13
+ /** Backing storage for `agentPermissionMode`: how much the work on a context may touch. */
14
+ const permissionModeNamespace = createContextNamespace("agentPermissionMode", DEFAULT_AGENT_PERMISSION_MODE);
12
15
  /** Backing storage for `agentKV`: the scoped key-value store carried on a context. */
13
16
  const kvNamespace = createContextNamespace("agentKV", undefined);
14
17
  /** Backing storage for `agentRunKV`: the run's own store, erased when the agent settles. */
15
18
  const runKVNamespace = createContextNamespace("agentRunKV", undefined);
16
19
  /**
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.
20
+ * Derive the agent's context carrying its ID, provider ID, model, effort, service tier, and
21
+ * permission mode — all serializable values. The agent applies this once at construction, so hooks
22
+ * and tool executions can read the values back through the accessors below. The ID is what lets one
23
+ * feature instance serve every agent in a collection: a shared feature learns which agent a hook is
24
+ * running for from the context rather than from something it was constructed with.
22
25
  */
23
26
  export function withAgentContext(ctx, values) {
24
27
  const withId = idNamespace.set(ctx, values.id);
25
28
  const withProvider = providerNamespace.set(withId, values.provider);
26
29
  const withModel = modelNamespace.set(withProvider, values.model);
27
30
  const withEffort = effortNamespace.set(withModel, values.effort);
28
- return serviceTierNamespace.set(withEffort, values.serviceTier);
31
+ const withTier = serviceTierNamespace.set(withEffort, values.serviceTier);
32
+ return permissionModeNamespace.set(withTier, values.permissionMode);
29
33
  }
30
34
  /** The ID of the agent owning this context. */
31
35
  export function agentId(ctx) {
@@ -47,6 +51,22 @@ export function agentProvider(ctx) {
47
51
  export function agentServiceTier(ctx) {
48
52
  return serviceTierNamespace.get(ctx);
49
53
  }
54
+ /**
55
+ * How much the work on this context may touch. It is the mode the agent is running in, unless a
56
+ * narrower scope replaced it for one execution.
57
+ */
58
+ export function agentPermissionMode(ctx) {
59
+ return permissionModeNamespace.get(ctx);
60
+ }
61
+ /**
62
+ * Run one stretch of work under another mode. This is how an allowed Auto action is lent the access
63
+ * it was reviewed for: the work derived from this context sees the wider mode, and everything
64
+ * outside it goes on seeing the agent's own. Deriving from a context the agent handed out is what
65
+ * keeps the rest of that context — the agent's identity, its stores, its lifetime — intact.
66
+ */
67
+ export function withAgentPermissionMode(ctx, mode) {
68
+ return permissionModeNamespace.set(ctx, mode);
69
+ }
50
70
  /** Carry a scoped key-value store on the context, replacing any store carried before. */
51
71
  export function withAgentKV(ctx, kv) {
52
72
  return kvNamespace.set(ctx, kv);
@@ -1 +1 @@
1
- {"version":3,"file":"AgentContexts.js","sourceRoot":"","sources":["../sources/AgentContexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAgB,MAAM,oBAAoB,CAAC;AAI1E,2EAA2E;AAC3E,MAAM,WAAW,GAAG,sBAAsB,CAAqB,SAAS,EAAE,SAAS,CAAC,CAAC;AACrF,8FAA8F;AAC9F,MAAM,cAAc,GAAG,sBAAsB,CAAqB,YAAY,EAAE,SAAS,CAAC,CAAC;AAC3F,4FAA4F;AAC5F,MAAM,eAAe,GAAG,sBAAsB,CAC1C,aAAa,EACb,SAAS,CACZ,CAAC;AACF,6FAA6F;AAC7F,MAAM,iBAAiB,GAAG,sBAAsB,CAAqB,eAAe,EAAE,SAAS,CAAC,CAAC;AACjG,6FAA6F;AAC7F,MAAM,oBAAoB,GAAG,sBAAsB,CAC/C,kBAAkB,EAClB,SAAS,CACZ,CAAC;AACF,sFAAsF;AACtF,MAAM,WAAW,GAAG,sBAAsB,CAAsB,SAAS,EAAE,SAAS,CAAC,CAAC;AACtF,4FAA4F;AAC5F,MAAM,cAAc,GAAG,sBAAsB,CAAsB,YAAY,EAAE,SAAS,CAAC,CAAC;AAE5F;;;;;;GAMG;AACH,MAAM,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AACH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC5C,OAAO,uBAAuB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAY,EAAE,IAAyB;IAC3E,OAAO,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAClD,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"}
@@ -1,8 +1,10 @@
1
- import type { ProviderModelCompatibilityType, SessionEvent, SessionReasoningEffort, SessionServiceTier, SessionSystemMessage } from "@slopus/happy-providers";
1
+ import type { ProviderModelCompatibilityType, SessionEvent, SessionReasoningEffort, SessionServiceTier, SessionSystemMessage, SessionToolCallBlock, SessionToolResultMessage } from "@slopus/happy-providers";
2
2
  import type { Context } from "@steve.kite/stdlib";
3
- import type { AgentBaseInference, AgentBaseModelChange, AgentBasePersistedEvent, AgentBaseToolExecution, AgentBaseTurn, AgentBaseTurnStart, MaybePromise } from "./AgentBaseHooks.js";
3
+ import type { AgentBaseAcceptedMessage, AgentBaseInference, AgentBaseModelChange, AgentBasePermissionModeChange, AgentBasePersistedEvent, AgentBaseToolCall, AgentBaseToolCallDecision, AgentBaseToolOutcome, AgentBaseTurn, AgentBaseTurnStart, MaybePromise } from "./AgentBaseHooks.js";
4
4
  import type { AgentFeatureAction } from "./AgentFeatureAction.js";
5
5
  import type { AgentKV } from "./AgentKV.js";
6
+ import type { AgentMetadata, AgentMetadataChange } from "./AgentMetadata.js";
7
+ import type { AgentPermissionMode } from "./AgentPermissionMode.js";
6
8
  import type { AgentSystemRef } from "./AgentSystemRef.js";
7
9
  import type { AnyAgentTool } from "./AgentTool.js";
8
10
  /**
@@ -11,8 +13,10 @@ import type { AnyAgentTool } from "./AgentTool.js";
11
13
  * it is looking at, and what that agent is about to run on.
12
14
  */
13
15
  export interface AgentFeatureAgent {
14
- /** The system-generated identity of the agent, stable for its whole life. */
16
+ /** The generated or caller-supplied cuid2 identity, stable for the agent's whole life. */
15
17
  readonly id: string;
18
+ /** The immutable descriptive metadata currently stored in this agent's configuration. */
19
+ readonly metadata: AgentMetadata | undefined;
16
20
  /** The registry ID of the provider in force, which one agent may switch between. */
17
21
  readonly provider: string;
18
22
  /**
@@ -27,6 +31,12 @@ export interface AgentFeatureAgent {
27
31
  readonly effort: SessionReasoningEffort | undefined;
28
32
  /** The service tier in force, absent when none was ever selected. */
29
33
  readonly tier: SessionServiceTier | undefined;
34
+ /**
35
+ * How much of the machine the agent may touch. The runtime carries it and makes its changes
36
+ * durable but enforces nothing, so a feature whose tools act on the machine is what decides
37
+ * what this mode actually permits.
38
+ */
39
+ readonly permissionMode: AgentPermissionMode;
30
40
  }
31
41
  /**
32
42
  * What every hook of a feature is handed alongside the context: which agent it is running for,
@@ -78,14 +88,14 @@ export interface AgentFeature<Tool extends AnyAgentTool = AnyAgentTool> {
78
88
  * store lock and before any agent is restored or started. Every feature initializes
79
89
  * concurrently, and agent work begins only after all of them settle successfully.
80
90
  */
81
- readonly beforeStart?: (ctx: Context, agents: AgentSystemRef) => Promise<void>;
91
+ readonly beforeStart?: (ctx: Context, agents: AgentSystemRef) => MaybePromise<void>;
82
92
  /**
83
93
  * Called once after every durable-active agent has been restored and started. Every feature
84
94
  * runs concurrently, and system creation resolves only after all of them settle successfully.
85
95
  */
86
- readonly afterStart?: (ctx: Context, agents: AgentSystemRef) => Promise<void>;
87
- /** Observes every session event; must never fail or delay the run. */
88
- readonly onEvent?: (ctx: Context, scope: AgentFeatureScope, event: SessionEvent) => void;
96
+ readonly afterStart?: (ctx: Context, agents: AgentSystemRef) => MaybePromise<void>;
97
+ /** Observes every session event; the run awaits it and contains its failure. */
98
+ readonly onEvent?: (ctx: Context, scope: AgentFeatureScope, event: SessionEvent) => MaybePromise<unknown>;
89
99
  /** Runs inside the transaction committing a completed assistant block. */
90
100
  readonly onEventTransact?: (ctx: Context, scope: AgentFeatureScope, event: AgentBasePersistedEvent) => MaybePromise<void>;
91
101
  /** Merged after the base state and every earlier feature's instructions, in feature order. */
@@ -93,12 +103,40 @@ export interface AgentFeature<Tool extends AnyAgentTool = AnyAgentTool> {
93
103
  /** Merged after the base state and every earlier feature's tools, in feature order. */
94
104
  readonly tools?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<readonly Tool[]>;
95
105
  /**
96
- * Wraps validated tool execution. Features compose as nested middleware in array order.
97
- * See `AgentBaseHooks.aroundToolExecution` for the continuation contract.
106
+ * Runs inside the transaction that makes a dispatched batch durable, once per call in it.
107
+ * Features run in array order and a failure propagates, rolling the dispatch back.
108
+ */
109
+ readonly beforeToolCallTransact?: (ctx: Context, scope: AgentFeatureScope, call: SessionToolCallBlock) => MaybePromise<void>;
110
+ /**
111
+ * Decides what to do with one validated call before it runs. Features are asked in array
112
+ * order: what one of them amends is what the next one sees, and the first to answer the model
113
+ * settles the call and ends the chain.
98
114
  */
99
- readonly aroundToolExecution?: (ctx: Context, scope: AgentFeatureScope, execution: AgentBaseToolExecution) => MaybePromise<unknown>;
115
+ readonly beforeToolCall?: (ctx: Context, scope: AgentFeatureScope, call: AgentBaseToolCall) => MaybePromise<AgentBaseToolCallDecision | undefined>;
116
+ /** Observes what one call produced, before its result is committed. */
117
+ readonly afterToolCall?: (ctx: Context, scope: AgentFeatureScope, outcome: AgentBaseToolOutcome) => MaybePromise<void>;
118
+ /**
119
+ * Runs inside the transaction appending one tool result to the durable conversation. Features
120
+ * run in array order and a failure propagates, rolling that commit back.
121
+ */
122
+ readonly afterToolCallTransact?: (ctx: Context, scope: AgentFeatureScope, result: SessionToolResultMessage) => MaybePromise<void>;
100
123
  /** The first feature that returns a handoff message wins the reset injection. */
101
124
  readonly modelChanged?: (ctx: Context, scope: AgentFeatureScope, change: AgentBaseModelChange) => MaybePromise<SessionSystemMessage | undefined>;
125
+ /**
126
+ * Runs inside the transaction appending a queued message to the durable conversation, once per
127
+ * message. Features run in array order and a failure propagates, rolling the consumption back.
128
+ */
129
+ readonly messageAcceptedTransact?: (ctx: Context, scope: AgentFeatureScope, accepted: AgentBaseAcceptedMessage) => MaybePromise<void>;
130
+ /** Observes the same messages once the consumption has committed. */
131
+ readonly messageAccepted?: (ctx: Context, scope: AgentFeatureScope, accepted: AgentBaseAcceptedMessage) => MaybePromise<void>;
132
+ /** Transactional counterpart to `permissionModeChanged`; a failure rolls the change back. */
133
+ readonly permissionModeChangedTransact?: (ctx: Context, scope: AgentFeatureScope, change: AgentBasePermissionModeChange) => MaybePromise<void>;
134
+ /** Observes a permission-mode change a consumed message made, once it is durable. */
135
+ readonly permissionModeChanged?: (ctx: Context, scope: AgentFeatureScope, change: AgentBasePermissionModeChange) => MaybePromise<void>;
136
+ /** Transactional counterpart to `metadataChanged`; a failure rolls the merge back. */
137
+ readonly metadataChangedTransact?: (ctx: Context, scope: AgentFeatureScope, change: AgentMetadataChange) => MaybePromise<void>;
138
+ /** Observes the complete merged agent metadata after it commits. */
139
+ readonly metadataChanged?: (ctx: Context, scope: AgentFeatureScope, change: AgentMetadataChange) => MaybePromise<void>;
102
140
  /** Transactional counterpart to `beforeAgentLoop`. */
103
141
  readonly beforeAgentLoopTransact?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
104
142
  /** Called when the loop leaves the settled state and begins working. */
@@ -1 +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,uBAAuB,EACvB,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;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAC9B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,8BAA8B,GAAG,SAAS,CAAC;IAClE,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC;IACpD,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAAC;CACjD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAC9B,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;I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AE,OAAO,EACZ,KAAK,EAAE,iBAAiB,EACxB,IAAI,EAAE,aAAa,KAClB,YAAY,CAAC,SAAS,kBAAkB,EAAE,GAAG,SAAS,CAAC,CAAC;IAC7D,qDAAqD;IACrD,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAC9B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,iBAAiB,KACvB,YAAY,CAAC,IAAI,CAAC,CAAC;IACxB,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"}
@@ -1,4 +1,5 @@
1
1
  import type { SessionUserMessage } from "@slopus/happy-providers";
2
+ import type { AgentMessageMetadata } from "./AgentMetadata.js";
2
3
  /**
3
4
  * What a lifecycle hook can ask the agent to do next: queue a steering or sent message through
4
5
  * the ordinary durable queues, or trigger a compaction. An action drives the loop exactly like
@@ -6,10 +7,14 @@ import type { SessionUserMessage } from "@slopus/happy-providers";
6
7
  */
7
8
  export type AgentFeatureAction = {
8
9
  readonly type: "steer";
10
+ readonly id?: string;
9
11
  readonly message: SessionUserMessage;
12
+ readonly metadata?: AgentMessageMetadata;
10
13
  } | {
11
14
  readonly type: "send";
15
+ readonly id?: string;
12
16
  readonly message: SessionUserMessage;
17
+ readonly metadata?: AgentMessageMetadata;
13
18
  } | {
14
19
  readonly type: "compact";
15
20
  };
@@ -1 +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"}
1
+ {"version":3,"file":"AgentFeatureAction.d.ts","sourceRoot":"","sources":["../sources/AgentFeatureAction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GACxB;IACI,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CAC5C,GACD;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CAC5C,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ /** A cuid2 identity: two to thirty-two lowercase alphanumeric characters, opening with a letter. */
3
+ export declare const cuid2Schema: import("@sinclair/typebox").TString;
4
+ /** JSON values metadata may contain, so every metadata object is safe to persist and clone. */
5
+ export declare const agentMetadataValueSchema: import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>;
6
+ /** The TypeScript type inferred from {@link agentMetadataValueSchema}. */
7
+ export type AgentMetadataValue = Static<typeof agentMetadataValueSchema>;
8
+ /**
9
+ * Metadata attached to one queued message. Features own additional fields; `hideFromUser` is the
10
+ * common hint that a presentation feature should keep this message out of the user-visible view.
11
+ */
12
+ export declare const agentMessageMetadataSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
13
+ hideFromUser: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
14
+ }>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>>]>;
15
+ /** The TypeScript type inferred from {@link agentMessageMetadataSchema}. */
16
+ export type AgentMessageMetadata = Static<typeof agentMessageMetadataSchema>;
17
+ /**
18
+ * Mutable-by-replacement metadata describing one agent. Features own additional fields; `title`
19
+ * is the common human-readable label.
20
+ */
21
+ export declare const agentMetadataSchema: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
22
+ title: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
23
+ }>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TRecursive<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TThis>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TThis>]>>>]>;
24
+ /** The TypeScript type inferred from {@link agentMetadataSchema}. */
25
+ export type AgentMetadata = Static<typeof agentMetadataSchema>;
26
+ /** What metadata-change hooks see after an update has been merged with the previous object. */
27
+ export interface AgentMetadataChange {
28
+ /** The agent whose metadata changed. */
29
+ readonly agentId: string;
30
+ /** The complete immutable metadata before the update. */
31
+ readonly previousMetadata: AgentMetadata;
32
+ /** The immutable fields supplied by this update. */
33
+ readonly update: AgentMetadata;
34
+ /** The complete immutable result after the shallow merge. */
35
+ readonly metadata: AgentMetadata;
36
+ }
37
+ //# sourceMappingURL=AgentMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentMetadata.d.ts","sourceRoot":"","sources":["../sources/AgentMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtD,oGAAoG;AACpG,eAAO,MAAM,WAAW,qCAItB,CAAC;AAEH,+FAA+F;AAC/F,eAAO,MAAM,wBAAwB,qZASpC,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;meAKrC,CAAC;AAEH,4EAA4E;AAC5E,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;meAK9B,CAAC;AAEH,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE/D,+FAA+F;AAC/F,MAAM,WAAW,mBAAmB;IAChC,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,gBAAgB,EAAE,aAAa,CAAC;IACzC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;CACpC"}
@@ -0,0 +1,74 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { Value } from "@sinclair/typebox/value";
3
+ /** A cuid2 identity: two to thirty-two lowercase alphanumeric characters, opening with a letter. */
4
+ export const cuid2Schema = Type.String({
5
+ minLength: 2,
6
+ maxLength: 32,
7
+ pattern: "^[a-z][a-z0-9]*$",
8
+ });
9
+ /** JSON values metadata may contain, so every metadata object is safe to persist and clone. */
10
+ export const agentMetadataValueSchema = Type.Recursive((value) => Type.Union([
11
+ Type.String(),
12
+ Type.Number(),
13
+ Type.Boolean(),
14
+ Type.Null(),
15
+ Type.Array(value),
16
+ Type.Record(Type.String(), value),
17
+ ]));
18
+ /**
19
+ * Metadata attached to one queued message. Features own additional fields; `hideFromUser` is the
20
+ * common hint that a presentation feature should keep this message out of the user-visible view.
21
+ */
22
+ export const agentMessageMetadataSchema = Type.Intersect([
23
+ Type.Object({
24
+ hideFromUser: Type.Optional(Type.Boolean()),
25
+ }),
26
+ Type.Record(Type.String(), agentMetadataValueSchema),
27
+ ]);
28
+ /**
29
+ * Mutable-by-replacement metadata describing one agent. Features own additional fields; `title`
30
+ * is the common human-readable label.
31
+ */
32
+ export const agentMetadataSchema = Type.Intersect([
33
+ Type.Object({
34
+ title: Type.Optional(Type.String()),
35
+ }),
36
+ Type.Record(Type.String(), agentMetadataValueSchema),
37
+ ]);
38
+ /** @internal Validate, clone, and deeply freeze message metadata at its ownership boundary. */
39
+ export function ownAgentMessageMetadata(metadata) {
40
+ if (metadata === undefined)
41
+ return undefined;
42
+ if (!Value.Check(agentMessageMetadataSchema, metadata)) {
43
+ throw new Error("The message metadata is not valid.");
44
+ }
45
+ return immutableClone(metadata);
46
+ }
47
+ /** @internal Validate, clone, and deeply freeze agent metadata at its ownership boundary. */
48
+ export function ownAgentMetadata(metadata) {
49
+ if (metadata === undefined)
50
+ return undefined;
51
+ if (!Value.Check(agentMetadataSchema, metadata)) {
52
+ throw new Error("The agent metadata is not valid.");
53
+ }
54
+ return immutableClone(metadata);
55
+ }
56
+ /** Clone one persisted value and freeze every object reachable through ordinary properties. */
57
+ function immutableClone(value) {
58
+ return deepFreeze(structuredClone(value), new WeakSet());
59
+ }
60
+ function deepFreeze(value, seen) {
61
+ if (value === null || typeof value !== "object")
62
+ return value;
63
+ if (seen.has(value))
64
+ return value;
65
+ seen.add(value);
66
+ for (const key of Reflect.ownKeys(value)) {
67
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
68
+ if (descriptor !== undefined && "value" in descriptor) {
69
+ deepFreeze(descriptor.value, seen);
70
+ }
71
+ }
72
+ return Object.freeze(value);
73
+ }
74
+ //# sourceMappingURL=AgentMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentMetadata.js","sourceRoot":"","sources":["../sources/AgentMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,oGAAoG;AACpG,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,kBAAkB;CAC9B,CAAC,CAAC;AAEH,+FAA+F;AAC/F,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7D,IAAI,CAAC,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E,OAAO,SAAS,CAAC;IAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,QAAQ,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED,+FAA+F;AAC/F,SAAS,cAAc,CAAQ,KAAY;IACvC,OAAO,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,IAAI,OAAO,EAAU,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,UAAU,CAAQ,KAAY,EAAE,IAAqB;IAC1D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC/D,IAAI,UAAU,KAAK,SAAS,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;YACpD,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ /**
3
+ * How much of the machine an agent is allowed to touch, as one of four modes.
4
+ *
5
+ * The mode is part of what an agent is running on, exactly like its model: it is carried on every
6
+ * context the agent derives, it is durable, and a message may change it. What the runtime does not
7
+ * do is enforce it — the loop has no idea what any particular tool touches. Enforcement belongs to
8
+ * the features and tools that know, and they read the mode in force from the context they are
9
+ * given.
10
+ */
11
+ export declare const agentPermissionModeSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"read_only">, import("@sinclair/typebox").TLiteral<"workspace_write">, import("@sinclair/typebox").TLiteral<"auto">, import("@sinclair/typebox").TLiteral<"full_access">]>;
12
+ /** The TypeScript type inferred from {@link agentPermissionModeSchema}. */
13
+ export type AgentPermissionMode = Static<typeof agentPermissionModeSchema>;
14
+ /**
15
+ * The mode an agent runs in when nobody has said otherwise. Auto is the product's default: work
16
+ * happens in the sandbox, and the one action that has to leave it is reviewed rather than refused.
17
+ */
18
+ export declare const DEFAULT_AGENT_PERMISSION_MODE: AgentPermissionMode;
19
+ /**
20
+ * Whether a value is one of the four modes. Durable state is read back through this rather than
21
+ * trusted, so a store holding something else falls back to the mode the agent was built with
22
+ * instead of running under a mode nothing can interpret.
23
+ */
24
+ export declare function isAgentPermissionMode(value: unknown): value is AgentPermissionMode;
25
+ /** The mode's name in the words a person reads, for anything shown to a person or a model. */
26
+ export declare function agentPermissionModeLabel(mode: AgentPermissionMode): string;
27
+ //# sourceMappingURL=AgentPermissionMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentPermissionMode.d.ts","sourceRoot":"","sources":["../sources/AgentPermissionMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,qPAYrC,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,mBAA4B,CAAC;AAEzE;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAElF;AAED,8FAA8F;AAC9F,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAW1E"}
@@ -0,0 +1,48 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ import { Value } from "@sinclair/typebox/value";
3
+ /**
4
+ * How much of the machine an agent is allowed to touch, as one of four modes.
5
+ *
6
+ * The mode is part of what an agent is running on, exactly like its model: it is carried on every
7
+ * context the agent derives, it is durable, and a message may change it. What the runtime does not
8
+ * do is enforce it — the loop has no idea what any particular tool touches. Enforcement belongs to
9
+ * the features and tools that know, and they read the mode in force from the context they are
10
+ * given.
11
+ */
12
+ export const agentPermissionModeSchema = Type.Union([
13
+ /** Inspection only: nothing may be changed and the shell reaches no network. */
14
+ Type.Literal("read_only"),
15
+ /** Changes inside the workspace, with shell network and outside writes still blocked. */
16
+ Type.Literal("workspace_write"),
17
+ /** The workspace sandbox, plus a review that may allow one action to cross it. */
18
+ Type.Literal("auto"),
19
+ /** No filesystem, shell, or network restriction of Rig's own. */
20
+ Type.Literal("full_access"),
21
+ ], { description: "How much of the machine the agent may touch." });
22
+ /**
23
+ * The mode an agent runs in when nobody has said otherwise. Auto is the product's default: work
24
+ * happens in the sandbox, and the one action that has to leave it is reviewed rather than refused.
25
+ */
26
+ export const DEFAULT_AGENT_PERMISSION_MODE = "auto";
27
+ /**
28
+ * Whether a value is one of the four modes. Durable state is read back through this rather than
29
+ * trusted, so a store holding something else falls back to the mode the agent was built with
30
+ * instead of running under a mode nothing can interpret.
31
+ */
32
+ export function isAgentPermissionMode(value) {
33
+ return Value.Check(agentPermissionModeSchema, value);
34
+ }
35
+ /** The mode's name in the words a person reads, for anything shown to a person or a model. */
36
+ export function agentPermissionModeLabel(mode) {
37
+ switch (mode) {
38
+ case "read_only":
39
+ return "Read only";
40
+ case "workspace_write":
41
+ return "Workspace write";
42
+ case "auto":
43
+ return "Auto";
44
+ case "full_access":
45
+ return "Full access";
46
+ }
47
+ }
48
+ //# sourceMappingURL=AgentPermissionMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentPermissionMode.js","sourceRoot":"","sources":["../sources/AgentPermissionMode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC,KAAK,CAC/C;IACI,gFAAgF;IAChF,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IACzB,yFAAyF;IACzF,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IAC/B,kFAAkF;IAClF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IACpB,iEAAiE;IACjE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;CAC9B,EACD,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAClE,CAAC;AAKF;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,MAAM,CAAC;AAEzE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAChD,OAAO,KAAK,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,wBAAwB,CAAC,IAAyB;IAC9D,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,WAAW;YACZ,OAAO,WAAW,CAAC;QACvB,KAAK,iBAAiB;YAClB,OAAO,iBAAiB,CAAC;QAC7B,KAAK,MAAM;YACP,OAAO,MAAM,CAAC;QAClB,KAAK,aAAa;YACd,OAAO,aAAa,CAAC;IAC7B,CAAC;AACL,CAAC"}