@slopus/happy-agent-base 0.0.6 → 0.0.8
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/README.md +52 -11
- package/dist/Agent.d.ts +24 -22
- package/dist/Agent.d.ts.map +1 -1
- package/dist/Agent.js +113 -111
- package/dist/Agent.js.map +1 -1
- package/dist/AgentBase.d.ts +18 -14
- package/dist/AgentBase.d.ts.map +1 -1
- package/dist/AgentBase.js +486 -122
- package/dist/AgentBase.js.map +1 -1
- package/dist/AgentBaseHooks.d.ts +41 -28
- package/dist/AgentBaseHooks.d.ts.map +1 -1
- package/dist/AgentBasePending.d.ts +6 -2
- package/dist/AgentBasePending.d.ts.map +1 -1
- package/dist/AgentBasePending.js +7 -0
- package/dist/AgentBasePending.js.map +1 -1
- package/dist/AgentConfig.d.ts +9 -9
- package/dist/AgentConfig.d.ts.map +1 -1
- package/dist/AgentConfig.js +8 -8
- package/dist/AgentConfig.js.map +1 -1
- package/dist/AgentContexts.d.ts +25 -1
- package/dist/AgentContexts.d.ts.map +1 -1
- package/dist/AgentContexts.js +46 -2
- package/dist/AgentContexts.js.map +1 -1
- package/dist/AgentDatabase.d.ts +35 -0
- package/dist/AgentDatabase.d.ts.map +1 -0
- package/dist/AgentDatabase.js +30 -0
- package/dist/AgentDatabase.js.map +1 -0
- package/dist/AgentKV.d.ts +19 -6
- package/dist/AgentKV.d.ts.map +1 -1
- package/dist/AgentKV.js +110 -43
- package/dist/AgentKV.js.map +1 -1
- package/dist/AgentMessageAcceptance.d.ts +14 -0
- package/dist/AgentMessageAcceptance.d.ts.map +1 -0
- package/dist/AgentMessageAcceptance.js +2 -0
- package/dist/AgentMessageAcceptance.js.map +1 -0
- package/dist/AgentMetadata.d.ts +3 -3
- package/dist/AgentMetadata.js +3 -3
- package/dist/AgentModule.d.ts +209 -0
- package/dist/AgentModule.d.ts.map +1 -0
- package/dist/AgentModule.js +2 -0
- package/dist/AgentModule.js.map +1 -0
- package/dist/{AgentFeatureAction.d.ts → AgentModuleAction.d.ts} +2 -2
- package/dist/AgentModuleAction.d.ts.map +1 -0
- package/dist/AgentModuleAction.js +2 -0
- package/dist/AgentModuleAction.js.map +1 -0
- package/dist/AgentPermissionMode.d.ts +1 -1
- package/dist/AgentPermissionMode.js +1 -1
- package/dist/AgentPersistence.d.ts +7 -4
- package/dist/AgentPersistence.d.ts.map +1 -1
- package/dist/AgentPersistenceDrizzle.d.ts +29 -0
- package/dist/AgentPersistenceDrizzle.d.ts.map +1 -0
- package/dist/AgentPersistenceDrizzle.js +112 -0
- package/dist/AgentPersistenceDrizzle.js.map +1 -0
- package/dist/AgentRef.d.ts +12 -9
- package/dist/AgentRef.d.ts.map +1 -1
- package/dist/AgentRef.js +8 -8
- package/dist/AgentRef.js.map +1 -1
- package/dist/AgentStorage.d.ts +26 -12
- package/dist/AgentStorage.d.ts.map +1 -1
- package/dist/AgentStorage.js +90 -3
- package/dist/AgentStorage.js.map +1 -1
- package/dist/AgentSystem.d.ts +10 -7
- package/dist/AgentSystem.d.ts.map +1 -1
- package/dist/AgentSystemContext.d.ts +5 -4
- package/dist/AgentSystemContext.d.ts.map +1 -1
- package/dist/AgentSystemContext.js +4 -4
- package/dist/AgentSystemContext.js.map +1 -1
- package/dist/AgentSystemLocal.d.ts +17 -14
- package/dist/AgentSystemLocal.d.ts.map +1 -1
- package/dist/AgentSystemLocal.js +120 -29
- package/dist/AgentSystemLocal.js.map +1 -1
- package/dist/AgentSystemRef.d.ts +9 -7
- package/dist/AgentSystemRef.d.ts.map +1 -1
- package/dist/AgentSystemRef.js +17 -4
- package/dist/AgentSystemRef.js.map +1 -1
- package/dist/AgentTool.d.ts +24 -2
- package/dist/AgentTool.d.ts.map +1 -1
- package/dist/AgentTool.js.map +1 -1
- package/dist/inTx.d.ts +17 -0
- package/dist/inTx.d.ts.map +1 -0
- package/dist/inTx.js +65 -0
- package/dist/inTx.js.map +1 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/AgentFeature.d.ts +0 -184
- package/dist/AgentFeature.d.ts.map +0 -1
- package/dist/AgentFeature.js +0 -2
- package/dist/AgentFeature.js.map +0 -1
- package/dist/AgentFeatureAction.d.ts.map +0 -1
- package/dist/AgentFeatureAction.js +0 -2
- package/dist/AgentFeatureAction.js.map +0 -1
package/dist/AgentTool.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentTool.js","sourceRoot":"","sources":["../sources/AgentTool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AgentTool.js","sourceRoot":"","sources":["../sources/AgentTool.ts"],"names":[],"mappings":"AAkHA,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAC3B,IAA6B;IAE7B,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
package/dist/inTx.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Context } from "@steve.kite/stdlib";
|
|
2
|
+
/** Work whose database operations should share one outer Agent Storage transaction. */
|
|
3
|
+
export type AgentTransactionWork<Result> = (ctx: Context) => Result | PromiseLike<Result>;
|
|
4
|
+
declare global {
|
|
5
|
+
namespace stdlib {
|
|
6
|
+
interface ContextExtensions {
|
|
7
|
+
readonly inTx: <Result>(work: AgentTransactionWork<Result>) => Promise<Awaited<Result>>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Run work inside the database transaction carried by `ctx`, or open the one outer transaction
|
|
13
|
+
* for its root database. Nested calls reuse the current transaction; transaction concurrency
|
|
14
|
+
* belongs to the Drizzle database and its driver.
|
|
15
|
+
*/
|
|
16
|
+
export declare function inTx<Result>(ctx: Context, work: AgentTransactionWork<Result>): Promise<Awaited<Result>>;
|
|
17
|
+
//# sourceMappingURL=inTx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inTx.d.ts","sourceRoot":"","sources":["../sources/inTx.ts"],"names":[],"mappings":"AAEA,OAAO,EAA6C,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAU7F,uFAAuF;AACvF,MAAM,MAAM,oBAAoB,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AAE1F,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM,CAAC;QACb,UAAU,iBAAiB;YACvB,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;SAC3F;KACJ;CACJ;AAWD;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,MAAM,EAC7B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACnC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAgD1B"}
|
package/dist/inTx.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { registerContextExtension, withAfterCommit } from "@steve.kite/stdlib";
|
|
3
|
+
import { isAgentSQLiteDatabase } from "./AgentDatabase.js";
|
|
4
|
+
import { agentDatabase, agentStorageTransaction, withAgentStorageTransaction, } from "./AgentContexts.js";
|
|
5
|
+
const activeTransactions = new AsyncLocalStorage();
|
|
6
|
+
registerContextExtension("inTx", (ctx) => async (work) => await inTx(ctx, work));
|
|
7
|
+
/**
|
|
8
|
+
* Run work inside the database transaction carried by `ctx`, or open the one outer transaction
|
|
9
|
+
* for its root database. Nested calls reuse the current transaction; transaction concurrency
|
|
10
|
+
* belongs to the Drizzle database and its driver.
|
|
11
|
+
*/
|
|
12
|
+
export async function inTx(ctx, work) {
|
|
13
|
+
const carried = agentStorageTransaction(ctx);
|
|
14
|
+
const ambient = activeTransactions.getStore();
|
|
15
|
+
if (ambient !== undefined && !ambient.lifetime.aborted) {
|
|
16
|
+
if (carried === ambient)
|
|
17
|
+
return await work(ctx);
|
|
18
|
+
throw new Error("Work started inside an agent storage transaction must use that transaction's context.");
|
|
19
|
+
}
|
|
20
|
+
if (carried !== undefined) {
|
|
21
|
+
if (carried.lifetime.aborted) {
|
|
22
|
+
throw new Error("The agent storage transaction carried by this context has ended.");
|
|
23
|
+
}
|
|
24
|
+
return await work(ctx);
|
|
25
|
+
}
|
|
26
|
+
const root = agentDatabase(ctx);
|
|
27
|
+
if (root === undefined) {
|
|
28
|
+
throw new Error("Context has no agent database.");
|
|
29
|
+
}
|
|
30
|
+
const commit = async (transactionCtx) => {
|
|
31
|
+
let runAfterCommit;
|
|
32
|
+
const result = await runDrizzleTransaction(root, async (database) => {
|
|
33
|
+
const [afterCommitCtx, drain] = withAfterCommit(transactionCtx);
|
|
34
|
+
runAfterCommit = drain;
|
|
35
|
+
const lifetime = new AbortController();
|
|
36
|
+
const state = {
|
|
37
|
+
database,
|
|
38
|
+
root,
|
|
39
|
+
lifetime: lifetime.signal,
|
|
40
|
+
};
|
|
41
|
+
const txCtx = withAgentStorageTransaction(afterCommitCtx, state);
|
|
42
|
+
try {
|
|
43
|
+
return await activeTransactions.run(state, async () => await work(txCtx));
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
lifetime.abort();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
await runAfterCommit();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
transactionCtx.log.warn("Agent storage committed, but post-commit work failed.", error);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
return await commit(ctx);
|
|
58
|
+
}
|
|
59
|
+
async function runDrizzleTransaction(database, work) {
|
|
60
|
+
if (isAgentSQLiteDatabase(database)) {
|
|
61
|
+
return await database.transaction(async (transaction) => await work(transaction));
|
|
62
|
+
}
|
|
63
|
+
return await database.transaction(async (transaction) => await work(transaction));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=inTx.js.map
|
package/dist/inTx.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inTx.js","sourceRoot":"","sources":["../sources/inTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAgB,MAAM,oBAAoB,CAAC;AAE7F,OAAO,EAAE,qBAAqB,EAAsB,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACH,aAAa,EACb,uBAAuB,EACvB,2BAA2B,GAE9B,MAAM,oBAAoB,CAAC;AAa5B,MAAM,kBAAkB,GAAG,IAAI,iBAAiB,EAAkC,CAAC;AAEnF,wBAAwB,CACpB,MAAM,EACN,CAAC,GAAG,EAAE,EAAE,CACJ,KAAK,EAAU,IAAkC,EAA4B,EAAE,CAC3E,MAAM,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAChC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACtB,GAAY,EACZ,IAAkC;IAElC,MAAM,OAAO,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ,EAAE,CAAC;IAC9C,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,OAAO;YAAE,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,IAAI,KAAK,CACX,uFAAuF,CAC1F,CAAC;IACN,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC3B,MAAM,IA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O,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,KAAK,UAAU,qBAAqB,CAChC,QAAuB,EACvB,IAAkD;IAElD,IAAI,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,OAAO,MAAM,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,MAAM,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AACtF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,22 +6,25 @@ export { AgentSystemLocal, type AgentSystemLocalOptions } from "./AgentSystemLoc
|
|
|
6
6
|
export { AgentSystemRef } from "./AgentSystemRef.js";
|
|
7
7
|
export { AgentRef } from "./AgentRef.js";
|
|
8
8
|
export { agentSystem, withAgentSystem } from "./AgentSystemContext.js";
|
|
9
|
-
export { agentConfig, agentConfigSchema,
|
|
9
|
+
export { agentConfig, agentConfigSchema, agentModuleConfig, agentMetadata, agentEnvironment, agentEnvironmentSchema, agentModuleConfigSchema, agentPlatformSchema, currentAgentEnvironment, withAgentConfig, type AgentConfig, type AgentEnvironment, type AgentModuleConfig, type AgentPlatform, } from "./AgentConfig.js";
|
|
10
10
|
export { agentMessageMetadataSchema, agentMetadataSchema, agentMetadataValueSchema, cuid2Schema, type AgentMessageMetadata, type AgentMetadata, type AgentMetadataChange, type AgentMetadataValue, } from "./AgentMetadata.js";
|
|
11
|
+
export { type AgentMessageAcceptance } from "./AgentMessageAcceptance.js";
|
|
11
12
|
export { AgentStorage, type AgentStorageLock, type AgentStorageOptions } from "./AgentStorage.js";
|
|
13
|
+
export { agentDatabaseRows, agentDatabaseRun, isAgentSQLiteDatabase, type AgentDatabase, type AgentDatabaseFacade, type AgentModuleMigration, type AgentPostgresDatabase, type AgentSQLiteDatabase, type AgentStorageTransaction, } from "./AgentDatabase.js";
|
|
12
14
|
export { type AgentModel } from "./AgentModel.js";
|
|
13
15
|
export { knownModels, type Model } from "./models.js";
|
|
14
16
|
export { AgentBase, type AgentBaseAwaitOptions, type AgentBaseMessageOptions, type AgentBaseOptions, type AgentBaseQueueMode, } from "./AgentBase.js";
|
|
15
|
-
export { agentEffort, agentId, agentKV, agentModel, agentPermissionMode, agentProvider, agentRunKV, agentServiceTier, withAgentContext, withAgentKV, withAgentPermissionMode, withAgentRunKV, } from "./AgentContexts.js";
|
|
17
|
+
export { agentDatabase, agentEffort, agentId, agentKV, agentModel, agentPermissionMode, agentProvider, agentRunKV, agentServiceTier, withAgentContext, withAgentDatabase, withAgentKV, withAgentPermissionMode, withAgentRunKV, } from "./AgentContexts.js";
|
|
16
18
|
export { agentPermissionModeLabel, agentPermissionModeSchema, isAgentPermissionMode, DEFAULT_AGENT_PERMISSION_MODE, type AgentPermissionMode, } from "./AgentPermissionMode.js";
|
|
17
19
|
export { agentTaskContext, taskContextBeforeToolCall, withAgentTaskContext, } from "./AgentTaskContext.js";
|
|
20
|
+
export { inTx, type AgentTransactionWork } from "./inTx.js";
|
|
18
21
|
export { AgentKV } from "./AgentKV.js";
|
|
19
|
-
export { type AgentBaseAcceptedMessage, type AgentBaseHooks, type AgentBaseInference, type AgentBaseModelChange, type AgentBasePermissionModeChange, type AgentBasePersistedEvent, type AgentBaseToolCall, type AgentBaseToolCallDecision, type AgentBaseToolOutcome, type AgentBaseTurn, type AgentBaseTurnStart, type MaybePromise, } from "./AgentBaseHooks.js";
|
|
22
|
+
export { type AgentBaseAcceptedMessage, type AgentBaseHooks, type AgentBaseInference, type AgentBaseInferenceStart, type AgentBaseLoop, type AgentBaseModelChange, type AgentBasePermissionModeChange, type AgentBasePersistedEvent, type AgentBaseSettlement, type AgentBaseToolCall, type AgentBaseToolCallDecision, type AgentBaseToolOutcome, type AgentBaseTurn, type AgentBaseTurnStart, type MaybePromise, } from "./AgentBaseHooks.js";
|
|
20
23
|
export { type AgentPersistence, type AgentRecord } from "./AgentPersistence.js";
|
|
21
24
|
export { agentBasePendingStateOf, agentBaseStoreOwesWork, AGENT_BASE_PENDING_KEY, type AgentBasePendingStage, type AgentBasePendingState, } from "./AgentBasePending.js";
|
|
22
25
|
export { type AgentBaseState } from "./AgentBaseState.js";
|
|
23
|
-
export { type
|
|
24
|
-
export { type
|
|
26
|
+
export { type AgentModule, type AgentModuleAgent, type AgentModuleAgentLifecycle, type AgentModuleScope, type AgentModuleSystemScope, } from "./AgentModule.js";
|
|
27
|
+
export { type AgentModuleAction } from "./AgentModuleAction.js";
|
|
25
28
|
export { AgentProviders, type AgentProviderSelection, type AgentProviderSource, } from "./AgentProviders.js";
|
|
26
|
-
export { defineAgentTool, type AgentTool, type AgentToolAutoPermissionActionDescriber, type AgentToolAutoPermissionPredicate, type AnyAgentTool, } from "./AgentTool.js";
|
|
29
|
+
export { defineAgentTool, type AgentTool, type AgentToolCall, type AgentToolAutoPermissionActionDescriber, type AgentToolAutoPermissionPredicate, type AnyAgentTool, } from "./AgentTool.js";
|
|
27
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../sources/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,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zB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EACH,cAAc,EACd,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,GAC3B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACH,eAAe,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,sCAAsC,EAC3C,KAAK,gCAAgC,EACrC,KAAK,YAAY,GACpB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,25 +8,28 @@ export { AgentSystemRef } from "./AgentSystemRef.js";
|
|
|
8
8
|
export { AgentRef } from "./AgentRef.js";
|
|
9
9
|
export { agentSystem, withAgentSystem } from "./AgentSystemContext.js";
|
|
10
10
|
// Agent configuration: fixed environment/settings, mergeable metadata, and its context carrier.
|
|
11
|
-
export { agentConfig, agentConfigSchema,
|
|
11
|
+
export { agentConfig, agentConfigSchema, agentModuleConfig, agentMetadata, agentEnvironment, agentEnvironmentSchema, agentModuleConfigSchema, agentPlatformSchema, currentAgentEnvironment, withAgentConfig, } from "./AgentConfig.js";
|
|
12
12
|
export { agentMessageMetadataSchema, agentMetadataSchema, agentMetadataValueSchema, cuid2Schema, } from "./AgentMetadata.js";
|
|
13
|
+
export {} from "./AgentMessageAcceptance.js";
|
|
13
14
|
export { AgentStorage } from "./AgentStorage.js";
|
|
15
|
+
export { agentDatabaseRows, agentDatabaseRun, isAgentSQLiteDatabase, } from "./AgentDatabase.js";
|
|
14
16
|
// Provider/model routing and the curated model catalog.
|
|
15
17
|
export {} from "./AgentModel.js";
|
|
16
18
|
export { knownModels } from "./models.js";
|
|
17
19
|
// The run loop itself: its context carriers, key-value store, hook contracts, and persistence.
|
|
18
20
|
export { AgentBase, } from "./AgentBase.js";
|
|
19
|
-
export { agentEffort, agentId, agentKV, agentModel, agentPermissionMode, agentProvider, agentRunKV, agentServiceTier, withAgentContext, withAgentKV, withAgentPermissionMode, withAgentRunKV, } from "./AgentContexts.js";
|
|
21
|
+
export { agentDatabase, agentEffort, agentId, agentKV, agentModel, agentPermissionMode, agentProvider, agentRunKV, agentServiceTier, withAgentContext, withAgentDatabase, withAgentKV, withAgentPermissionMode, withAgentRunKV, } from "./AgentContexts.js";
|
|
20
22
|
export { agentPermissionModeLabel, agentPermissionModeSchema, isAgentPermissionMode, DEFAULT_AGENT_PERMISSION_MODE, } from "./AgentPermissionMode.js";
|
|
21
23
|
export { agentTaskContext, taskContextBeforeToolCall, withAgentTaskContext, } from "./AgentTaskContext.js";
|
|
24
|
+
export { inTx } from "./inTx.js";
|
|
22
25
|
export { AgentKV } from "./AgentKV.js";
|
|
23
26
|
export {} from "./AgentBaseHooks.js";
|
|
24
27
|
export {} from "./AgentPersistence.js";
|
|
25
28
|
export { agentBasePendingStateOf, agentBaseStoreOwesWork, AGENT_BASE_PENDING_KEY, } from "./AgentBasePending.js";
|
|
26
29
|
export {} from "./AgentBaseState.js";
|
|
27
|
-
//
|
|
28
|
-
export {} from "./
|
|
29
|
-
export {} from "./
|
|
30
|
+
// Modules: pluggable capabilities that compose into an agent's hooks, tools, and instructions.
|
|
31
|
+
export {} from "./AgentModule.js";
|
|
32
|
+
export {} from "./AgentModuleAction.js";
|
|
30
33
|
// Registry of provider sources agents resolve their selected models through.
|
|
31
34
|
export { AgentProviders, } from "./AgentProviders.js";
|
|
32
35
|
// Tool definitions.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../sources/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,8EAA8E;AAC9E,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAoB,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAqD,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAgC,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEvE,gGAAgG;AAChG,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../sources/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAE5E,8EAA8E;AAC9E,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAoB,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAqD,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAgC,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEvE,gGAAgG;AAChG,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,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B,CAAC;AAC1B,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AAEhE,6EAA6E;AAC7E,OAAO,EACH,cAAc,GAGjB,MAAM,qBAAqB,CAAC;AAE7B,oBAAoB;AACpB,OAAO,EACH,eAAe,GAMlB,MAAM,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slopus/happy-agent-base",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Durable runtime for Happy agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
28
28
|
"@sinclair/typebox": "^0.34.49",
|
|
29
|
-
"@slopus/happy-providers": "0.0.
|
|
30
|
-
"@steve.kite/stdlib": "0.0.
|
|
29
|
+
"@slopus/happy-providers": "0.0.8",
|
|
30
|
+
"@steve.kite/stdlib": "0.0.10",
|
|
31
|
+
"drizzle-orm": "^0.45.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/node": "^24.0.10",
|
package/dist/AgentFeature.d.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import type { ProviderModelCompatibilityType, SessionEvent, SessionReasoningEffort, SessionServiceTier, SessionSystemMessage, SessionToolCallBlock, SessionToolResultMessage } from "@slopus/happy-providers";
|
|
2
|
-
import type { Context } from "@steve.kite/stdlib";
|
|
3
|
-
import type { AgentBaseAcceptedMessage, AgentBaseInference, AgentBaseModelChange, AgentBasePermissionModeChange, AgentBasePersistedEvent, AgentBaseToolCall, AgentBaseToolCallDecision, AgentBaseToolOutcome, AgentBaseTurn, AgentBaseTurnStart, MaybePromise } from "./AgentBaseHooks.js";
|
|
4
|
-
import type { AgentFeatureAction } from "./AgentFeatureAction.js";
|
|
5
|
-
import type { AgentKV } from "./AgentKV.js";
|
|
6
|
-
import type { AgentMetadata, AgentMetadataChange } from "./AgentMetadata.js";
|
|
7
|
-
import type { AgentPermissionMode } from "./AgentPermissionMode.js";
|
|
8
|
-
import type { AgentSystemRef } from "./AgentSystemRef.js";
|
|
9
|
-
import type { AnyAgentTool } from "./AgentTool.js";
|
|
10
|
-
/**
|
|
11
|
-
* The agent a hook is serving, in full. One feature instance serves every agent in a collection,
|
|
12
|
-
* so this — rather than anything the feature was constructed with — is what tells it whose turn
|
|
13
|
-
* it is looking at, and what that agent is about to run on.
|
|
14
|
-
*/
|
|
15
|
-
export interface AgentFeatureAgent {
|
|
16
|
-
/** The generated or caller-supplied cuid2 identity, stable for the agent's whole life. */
|
|
17
|
-
readonly id: string;
|
|
18
|
-
/** The immutable descriptive metadata currently stored in this agent's configuration. */
|
|
19
|
-
readonly metadata: AgentMetadata | undefined;
|
|
20
|
-
/** The registry ID of the provider in force, which one agent may switch between. */
|
|
21
|
-
readonly provider: string;
|
|
22
|
-
/**
|
|
23
|
-
* What kind of provider that ID is registered as — `"claude"`, `"codex"`, and so on. It is
|
|
24
|
-
* the vendor shape a feature has to reason about when a provider ID alone says nothing, and
|
|
25
|
-
* is absent when the ID is not registered.
|
|
26
|
-
*/
|
|
27
|
-
readonly providerKind: ProviderModelCompatibilityType | undefined;
|
|
28
|
-
/** The model in force, absent when none was ever selected. */
|
|
29
|
-
readonly model: string | undefined;
|
|
30
|
-
/** The reasoning effort in force, absent when none was ever selected. */
|
|
31
|
-
readonly effort: SessionReasoningEffort | undefined;
|
|
32
|
-
/** The service tier in force, absent when none was ever selected. */
|
|
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;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* What every hook of a feature is handed alongside the context: which agent it is running for,
|
|
43
|
-
* and the three stores it may write to, each with its own lifetime.
|
|
44
|
-
*
|
|
45
|
-
* They are passed rather than read off the context because a feature's own dependencies are not
|
|
46
|
-
* ambient state to be looked up: a hook is given exactly what it is entitled to, and cannot be
|
|
47
|
-
* handed a context that quietly means a different agent.
|
|
48
|
-
*/
|
|
49
|
-
export interface AgentFeatureScope {
|
|
50
|
-
/** The agent this hook is running for, and the selection it is running on. */
|
|
51
|
-
readonly agent: AgentFeatureAgent;
|
|
52
|
-
/**
|
|
53
|
-
* The feature's durable store for this one agent, scoped to `feature.<name>`. It belongs to
|
|
54
|
-
* the agent's conversation: it outlives every run, and it is cleared when the identity is
|
|
55
|
-
* created again. Renaming a feature orphans everything it stored here.
|
|
56
|
-
*/
|
|
57
|
-
readonly kv: AgentKV;
|
|
58
|
-
/**
|
|
59
|
-
* The feature's durable store shared by every agent in the collection, and outliving all of
|
|
60
|
-
* them. Work one agent owes another lives here, since an agent's own store belongs to its
|
|
61
|
-
* conversation alone.
|
|
62
|
-
*/
|
|
63
|
-
readonly sharedKV: AgentKV;
|
|
64
|
-
/**
|
|
65
|
-
* The feature's store for the run in progress, erased in the transaction that settles the
|
|
66
|
-
* agent. It is where a feature keeps what only makes sense while the agent is working, so a
|
|
67
|
-
* crash mid-run leaves notes a resumed run can read, and a finished run leaves none at all.
|
|
68
|
-
*/
|
|
69
|
-
readonly runKV: AgentKV;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* One independent capability of an `Agent`: a feature implements any subset of the agent hooks,
|
|
73
|
-
* and the agent merges every feature's implementations into the singular hooks its internal
|
|
74
|
-
* `AgentBase` runs with. The hook contracts are the same as `AgentBaseHooks`; see there for
|
|
75
|
-
* when each hook fires and what its return value means.
|
|
76
|
-
*
|
|
77
|
-
* Agent-scoped hooks receive the agent's context first and their `AgentFeatureScope` second.
|
|
78
|
-
* System start hooks instead receive the system context and its deadlock-safe `AgentSystemRef`.
|
|
79
|
-
*/
|
|
80
|
-
export interface AgentFeature<Tool extends AnyAgentTool = AnyAgentTool> {
|
|
81
|
-
/**
|
|
82
|
-
* A stable identifier for the feature. Its persisted key-value entries live under this
|
|
83
|
-
* name, so renaming a feature orphans everything it stored.
|
|
84
|
-
*/
|
|
85
|
-
readonly name: string;
|
|
86
|
-
/**
|
|
87
|
-
* The first hook a feature receives. Called once after the owning AgentSystem acquires its
|
|
88
|
-
* store lock and before any agent is restored or started. Every feature initializes
|
|
89
|
-
* concurrently, and agent work begins only after all of them settle successfully.
|
|
90
|
-
*/
|
|
91
|
-
readonly beforeStart?: (ctx: Context, agents: AgentSystemRef) => MaybePromise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Called once after every durable-active agent has been restored and started. Every feature
|
|
94
|
-
* runs concurrently, and system creation resolves only after all of them settle successfully.
|
|
95
|
-
*/
|
|
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>;
|
|
99
|
-
/** Runs inside the transaction committing a completed assistant block. */
|
|
100
|
-
readonly onEventTransact?: (ctx: Context, scope: AgentFeatureScope, event: AgentBasePersistedEvent) => MaybePromise<void>;
|
|
101
|
-
/** Merged after the base state and every earlier feature's instructions, in feature order. */
|
|
102
|
-
readonly instructions?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<string>;
|
|
103
|
-
/** Merged after the base state and every earlier feature's tools, in feature order. */
|
|
104
|
-
readonly tools?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<readonly Tool[]>;
|
|
105
|
-
/**
|
|
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.
|
|
114
|
-
*/
|
|
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>;
|
|
123
|
-
/** The first feature that returns a handoff message wins the reset injection. */
|
|
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>;
|
|
140
|
-
/** Transactional counterpart to `beforeAgentLoop`. */
|
|
141
|
-
readonly beforeAgentLoopTransact?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
142
|
-
/** Called when the loop leaves the settled state and begins working. */
|
|
143
|
-
readonly beforeAgentLoop?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
144
|
-
/** Transactional counterpart to `beforeTurn`. */
|
|
145
|
-
readonly beforeTurnTransact?: (ctx: Context, scope: AgentFeatureScope, turn: AgentBaseTurnStart) => MaybePromise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* Receives the measured size of the context the turn is about to run on. Actions from every
|
|
148
|
-
* feature are concatenated and applied before the turn's first inference.
|
|
149
|
-
*/
|
|
150
|
-
readonly beforeTurn?: (ctx: Context, scope: AgentFeatureScope, turn: AgentBaseTurnStart) => MaybePromise<readonly AgentFeatureAction[] | undefined>;
|
|
151
|
-
/** Transactional counterpart to `beforeInference`. */
|
|
152
|
-
readonly beforeInferenceTransact?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
153
|
-
/** Called immediately before each inference request. */
|
|
154
|
-
readonly beforeInference?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
155
|
-
/** Transactional counterpart to `afterInference`. */
|
|
156
|
-
readonly afterInferenceTransact?: (ctx: Context, scope: AgentFeatureScope, inference: AgentBaseInference) => MaybePromise<void>;
|
|
157
|
-
/** Receives how the response ended and the token counts the provider measured for it. */
|
|
158
|
-
readonly afterInference?: (ctx: Context, scope: AgentFeatureScope, inference: AgentBaseInference) => MaybePromise<void>;
|
|
159
|
-
/** Transactional counterpart to `afterTurn`. */
|
|
160
|
-
readonly afterTurnTransact?: (ctx: Context, scope: AgentFeatureScope, turn: AgentBaseTurn) => MaybePromise<void>;
|
|
161
|
-
/**
|
|
162
|
-
* Receives the token counts the turn's last measured response reported. Actions from every
|
|
163
|
-
* feature are concatenated and applied together.
|
|
164
|
-
*/
|
|
165
|
-
readonly afterTurn?: (ctx: Context, scope: AgentFeatureScope, turn: AgentBaseTurn) => MaybePromise<readonly AgentFeatureAction[] | undefined>;
|
|
166
|
-
/** Transactional counterpart to `afterAgentLoop`. */
|
|
167
|
-
readonly afterAgentLoopTransact?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
168
|
-
/** Actions from every feature are concatenated and applied together. */
|
|
169
|
-
readonly afterAgentLoop?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<readonly AgentFeatureAction[] | undefined>;
|
|
170
|
-
/**
|
|
171
|
-
* Called inside the transaction that records the agent as settled. The feature's stores write
|
|
172
|
-
* into that transaction, so what a feature concludes about the run and the fact that the run
|
|
173
|
-
* is over become durable together. The `Transact` suffix is what marks a hook as running
|
|
174
|
-
* inside a transaction. The run store is erased by that same transaction, so this is the last
|
|
175
|
-
* chance to keep any part of what the run wrote about itself.
|
|
176
|
-
*
|
|
177
|
-
* Unlike the observing hooks, a failure here is not contained: it rolls the settlement back
|
|
178
|
-
* along with everything every feature wrote, and the agent stays recorded as working.
|
|
179
|
-
*/
|
|
180
|
-
readonly afterAgentSettledTransact?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
181
|
-
/** Called once after the loop has fully settled and no feature reopened it. */
|
|
182
|
-
readonly afterAgentSettled?: (ctx: Context, scope: AgentFeatureScope) => MaybePromise<void>;
|
|
183
|
-
}
|
|
184
|
-
//# sourceMappingURL=AgentFeature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,EACpB,oBAAoB,EACpB,wBAAwB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EACR,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,EAC7B,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,EACpB,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,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAC9B,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,yFAAyF;IACzF,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7C,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,8BA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ACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CACjB,GAAG,EAAE,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"}
|
package/dist/AgentFeature.js
DELETED
package/dist/AgentFeature.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgentFeature.js","sourceRoot":"","sources":["../sources/AgentFeature.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AgentFeatureAction.js","sourceRoot":"","sources":["../sources/AgentFeatureAction.ts"],"names":[],"mappings":""}
|