@standardagents/builder 0.39.1 → 0.40.0
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/dist/built-in-routes.js +494 -78
- package/dist/built-in-routes.js.map +1 -1
- package/dist/client/{ApiKeysView-AH5i-H6j.js → ApiKeysView-DoYvZZ7e.js} +1 -1
- package/dist/client/{CenteredContentView-DaBp0K-A.js → CenteredContentView-53PY0cqY.js} +1 -1
- package/dist/client/{CompositionView-yY1Q4M23.js → CompositionView-fp-0YnPt.js} +1 -1
- package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-Bwo5CJzF.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-Cvcagja2.js} +1 -1
- package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-D0WYwWyA.js → CopyButton.vue_vue_type_script_setup_true_lang-jYvO2v1K.js} +1 -1
- package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-1wwPn2aY.js → DataTable.vue_vue_type_script_setup_true_lang-DQ3Ufa7y.js} +1 -1
- package/dist/client/{JsonViewer-Bi8Zdmir.js → JsonViewer-6aaGzutE.js} +1 -1
- package/dist/client/{LoginView-BIKahEU6.js → LoginView-DwpCmNw9.js} +1 -1
- package/dist/client/{MarketplaceView-DPDPVH68.js → MarketplaceView-Da02L0J5.js} +1 -1
- package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-D1_rfOsy.js → Modal.vue_vue_type_script_setup_true_lang-Bi8OjiBf.js} +1 -1
- package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-DSLeOdxr.js → ModelModal.vue_vue_type_script_setup_true_lang-cYZLOYY7.js} +1 -1
- package/dist/client/{ModelsView-Q2WXu1Gw.js → ModelsView-BLlHO9Ud.js} +1 -1
- package/dist/client/{PromptEditView-BzA-3n1w.js → PromptEditView-EeNwTDtT.js} +1 -1
- package/dist/client/{PromptModal-CJWh_cru.js → PromptModal-BkwrKJ2d.js} +1 -1
- package/dist/client/{PromptsView-BezNl-Et.js → PromptsView-D1r7tsLu.js} +1 -1
- package/dist/client/{ProvidersView-BuzSKxuT.js → ProvidersView-CmUDl5nM.js} +1 -1
- package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DOxNp_3C.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-cRs3tApQ.js} +1 -1
- package/dist/client/{ThreadsView-DPCpZA4J.js → ThreadsView-Bl5fSIO1.js} +1 -1
- package/dist/client/{ToolsView-DMjFMAhH.js → ToolsView-DlVEF8-7.js} +1 -1
- package/dist/client/{UsersView-B7jXLNQs.js → UsersView-CGlA7a7R.js} +1 -1
- package/dist/client/{VariablesView-CF7x0G8g.js → VariablesView-BpYmJL4V.js} +1 -1
- package/dist/client/index-CKtIkI0N.js +6 -0
- package/dist/client/index.html +1 -1
- package/dist/{discovery-DiMJWisl.d.ts → discovery-DZ7fv-b4.d.ts} +3 -2
- package/dist/{index-yIcqf7DC.d.ts → index-9MaIifn3.d.ts} +7 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1242 -762
- package/dist/index.js.map +1 -1
- package/dist/packing.d.ts +5 -3
- package/dist/packing.js +180 -5
- package/dist/packing.js.map +1 -1
- package/dist/plugin.js +252 -17
- package/dist/plugin.js.map +1 -1
- package/dist/runtime.d.ts +10 -5
- package/dist/runtime.js +993 -750
- package/dist/runtime.js.map +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/{types-Bpe7IANZ.d.ts → types-BMnBYNwn.d.ts} +3 -1
- package/package.json +5 -5
- package/dist/client/index-eGECJFYe.js +0 -6
package/dist/runtime.js
CHANGED
|
@@ -6800,6 +6800,547 @@ var init_context = __esm({
|
|
|
6800
6800
|
}
|
|
6801
6801
|
});
|
|
6802
6802
|
|
|
6803
|
+
// src/packing/resolver.ts
|
|
6804
|
+
function parseQualifiedName(name) {
|
|
6805
|
+
if (name.startsWith("@")) {
|
|
6806
|
+
const firstSlash = name.indexOf("/");
|
|
6807
|
+
if (firstSlash === -1) {
|
|
6808
|
+
return [null, name];
|
|
6809
|
+
}
|
|
6810
|
+
const secondSlash = name.indexOf("/", firstSlash + 1);
|
|
6811
|
+
if (secondSlash === -1) {
|
|
6812
|
+
return [null, name];
|
|
6813
|
+
}
|
|
6814
|
+
return [name.substring(0, secondSlash), name.substring(secondSlash + 1)];
|
|
6815
|
+
}
|
|
6816
|
+
const separatorIndex = name.indexOf("/");
|
|
6817
|
+
if (separatorIndex === -1) {
|
|
6818
|
+
return [null, name];
|
|
6819
|
+
}
|
|
6820
|
+
return [name.substring(0, separatorIndex), name.substring(separatorIndex + 1)];
|
|
6821
|
+
}
|
|
6822
|
+
function qualifyName(packageId, shortName) {
|
|
6823
|
+
return `${packageId}/${shortName}`;
|
|
6824
|
+
}
|
|
6825
|
+
function getShortName(name) {
|
|
6826
|
+
const [, shortName] = parseQualifiedName(name);
|
|
6827
|
+
return shortName;
|
|
6828
|
+
}
|
|
6829
|
+
function resolveTool(registry, name, namespace) {
|
|
6830
|
+
const [pkgId, shortName] = parseQualifiedName(name);
|
|
6831
|
+
if (pkgId !== null) {
|
|
6832
|
+
const pkg = registry.packages[pkgId];
|
|
6833
|
+
if (!pkg) {
|
|
6834
|
+
throw new NamespaceResolutionError(
|
|
6835
|
+
"tool",
|
|
6836
|
+
name,
|
|
6837
|
+
namespace,
|
|
6838
|
+
`Package "${pkgId}" not found`
|
|
6839
|
+
);
|
|
6840
|
+
}
|
|
6841
|
+
throw new NamespaceResolutionError(
|
|
6842
|
+
"tool",
|
|
6843
|
+
name,
|
|
6844
|
+
namespace,
|
|
6845
|
+
`Cannot access tool "${shortName}" from package "${pkgId}". Only entry point agents are accessible cross-package.`
|
|
6846
|
+
);
|
|
6847
|
+
}
|
|
6848
|
+
if (namespace.type === "packed") {
|
|
6849
|
+
const pkg = registry.packages[namespace.packageId];
|
|
6850
|
+
if (!pkg) {
|
|
6851
|
+
throw new NamespaceResolutionError(
|
|
6852
|
+
"tool",
|
|
6853
|
+
name,
|
|
6854
|
+
namespace,
|
|
6855
|
+
`Package "${namespace.packageId}" not found`
|
|
6856
|
+
);
|
|
6857
|
+
}
|
|
6858
|
+
const loader2 = pkg.tools[shortName];
|
|
6859
|
+
if (!loader2) {
|
|
6860
|
+
throw new NamespaceResolutionError(
|
|
6861
|
+
"tool",
|
|
6862
|
+
name,
|
|
6863
|
+
namespace,
|
|
6864
|
+
`Tool "${shortName}" not found in package "${namespace.packageId}"`
|
|
6865
|
+
);
|
|
6866
|
+
}
|
|
6867
|
+
return loader2;
|
|
6868
|
+
}
|
|
6869
|
+
const loader = registry.global.tools[shortName];
|
|
6870
|
+
if (!loader) {
|
|
6871
|
+
throw new NamespaceResolutionError(
|
|
6872
|
+
"tool",
|
|
6873
|
+
name,
|
|
6874
|
+
namespace,
|
|
6875
|
+
`Tool "${shortName}" not found in global namespace`
|
|
6876
|
+
);
|
|
6877
|
+
}
|
|
6878
|
+
return loader;
|
|
6879
|
+
}
|
|
6880
|
+
function resolvePrompt(registry, name, namespace) {
|
|
6881
|
+
const [pkgId, shortName] = parseQualifiedName(name);
|
|
6882
|
+
if (pkgId !== null) {
|
|
6883
|
+
throw new NamespaceResolutionError(
|
|
6884
|
+
"prompt",
|
|
6885
|
+
name,
|
|
6886
|
+
namespace,
|
|
6887
|
+
`Cannot access prompt "${shortName}" from package "${pkgId}". Prompts are package-internal.`
|
|
6888
|
+
);
|
|
6889
|
+
}
|
|
6890
|
+
if (namespace.type === "packed") {
|
|
6891
|
+
const pkg = registry.packages[namespace.packageId];
|
|
6892
|
+
if (!pkg) {
|
|
6893
|
+
throw new NamespaceResolutionError(
|
|
6894
|
+
"prompt",
|
|
6895
|
+
name,
|
|
6896
|
+
namespace,
|
|
6897
|
+
`Package "${namespace.packageId}" not found`
|
|
6898
|
+
);
|
|
6899
|
+
}
|
|
6900
|
+
const loader2 = pkg.prompts[shortName];
|
|
6901
|
+
if (!loader2) {
|
|
6902
|
+
throw new NamespaceResolutionError(
|
|
6903
|
+
"prompt",
|
|
6904
|
+
name,
|
|
6905
|
+
namespace,
|
|
6906
|
+
`Prompt "${shortName}" not found in package "${namespace.packageId}"`
|
|
6907
|
+
);
|
|
6908
|
+
}
|
|
6909
|
+
return loader2;
|
|
6910
|
+
}
|
|
6911
|
+
const loader = registry.global.prompts[shortName];
|
|
6912
|
+
if (!loader) {
|
|
6913
|
+
throw new NamespaceResolutionError(
|
|
6914
|
+
"prompt",
|
|
6915
|
+
name,
|
|
6916
|
+
namespace,
|
|
6917
|
+
`Prompt "${shortName}" not found in global namespace`
|
|
6918
|
+
);
|
|
6919
|
+
}
|
|
6920
|
+
return loader;
|
|
6921
|
+
}
|
|
6922
|
+
function resolveModel(registry, name, namespace) {
|
|
6923
|
+
const [possiblePkgId, shortName] = parseQualifiedName(name);
|
|
6924
|
+
if (possiblePkgId !== null && registry.packages[possiblePkgId]) {
|
|
6925
|
+
throw new NamespaceResolutionError(
|
|
6926
|
+
"model",
|
|
6927
|
+
name,
|
|
6928
|
+
namespace,
|
|
6929
|
+
`Cannot use qualified model name "${name}". Models must be unqualified. If this is a provider model name, ensure no package named "${possiblePkgId}" exists.`
|
|
6930
|
+
);
|
|
6931
|
+
}
|
|
6932
|
+
const lookupName = name;
|
|
6933
|
+
if (namespace.type === "packed") {
|
|
6934
|
+
const pkg = registry.packages[namespace.packageId];
|
|
6935
|
+
if (pkg) {
|
|
6936
|
+
const loader2 = pkg.models[lookupName];
|
|
6937
|
+
if (loader2) {
|
|
6938
|
+
return loader2;
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6941
|
+
const globalLoader = registry.global.models[lookupName];
|
|
6942
|
+
if (globalLoader) {
|
|
6943
|
+
return globalLoader;
|
|
6944
|
+
}
|
|
6945
|
+
throw new NamespaceResolutionError(
|
|
6946
|
+
"model",
|
|
6947
|
+
name,
|
|
6948
|
+
namespace,
|
|
6949
|
+
`Model "${lookupName}" not found in package "${namespace.packageId}" or global namespace`
|
|
6950
|
+
);
|
|
6951
|
+
}
|
|
6952
|
+
const loader = registry.global.models[lookupName];
|
|
6953
|
+
if (!loader) {
|
|
6954
|
+
throw new NamespaceResolutionError(
|
|
6955
|
+
"model",
|
|
6956
|
+
name,
|
|
6957
|
+
namespace,
|
|
6958
|
+
`Model "${lookupName}" not found in global namespace`
|
|
6959
|
+
);
|
|
6960
|
+
}
|
|
6961
|
+
return loader;
|
|
6962
|
+
}
|
|
6963
|
+
function resolveAgent(registry, name, namespace) {
|
|
6964
|
+
const [pkgId, shortName] = parseQualifiedName(name);
|
|
6965
|
+
if (pkgId !== null) {
|
|
6966
|
+
const pkg = registry.packages[pkgId];
|
|
6967
|
+
if (!pkg) {
|
|
6968
|
+
throw new NamespaceResolutionError(
|
|
6969
|
+
"agent",
|
|
6970
|
+
name,
|
|
6971
|
+
namespace,
|
|
6972
|
+
`Package "${pkgId}" not found`
|
|
6973
|
+
);
|
|
6974
|
+
}
|
|
6975
|
+
if (!pkg.entryAgents.includes(shortName)) {
|
|
6976
|
+
throw new NamespaceResolutionError(
|
|
6977
|
+
"agent",
|
|
6978
|
+
name,
|
|
6979
|
+
namespace,
|
|
6980
|
+
`Agent "${shortName}" is not an entry point in package "${pkgId}"`
|
|
6981
|
+
);
|
|
6982
|
+
}
|
|
6983
|
+
const loader = pkg.agents[shortName];
|
|
6984
|
+
if (!loader) {
|
|
6985
|
+
throw new NamespaceResolutionError(
|
|
6986
|
+
"agent",
|
|
6987
|
+
name,
|
|
6988
|
+
namespace,
|
|
6989
|
+
`Agent "${shortName}" not found in package "${pkgId}"`
|
|
6990
|
+
);
|
|
6991
|
+
}
|
|
6992
|
+
return loader;
|
|
6993
|
+
}
|
|
6994
|
+
if (namespace.type === "packed") {
|
|
6995
|
+
const pkg = registry.packages[namespace.packageId];
|
|
6996
|
+
if (!pkg) {
|
|
6997
|
+
throw new NamespaceResolutionError(
|
|
6998
|
+
"agent",
|
|
6999
|
+
name,
|
|
7000
|
+
namespace,
|
|
7001
|
+
`Package "${namespace.packageId}" not found`
|
|
7002
|
+
);
|
|
7003
|
+
}
|
|
7004
|
+
const loader = pkg.agents[shortName];
|
|
7005
|
+
if (!loader) {
|
|
7006
|
+
throw new NamespaceResolutionError(
|
|
7007
|
+
"agent",
|
|
7008
|
+
name,
|
|
7009
|
+
namespace,
|
|
7010
|
+
`Agent "${shortName}" not found in package "${namespace.packageId}"`
|
|
7011
|
+
);
|
|
7012
|
+
}
|
|
7013
|
+
return loader;
|
|
7014
|
+
}
|
|
7015
|
+
const globalLoader = registry.global.agents[shortName];
|
|
7016
|
+
if (globalLoader) {
|
|
7017
|
+
return globalLoader;
|
|
7018
|
+
}
|
|
7019
|
+
for (const [pkgId2, pkg] of Object.entries(registry.packages)) {
|
|
7020
|
+
if (pkg.entryAgents.includes(shortName)) {
|
|
7021
|
+
const loader = pkg.agents[shortName];
|
|
7022
|
+
if (loader) {
|
|
7023
|
+
return loader;
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
}
|
|
7027
|
+
throw new NamespaceResolutionError(
|
|
7028
|
+
"agent",
|
|
7029
|
+
name,
|
|
7030
|
+
namespace,
|
|
7031
|
+
`Agent "${shortName}" not found in global namespace`
|
|
7032
|
+
);
|
|
7033
|
+
}
|
|
7034
|
+
function resolveHook(registry, name, namespace) {
|
|
7035
|
+
const [pkgId, shortName] = parseQualifiedName(name);
|
|
7036
|
+
if (pkgId !== null) {
|
|
7037
|
+
throw new NamespaceResolutionError(
|
|
7038
|
+
"hook",
|
|
7039
|
+
name,
|
|
7040
|
+
namespace,
|
|
7041
|
+
`Cannot use qualified hook name "${name}". Hooks must be unqualified.`
|
|
7042
|
+
);
|
|
7043
|
+
}
|
|
7044
|
+
if (namespace.type === "packed") {
|
|
7045
|
+
const pkg = registry.packages[namespace.packageId];
|
|
7046
|
+
if (pkg) {
|
|
7047
|
+
const loader2 = pkg.hooks[shortName];
|
|
7048
|
+
if (loader2) {
|
|
7049
|
+
return loader2;
|
|
7050
|
+
}
|
|
7051
|
+
}
|
|
7052
|
+
return null;
|
|
7053
|
+
}
|
|
7054
|
+
const loader = registry.global.hooks[shortName];
|
|
7055
|
+
return loader || null;
|
|
7056
|
+
}
|
|
7057
|
+
function getVisibleToolNames(registry, namespace) {
|
|
7058
|
+
if (namespace.type === "packed") {
|
|
7059
|
+
const pkg = registry.packages[namespace.packageId];
|
|
7060
|
+
return pkg ? Object.keys(pkg.tools) : [];
|
|
7061
|
+
}
|
|
7062
|
+
return Object.keys(registry.global.tools);
|
|
7063
|
+
}
|
|
7064
|
+
function getVisibleAgentNames(registry, namespace) {
|
|
7065
|
+
if (namespace.type === "packed") {
|
|
7066
|
+
const pkg = registry.packages[namespace.packageId];
|
|
7067
|
+
const ownAgents = pkg ? Object.keys(pkg.agents) : [];
|
|
7068
|
+
const otherEntryPoints = Object.entries(registry.packages).filter(([id]) => id !== namespace.packageId).flatMap(
|
|
7069
|
+
([pkgId, pkg2]) => pkg2.entryAgents.map((name) => qualifyName(pkgId, name))
|
|
7070
|
+
);
|
|
7071
|
+
return [...ownAgents, ...otherEntryPoints];
|
|
7072
|
+
}
|
|
7073
|
+
const globalAgents = Object.keys(registry.global.agents);
|
|
7074
|
+
const entryPoints = Object.values(registry.packages).flatMap((pkg) => pkg.entryAgents);
|
|
7075
|
+
return [.../* @__PURE__ */ new Set([...globalAgents, ...entryPoints])];
|
|
7076
|
+
}
|
|
7077
|
+
function getVisiblePromptNames(registry, namespace) {
|
|
7078
|
+
if (namespace.type === "packed") {
|
|
7079
|
+
const pkg = registry.packages[namespace.packageId];
|
|
7080
|
+
return pkg ? Object.keys(pkg.prompts) : [];
|
|
7081
|
+
}
|
|
7082
|
+
return Object.keys(registry.global.prompts);
|
|
7083
|
+
}
|
|
7084
|
+
function getVisibleModelNames(registry, namespace) {
|
|
7085
|
+
if (namespace.type === "packed") {
|
|
7086
|
+
const pkg = registry.packages[namespace.packageId];
|
|
7087
|
+
const ownModels = pkg ? Object.keys(pkg.models) : [];
|
|
7088
|
+
const globalModels = Object.keys(registry.global.models);
|
|
7089
|
+
return [.../* @__PURE__ */ new Set([...ownModels, ...globalModels])];
|
|
7090
|
+
}
|
|
7091
|
+
return Object.keys(registry.global.models);
|
|
7092
|
+
}
|
|
7093
|
+
function createNamespaceContext(agentDef) {
|
|
7094
|
+
if (agentDef?.__package) {
|
|
7095
|
+
return { type: "packed", packageId: agentDef.__package.packageId };
|
|
7096
|
+
}
|
|
7097
|
+
return { type: "global" };
|
|
7098
|
+
}
|
|
7099
|
+
function isQualifiedName(name) {
|
|
7100
|
+
if (name.startsWith("@")) {
|
|
7101
|
+
const firstSlash = name.indexOf("/");
|
|
7102
|
+
if (firstSlash === -1) return false;
|
|
7103
|
+
return name.indexOf("/", firstSlash + 1) !== -1;
|
|
7104
|
+
}
|
|
7105
|
+
return name.includes("/");
|
|
7106
|
+
}
|
|
7107
|
+
var NamespaceResolutionError;
|
|
7108
|
+
var init_resolver = __esm({
|
|
7109
|
+
"src/packing/resolver.ts"() {
|
|
7110
|
+
NamespaceResolutionError = class extends Error {
|
|
7111
|
+
constructor(itemType, itemName, namespace, message) {
|
|
7112
|
+
super(message);
|
|
7113
|
+
this.itemType = itemType;
|
|
7114
|
+
this.itemName = itemName;
|
|
7115
|
+
this.namespace = namespace;
|
|
7116
|
+
this.name = "NamespaceResolutionError";
|
|
7117
|
+
}
|
|
7118
|
+
};
|
|
7119
|
+
}
|
|
7120
|
+
});
|
|
7121
|
+
|
|
7122
|
+
// src/agents/ParentHookResolver.ts
|
|
7123
|
+
function packageOf(definition) {
|
|
7124
|
+
return definition?.__package ?? definition?._package;
|
|
7125
|
+
}
|
|
7126
|
+
function qualifyWithinPackage(name, packageId) {
|
|
7127
|
+
if (!packageId || parseQualifiedName(name)[0] !== null) {
|
|
7128
|
+
return name;
|
|
7129
|
+
}
|
|
7130
|
+
return qualifyName(packageId, name);
|
|
7131
|
+
}
|
|
7132
|
+
function promptHooks(prompt) {
|
|
7133
|
+
if (!prompt) return [];
|
|
7134
|
+
return Array.isArray(prompt.hooks) ? prompt.hooks : Array.isArray(prompt._hooks) ? prompt._hooks : [];
|
|
7135
|
+
}
|
|
7136
|
+
function promptTools(prompt) {
|
|
7137
|
+
if (!prompt) return [];
|
|
7138
|
+
return Array.isArray(prompt.tools) ? prompt.tools : Array.isArray(prompt._tools) ? prompt._tools : [];
|
|
7139
|
+
}
|
|
7140
|
+
function relationDescriptor(entry) {
|
|
7141
|
+
if (typeof entry === "string") {
|
|
7142
|
+
return {
|
|
7143
|
+
relationshipName: entry,
|
|
7144
|
+
implementingAgent: entry,
|
|
7145
|
+
explicitlyAgentShaped: false
|
|
7146
|
+
};
|
|
7147
|
+
}
|
|
7148
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
7149
|
+
return null;
|
|
7150
|
+
}
|
|
7151
|
+
const config = entry;
|
|
7152
|
+
if (typeof config.name !== "string" || !config.name) {
|
|
7153
|
+
return null;
|
|
7154
|
+
}
|
|
7155
|
+
const implementingAgent = typeof config.agent === "string" && config.agent ? config.agent : config.name;
|
|
7156
|
+
const explicitlyAgentShaped = "agent" in config || "blocking" in config || "resumable" in config || "immediate" in config || "parentCommunication" in config || "hidden" in config;
|
|
7157
|
+
return {
|
|
7158
|
+
relationshipName: config.name,
|
|
7159
|
+
implementingAgent,
|
|
7160
|
+
optional: typeof config.optional === "string" ? config.optional : void 0,
|
|
7161
|
+
explicitlyAgentShaped
|
|
7162
|
+
};
|
|
7163
|
+
}
|
|
7164
|
+
function hookLoader(host, owner, hookId) {
|
|
7165
|
+
const ownerPackage = packageOf(owner);
|
|
7166
|
+
if (!ownerPackage) {
|
|
7167
|
+
return host.hooks()[hookId];
|
|
7168
|
+
}
|
|
7169
|
+
return host.registry?.()?.packages?.[ownerPackage.packageId]?.hooks?.[hookId];
|
|
7170
|
+
}
|
|
7171
|
+
async function loadBinding(host, owner, hookId, hookType, context, required) {
|
|
7172
|
+
const loader = hookLoader(host, owner, hookId);
|
|
7173
|
+
if (!loader) {
|
|
7174
|
+
if (required) {
|
|
7175
|
+
throw new Error(
|
|
7176
|
+
`Required parent hook '${hookId}' was not found in the child agent namespace`
|
|
7177
|
+
);
|
|
7178
|
+
}
|
|
7179
|
+
return null;
|
|
7180
|
+
}
|
|
7181
|
+
let loaded;
|
|
7182
|
+
try {
|
|
7183
|
+
loaded = await loader();
|
|
7184
|
+
} catch (error) {
|
|
7185
|
+
if (required) throw error;
|
|
7186
|
+
console.error(`[Hooks] Failed to load hook '${hookId}':`, error);
|
|
7187
|
+
return null;
|
|
7188
|
+
}
|
|
7189
|
+
if (!loaded) {
|
|
7190
|
+
if (required) {
|
|
7191
|
+
throw new Error(`Required parent hook '${hookId}' did not export a hook definition`);
|
|
7192
|
+
}
|
|
7193
|
+
return null;
|
|
7194
|
+
}
|
|
7195
|
+
if (typeof loaded.id !== "string" || loaded.id !== hookId) {
|
|
7196
|
+
if (required) {
|
|
7197
|
+
throw new Error(`Required parent hook '${hookId}' exported a mismatched hook ID`);
|
|
7198
|
+
}
|
|
7199
|
+
return null;
|
|
7200
|
+
}
|
|
7201
|
+
if (typeof loaded.execute !== "function") {
|
|
7202
|
+
if (required) {
|
|
7203
|
+
throw new Error(`Required parent hook '${hookId}' did not export an execute function`);
|
|
7204
|
+
}
|
|
7205
|
+
return null;
|
|
7206
|
+
}
|
|
7207
|
+
if (USER_HOOK_NAMES.has(loaded.hook)) {
|
|
7208
|
+
if (required) {
|
|
7209
|
+
throw new Error(
|
|
7210
|
+
`Required parent hook '${hookId}' uses user-scoped hook type '${loaded.hook}'`
|
|
7211
|
+
);
|
|
7212
|
+
}
|
|
7213
|
+
return null;
|
|
7214
|
+
}
|
|
7215
|
+
if (!THREAD_HOOK_NAMES.has(loaded.hook)) {
|
|
7216
|
+
if (required) {
|
|
7217
|
+
throw new Error(`Required parent hook '${hookId}' exported invalid hook type '${loaded.hook}'`);
|
|
7218
|
+
}
|
|
7219
|
+
return null;
|
|
7220
|
+
}
|
|
7221
|
+
if (loaded.hook !== hookType) {
|
|
7222
|
+
return null;
|
|
7223
|
+
}
|
|
7224
|
+
return {
|
|
7225
|
+
id: hookId,
|
|
7226
|
+
hook: hookType,
|
|
7227
|
+
execute: loaded.execute,
|
|
7228
|
+
context
|
|
7229
|
+
};
|
|
7230
|
+
}
|
|
7231
|
+
async function resolveHooksForPrompt(input, hookType) {
|
|
7232
|
+
const agent = input.agent ?? await input.host.loadAgent(input.agentName);
|
|
7233
|
+
const agentPackage = packageOf(agent);
|
|
7234
|
+
const unqualifiedPromptName = input.promptName ?? agent.sideA?.prompt;
|
|
7235
|
+
const resolvedPromptName = unqualifiedPromptName ? qualifyWithinPackage(unqualifiedPromptName, agentPackage?.packageId) : void 0;
|
|
7236
|
+
const prompt = input.prompt ?? (resolvedPromptName ? await input.host.loadPrompt(resolvedPromptName) : void 0);
|
|
7237
|
+
const promptName = prompt?.name ?? prompt?.id ?? resolvedPromptName ?? "unknown_prompt";
|
|
7238
|
+
const before = [];
|
|
7239
|
+
const after = [];
|
|
7240
|
+
for (const entry of promptTools(prompt)) {
|
|
7241
|
+
const relation = relationDescriptor(entry);
|
|
7242
|
+
if (!relation) continue;
|
|
7243
|
+
if (relation.optional && input.isOptionalRelationshipEnabled && !await input.isOptionalRelationshipEnabled(relation.optional)) {
|
|
7244
|
+
continue;
|
|
7245
|
+
}
|
|
7246
|
+
const promptPackage = packageOf(prompt) ?? agentPackage;
|
|
7247
|
+
const childReference = qualifyWithinPackage(
|
|
7248
|
+
relation.implementingAgent,
|
|
7249
|
+
promptPackage?.packageId
|
|
7250
|
+
);
|
|
7251
|
+
let child;
|
|
7252
|
+
try {
|
|
7253
|
+
child = await input.host.loadAgent(childReference);
|
|
7254
|
+
} catch (error) {
|
|
7255
|
+
if (relation.explicitlyAgentShaped) throw error;
|
|
7256
|
+
continue;
|
|
7257
|
+
}
|
|
7258
|
+
if (child.type !== "dual_ai") continue;
|
|
7259
|
+
if (child.parentHooks !== void 0 && child.exposeAsTool !== true) {
|
|
7260
|
+
throw new Error(
|
|
7261
|
+
`Child agent '${childReference}' declares parentHooks but is not exposed as a tool`
|
|
7262
|
+
);
|
|
7263
|
+
}
|
|
7264
|
+
if (child.parentHooks !== void 0 && !Array.isArray(child.parentHooks)) {
|
|
7265
|
+
throw new Error(`Child agent '${childReference}' has an invalid parentHooks declaration`);
|
|
7266
|
+
}
|
|
7267
|
+
const requirements = child.parentHooks ?? [];
|
|
7268
|
+
const seenRequirements = /* @__PURE__ */ new Set();
|
|
7269
|
+
for (const requirement of requirements) {
|
|
7270
|
+
if (!requirement || typeof requirement !== "object" || typeof requirement.hook !== "string" || !requirement.hook || typeof requirement.reason !== "string" || !requirement.reason.trim() || requirement.stage !== void 0 && requirement.stage !== "before_parent" && requirement.stage !== "after_parent" || seenRequirements.has(requirement.hook)) {
|
|
7271
|
+
throw new Error(`Child agent '${childReference}' has an invalid parentHooks requirement`);
|
|
7272
|
+
}
|
|
7273
|
+
seenRequirements.add(requirement.hook);
|
|
7274
|
+
const loaded = await loadBinding(
|
|
7275
|
+
input.host,
|
|
7276
|
+
child,
|
|
7277
|
+
requirement.hook,
|
|
7278
|
+
hookType,
|
|
7279
|
+
{
|
|
7280
|
+
source: {
|
|
7281
|
+
kind: "child",
|
|
7282
|
+
relationshipName: relation.relationshipName,
|
|
7283
|
+
agentName: childReference,
|
|
7284
|
+
package: packageOf(child)
|
|
7285
|
+
}
|
|
7286
|
+
},
|
|
7287
|
+
true
|
|
7288
|
+
);
|
|
7289
|
+
if (!loaded) continue;
|
|
7290
|
+
if ((requirement.stage ?? "after_parent") === "before_parent") {
|
|
7291
|
+
before.push(loaded);
|
|
7292
|
+
} else {
|
|
7293
|
+
after.push(loaded);
|
|
7294
|
+
}
|
|
7295
|
+
}
|
|
7296
|
+
}
|
|
7297
|
+
const promptHookIds = promptHooks(prompt);
|
|
7298
|
+
const promptOwnsBaseHooks = promptHookIds.length > 0 && prompt !== void 0;
|
|
7299
|
+
const baseOwner = promptOwnsBaseHooks ? prompt : agent;
|
|
7300
|
+
const baseIds = promptHookIds.length > 0 ? promptHookIds : Array.isArray(agent.hooks) ? agent.hooks : [];
|
|
7301
|
+
const baseContext = promptOwnsBaseHooks ? { source: { kind: "prompt", promptName } } : { source: { kind: "agent", agentName: input.agentName } };
|
|
7302
|
+
const base = [];
|
|
7303
|
+
for (const hookId of baseIds) {
|
|
7304
|
+
const loaded = await loadBinding(
|
|
7305
|
+
input.host,
|
|
7306
|
+
baseOwner,
|
|
7307
|
+
hookId,
|
|
7308
|
+
hookType,
|
|
7309
|
+
baseContext,
|
|
7310
|
+
false
|
|
7311
|
+
);
|
|
7312
|
+
if (loaded) base.push(loaded);
|
|
7313
|
+
}
|
|
7314
|
+
return [...before, ...base, ...after];
|
|
7315
|
+
}
|
|
7316
|
+
var USER_HOOK_NAMES, THREAD_HOOK_NAMES;
|
|
7317
|
+
var init_ParentHookResolver = __esm({
|
|
7318
|
+
"src/agents/ParentHookResolver.ts"() {
|
|
7319
|
+
init_resolver();
|
|
7320
|
+
USER_HOOK_NAMES = /* @__PURE__ */ new Set([
|
|
7321
|
+
"user_client_attached",
|
|
7322
|
+
"user_client_detached",
|
|
7323
|
+
"user_value_changed"
|
|
7324
|
+
]);
|
|
7325
|
+
THREAD_HOOK_NAMES = /* @__PURE__ */ new Set([
|
|
7326
|
+
"after_thread_created",
|
|
7327
|
+
"after_subagent_created",
|
|
7328
|
+
"after_system_message",
|
|
7329
|
+
"filter_messages",
|
|
7330
|
+
"prefilter_llm_history",
|
|
7331
|
+
"before_create_message",
|
|
7332
|
+
"after_create_message",
|
|
7333
|
+
"before_update_message",
|
|
7334
|
+
"after_update_message",
|
|
7335
|
+
"before_store_tool_result",
|
|
7336
|
+
"after_tool_call_success",
|
|
7337
|
+
"after_tool_call_failure",
|
|
7338
|
+
"tool_call_started",
|
|
7339
|
+
"tool_call_done"
|
|
7340
|
+
]);
|
|
7341
|
+
}
|
|
7342
|
+
});
|
|
7343
|
+
|
|
6803
7344
|
// src/agents/FlowEngine.ts
|
|
6804
7345
|
var FlowEngine_exports = {};
|
|
6805
7346
|
__export(FlowEngine_exports, {
|
|
@@ -6816,6 +7357,7 @@ var init_FlowEngine = __esm({
|
|
|
6816
7357
|
init_context();
|
|
6817
7358
|
init_sessionTools();
|
|
6818
7359
|
init_ThreadStateImpl();
|
|
7360
|
+
init_ParentHookResolver();
|
|
6819
7361
|
IMMEDIATE_BOOTSTRAP_TOOL_NAME = "bootstrap_immediate_subagent";
|
|
6820
7362
|
HookBlockedExecutionError = class extends Error {
|
|
6821
7363
|
constructor(message) {
|
|
@@ -7158,7 +7700,8 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
7158
7700
|
_variables: def.variables ?? [],
|
|
7159
7701
|
_env: def.env ?? def.tenvs ?? {},
|
|
7160
7702
|
_requiredSchema: def.requiredSchema ?? null,
|
|
7161
|
-
_hooks: def.hooks ?? []
|
|
7703
|
+
_hooks: def.hooks ?? [],
|
|
7704
|
+
_package: def.__package
|
|
7162
7705
|
};
|
|
7163
7706
|
}
|
|
7164
7707
|
/**
|
|
@@ -7548,6 +8091,8 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
7548
8091
|
type: newAgentDef.type,
|
|
7549
8092
|
created_at: Date.now(),
|
|
7550
8093
|
max_session_turns: newAgentDef.maxSessionTurns ?? null,
|
|
8094
|
+
hooks: newAgentDef.hooks ?? [],
|
|
8095
|
+
_package: newAgentDef.__package,
|
|
7551
8096
|
side_a_label: newAgentDef.sideA?.label ?? null,
|
|
7552
8097
|
side_a_agent_prompt: newAgentDef.sideA?.prompt ?? null,
|
|
7553
8098
|
side_a_stop_on_response: newAgentDef.sideA?.stopOnResponse ?? true,
|
|
@@ -7708,7 +8253,7 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
7708
8253
|
return null;
|
|
7709
8254
|
}
|
|
7710
8255
|
return await stub.resolveThreadEnv({
|
|
7711
|
-
threadId: state.
|
|
8256
|
+
threadId: state.thread.metadata.id,
|
|
7712
8257
|
property,
|
|
7713
8258
|
promptName: state.prompt?.name
|
|
7714
8259
|
});
|
|
@@ -8230,8 +8775,8 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
8230
8775
|
state.context[key] = existing;
|
|
8231
8776
|
}
|
|
8232
8777
|
static async runImmediateToolsIfNeeded(state) {
|
|
8233
|
-
const
|
|
8234
|
-
if (
|
|
8778
|
+
const promptTools2 = Array.isArray(state.prompt._tools) ? state.prompt._tools : [];
|
|
8779
|
+
if (promptTools2.length === 0) {
|
|
8235
8780
|
return false;
|
|
8236
8781
|
}
|
|
8237
8782
|
if (!state.immediatePromptRuns) {
|
|
@@ -8267,7 +8812,7 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
8267
8812
|
(activeInstanceCounts.get(child.name) ?? 0) + 1
|
|
8268
8813
|
);
|
|
8269
8814
|
}
|
|
8270
|
-
for (const toolConfig of
|
|
8815
|
+
for (const toolConfig of promptTools2) {
|
|
8271
8816
|
if (!toolConfig || typeof toolConfig !== "object") {
|
|
8272
8817
|
continue;
|
|
8273
8818
|
}
|
|
@@ -8433,10 +8978,10 @@ This usually points to something I can't fix from here \u2014 for example the wo
|
|
|
8433
8978
|
* model's to clean up, and terminate_subagent on an infrastructure child
|
|
8434
8979
|
* kills work the runtime depends on. Static and pure for direct testing.
|
|
8435
8980
|
*/
|
|
8436
|
-
static filterModelVisibleSubagents(registry,
|
|
8981
|
+
static filterModelVisibleSubagents(registry, promptTools2) {
|
|
8437
8982
|
if (registry.length === 0) return registry;
|
|
8438
8983
|
const hidden = /* @__PURE__ */ new Set();
|
|
8439
|
-
for (const config of
|
|
8984
|
+
for (const config of promptTools2 ?? []) {
|
|
8440
8985
|
if (typeof config === "object" && config !== null && "name" in config && config.hidden === true) {
|
|
8441
8986
|
hidden.add(config.name);
|
|
8442
8987
|
}
|
|
@@ -9466,8 +10011,8 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9466
10011
|
try {
|
|
9467
10012
|
const nativeTools = await this.loadNativeTools(state);
|
|
9468
10013
|
tools.push(...nativeTools);
|
|
9469
|
-
const
|
|
9470
|
-
tools.push(...
|
|
10014
|
+
const promptTools2 = await this.loadPromptTools(state);
|
|
10015
|
+
tools.push(...promptTools2);
|
|
9471
10016
|
const agentTools = await this.loadAgentTools(state);
|
|
9472
10017
|
tools.push(...agentTools);
|
|
9473
10018
|
const toolNameSources = /* @__PURE__ */ new Map();
|
|
@@ -9476,7 +10021,7 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9476
10021
|
sources.add("native tool");
|
|
9477
10022
|
toolNameSources.set(tool.function.name, sources);
|
|
9478
10023
|
}
|
|
9479
|
-
for (const tool of
|
|
10024
|
+
for (const tool of promptTools2) {
|
|
9480
10025
|
const sources = toolNameSources.get(tool.function.name) || /* @__PURE__ */ new Set();
|
|
9481
10026
|
sources.add("prompt");
|
|
9482
10027
|
toolNameSources.set(tool.function.name, sources);
|
|
@@ -9612,30 +10157,14 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9612
10157
|
} catch (error) {
|
|
9613
10158
|
console.error("Error loading agent tools:", error);
|
|
9614
10159
|
}
|
|
9615
|
-
return tools;
|
|
9616
|
-
}
|
|
9617
|
-
// ==========================================================================
|
|
9618
|
-
// Hook Resolution Helpers
|
|
9619
|
-
// ==========================================================================
|
|
9620
|
-
/**
|
|
9621
|
-
* Get the list of hook IDs that should run for the current context.
|
|
9622
|
-
* Resolution: prompt hooks > agent hooks > empty array
|
|
9623
|
-
*
|
|
9624
|
-
* @param state - Flow state with prompt and agent configuration
|
|
9625
|
-
* @returns Array of hook IDs to execute
|
|
9626
|
-
*/
|
|
9627
|
-
static getActiveHookIds(state) {
|
|
9628
|
-
if (state.prompt?._hooks !== void 0 && state.prompt._hooks.length > 0) {
|
|
9629
|
-
return state.prompt._hooks;
|
|
9630
|
-
}
|
|
9631
|
-
if (state.agentConfig.hooks !== void 0 && state.agentConfig.hooks.length > 0) {
|
|
9632
|
-
return state.agentConfig.hooks;
|
|
9633
|
-
}
|
|
9634
|
-
return [];
|
|
10160
|
+
return tools;
|
|
9635
10161
|
}
|
|
10162
|
+
// ==========================================================================
|
|
10163
|
+
// Hook Resolution Helpers
|
|
10164
|
+
// ==========================================================================
|
|
9636
10165
|
/**
|
|
9637
|
-
*
|
|
9638
|
-
*
|
|
10166
|
+
* Resolve hooks of a specific type for the active prompt, including required
|
|
10167
|
+
* hooks contributed automatically by its enabled direct child agents.
|
|
9639
10168
|
*
|
|
9640
10169
|
* @template K - The hook type name (ensures type-safe executors)
|
|
9641
10170
|
* @param state - Flow state with hook configuration
|
|
@@ -9643,24 +10172,17 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9643
10172
|
* @returns Array of typed hook executor functions
|
|
9644
10173
|
*/
|
|
9645
10174
|
static async getHooksForType(state, hookType) {
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
executors.push(hookDef.execute);
|
|
9658
|
-
}
|
|
9659
|
-
} catch (error) {
|
|
9660
|
-
console.error(`[Hooks] Failed to load hook '${hookId}':`, error);
|
|
9661
|
-
}
|
|
9662
|
-
}
|
|
9663
|
-
return executors;
|
|
10175
|
+
return await resolveHooksForPrompt(
|
|
10176
|
+
{
|
|
10177
|
+
host: state.thread.instance,
|
|
10178
|
+
agentName: state.agentConfig.id,
|
|
10179
|
+
agent: state.agentConfig,
|
|
10180
|
+
promptName: state.prompt?.id,
|
|
10181
|
+
prompt: state.prompt,
|
|
10182
|
+
isOptionalRelationshipEnabled: (envName) => this.isOptionalToolEnabled(state, envName)
|
|
10183
|
+
},
|
|
10184
|
+
hookType
|
|
10185
|
+
);
|
|
9664
10186
|
}
|
|
9665
10187
|
// ==========================================================================
|
|
9666
10188
|
// Hook Runner Methods
|
|
@@ -9678,9 +10200,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9678
10200
|
if (executors.length === 0) return messages;
|
|
9679
10201
|
let result = messages;
|
|
9680
10202
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9681
|
-
for (const
|
|
10203
|
+
for (const { execute, context } of executors) {
|
|
9682
10204
|
try {
|
|
9683
|
-
result = await
|
|
10205
|
+
result = await execute(threadState, result, context);
|
|
9684
10206
|
} catch (error) {
|
|
9685
10207
|
if (error && typeof error === "object" && error.block === true) {
|
|
9686
10208
|
throw new HookBlockedExecutionError(error instanceof Error ? error.message : String(error));
|
|
@@ -9698,9 +10220,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9698
10220
|
if (executors.length === 0) return systemMessage;
|
|
9699
10221
|
let result = systemMessage;
|
|
9700
10222
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9701
|
-
for (const
|
|
10223
|
+
for (const { execute, context } of executors) {
|
|
9702
10224
|
try {
|
|
9703
|
-
const next = await
|
|
10225
|
+
const next = await execute(threadState, result, context);
|
|
9704
10226
|
if (next !== null && next !== void 0) {
|
|
9705
10227
|
result = next;
|
|
9706
10228
|
}
|
|
@@ -9717,9 +10239,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9717
10239
|
const executors = await this.getHooksForType(state, "after_subagent_created");
|
|
9718
10240
|
if (executors.length === 0) return;
|
|
9719
10241
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9720
|
-
for (const
|
|
10242
|
+
for (const { execute, context } of executors) {
|
|
9721
10243
|
try {
|
|
9722
|
-
await
|
|
10244
|
+
await execute(threadState, childState, context);
|
|
9723
10245
|
} catch (error) {
|
|
9724
10246
|
console.error("[Hooks] \u2717 Error running after_subagent_created hook:", error);
|
|
9725
10247
|
}
|
|
@@ -9738,9 +10260,13 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9738
10260
|
if (executors.length === 0) return message;
|
|
9739
10261
|
let result = message;
|
|
9740
10262
|
const threadState = threadStateOverride ?? ThreadStateImpl.fromFlowState(state);
|
|
9741
|
-
for (const
|
|
10263
|
+
for (const { execute, context } of executors) {
|
|
9742
10264
|
try {
|
|
9743
|
-
const hooked = await
|
|
10265
|
+
const hooked = await execute(
|
|
10266
|
+
threadState,
|
|
10267
|
+
_FlowEngine.rowToHookMessage(result),
|
|
10268
|
+
context
|
|
10269
|
+
);
|
|
9744
10270
|
result = {
|
|
9745
10271
|
...result,
|
|
9746
10272
|
...hooked,
|
|
@@ -9766,9 +10292,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9766
10292
|
const executors = await this.getHooksForType(state, "after_create_message");
|
|
9767
10293
|
if (executors.length === 0) return;
|
|
9768
10294
|
const threadState = threadStateOverride ?? ThreadStateImpl.fromFlowState(state);
|
|
9769
|
-
for (const
|
|
10295
|
+
for (const { execute, context } of executors) {
|
|
9770
10296
|
try {
|
|
9771
|
-
await
|
|
10297
|
+
await execute(threadState, _FlowEngine.rowToHookMessage(message), context);
|
|
9772
10298
|
} catch (error) {
|
|
9773
10299
|
console.error("[Hooks] \u2717 Error running after_create_message hook:", error);
|
|
9774
10300
|
}
|
|
@@ -9809,9 +10335,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9809
10335
|
if (executors.length === 0) return updates;
|
|
9810
10336
|
let result = updates;
|
|
9811
10337
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9812
|
-
for (const
|
|
10338
|
+
for (const { execute, context } of executors) {
|
|
9813
10339
|
try {
|
|
9814
|
-
result = await
|
|
10340
|
+
result = await execute(threadState, messageId, result, context);
|
|
9815
10341
|
} catch (error) {
|
|
9816
10342
|
console.error("[Hooks] \u2717 Error running before_update_message hook:", error);
|
|
9817
10343
|
}
|
|
@@ -9829,9 +10355,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9829
10355
|
const executors = await this.getHooksForType(state, "after_update_message");
|
|
9830
10356
|
if (executors.length === 0) return;
|
|
9831
10357
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9832
|
-
for (const
|
|
10358
|
+
for (const { execute, context } of executors) {
|
|
9833
10359
|
try {
|
|
9834
|
-
await
|
|
10360
|
+
await execute(threadState, _FlowEngine.rowToHookMessage(message), context);
|
|
9835
10361
|
} catch (error) {
|
|
9836
10362
|
console.error("[Hooks] \u2717 Error running after_update_message hook:", error);
|
|
9837
10363
|
}
|
|
@@ -9851,9 +10377,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9851
10377
|
if (executors.length === 0) return toolResult;
|
|
9852
10378
|
let result = toolResult;
|
|
9853
10379
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9854
|
-
for (const
|
|
10380
|
+
for (const { execute, context } of executors) {
|
|
9855
10381
|
try {
|
|
9856
|
-
result = await
|
|
10382
|
+
result = await execute(threadState, toolCall, result, context);
|
|
9857
10383
|
} catch (error) {
|
|
9858
10384
|
console.error("[Hooks] \u2717 Error running before_store_tool_result hook:", error);
|
|
9859
10385
|
}
|
|
@@ -9873,10 +10399,10 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9873
10399
|
if (executors.length === 0) return toolResult;
|
|
9874
10400
|
let result = toolResult;
|
|
9875
10401
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9876
|
-
for (const
|
|
10402
|
+
for (const { execute, context } of executors) {
|
|
9877
10403
|
if (result === null) break;
|
|
9878
10404
|
try {
|
|
9879
|
-
result = await
|
|
10405
|
+
result = await execute(threadState, toolCall, result, context);
|
|
9880
10406
|
} catch (error) {
|
|
9881
10407
|
console.error("[Hooks] \u2717 Error running after_tool_call_success hook:", error);
|
|
9882
10408
|
}
|
|
@@ -9896,10 +10422,10 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9896
10422
|
if (executors.length === 0) return toolResult;
|
|
9897
10423
|
let result = toolResult;
|
|
9898
10424
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9899
|
-
for (const
|
|
10425
|
+
for (const { execute, context } of executors) {
|
|
9900
10426
|
if (result === null) break;
|
|
9901
10427
|
try {
|
|
9902
|
-
result = await
|
|
10428
|
+
result = await execute(threadState, toolCall, result, context);
|
|
9903
10429
|
} catch (error) {
|
|
9904
10430
|
console.error("[Hooks] \u2717 Error running after_tool_call_failure hook:", error);
|
|
9905
10431
|
}
|
|
@@ -9929,9 +10455,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9929
10455
|
const executors = await this.getHooksForType(state, "tool_call_started");
|
|
9930
10456
|
if (executors.length === 0) return;
|
|
9931
10457
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9932
|
-
for (const
|
|
10458
|
+
for (const { execute, context } of executors) {
|
|
9933
10459
|
try {
|
|
9934
|
-
await
|
|
10460
|
+
await execute(threadState, toolCall, progress, context);
|
|
9935
10461
|
} catch (error) {
|
|
9936
10462
|
console.error("[Hooks] \u2717 Error running tool_call_started hook:", error);
|
|
9937
10463
|
}
|
|
@@ -9959,9 +10485,9 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
9959
10485
|
const executors = await this.getHooksForType(state, "tool_call_done");
|
|
9960
10486
|
if (executors.length === 0) return;
|
|
9961
10487
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
9962
|
-
for (const
|
|
10488
|
+
for (const { execute, context } of executors) {
|
|
9963
10489
|
try {
|
|
9964
|
-
await
|
|
10490
|
+
await execute(threadState, toolCall, toolResult, context);
|
|
9965
10491
|
} catch (error) {
|
|
9966
10492
|
console.error("[Hooks] \u2717 Error running tool_call_done hook:", error);
|
|
9967
10493
|
}
|
|
@@ -10914,12 +11440,12 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
|
|
|
10914
11440
|
if (executors.length === 0) return messages;
|
|
10915
11441
|
let result = messages;
|
|
10916
11442
|
const threadState = ThreadStateImpl.fromFlowState(state);
|
|
10917
|
-
for (const
|
|
11443
|
+
for (const { execute, context } of executors) {
|
|
10918
11444
|
try {
|
|
10919
11445
|
const byId = /* @__PURE__ */ new Map();
|
|
10920
11446
|
for (const row of result) if (row.id) byId.set(row.id, row);
|
|
10921
11447
|
const hookView = result.map((row) => _FlowEngine.rowToHookMessage(row));
|
|
10922
|
-
const kept = await
|
|
11448
|
+
const kept = await execute(threadState, hookView, context);
|
|
10923
11449
|
result = kept.map((hookedMessage) => {
|
|
10924
11450
|
const original = hookedMessage.id ? byId.get(hookedMessage.id) : void 0;
|
|
10925
11451
|
if (original) {
|
|
@@ -17699,702 +18225,389 @@ var migration48 = {
|
|
|
17699
18225
|
replica_updated_at INTEGER,
|
|
17700
18226
|
deleted_at INTEGER,
|
|
17701
18227
|
permissions TEXT
|
|
17702
|
-
)
|
|
17703
|
-
`);
|
|
17704
|
-
sql.exec(`
|
|
17705
|
-
INSERT INTO users (
|
|
17706
|
-
id, username, password_hash, role, created_at, updated_at,
|
|
17707
|
-
platform_user_id, email, display_name, avatar_url, instance_role,
|
|
17708
|
-
source, replica_active, replica_updated_at, deleted_at, permissions
|
|
17709
|
-
)
|
|
17710
|
-
SELECT
|
|
17711
|
-
id, username, password_hash, role, created_at, updated_at,
|
|
17712
|
-
platform_user_id, email, display_name, avatar_url, instance_role,
|
|
17713
|
-
source, replica_active, replica_updated_at, deleted_at, permissions
|
|
17714
|
-
FROM users_0012_old
|
|
17715
|
-
`);
|
|
17716
|
-
sql.exec(`DROP TABLE users_0012_old`);
|
|
17717
|
-
sql.exec(`CREATE INDEX idx_users_username ON users(username)`);
|
|
17718
|
-
sql.exec(`CREATE INDEX idx_users_role ON users(role)`);
|
|
17719
|
-
sql.exec(`CREATE INDEX idx_users_platform_user_id ON users(platform_user_id)`);
|
|
17720
|
-
sql.exec(`CREATE INDEX idx_users_replica_active ON users(replica_active)`);
|
|
17721
|
-
sql.exec(`CREATE INDEX idx_users_instance_role ON users(instance_role)`);
|
|
17722
|
-
sql.exec(`
|
|
17723
|
-
CREATE TABLE oauth_accounts (
|
|
17724
|
-
id TEXT PRIMARY KEY NOT NULL,
|
|
17725
|
-
user_id TEXT NOT NULL,
|
|
17726
|
-
provider TEXT NOT NULL CHECK (provider IN ('github', 'google')),
|
|
17727
|
-
provider_user_id TEXT NOT NULL,
|
|
17728
|
-
provider_username TEXT,
|
|
17729
|
-
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
17730
|
-
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
17731
|
-
)
|
|
17732
|
-
`);
|
|
17733
|
-
sql.exec(`INSERT INTO oauth_accounts SELECT * FROM oauth_accounts_0012_backup`);
|
|
17734
|
-
sql.exec(`CREATE UNIQUE INDEX idx_oauth_accounts_provider ON oauth_accounts(provider, provider_user_id)`);
|
|
17735
|
-
sql.exec(`CREATE INDEX idx_oauth_accounts_user_id ON oauth_accounts(user_id)`);
|
|
17736
|
-
sql.exec(`
|
|
17737
|
-
CREATE TABLE api_keys (
|
|
17738
|
-
id TEXT PRIMARY KEY NOT NULL,
|
|
17739
|
-
name TEXT NOT NULL,
|
|
17740
|
-
key_hash TEXT NOT NULL,
|
|
17741
|
-
key_prefix TEXT NOT NULL,
|
|
17742
|
-
last_five TEXT NOT NULL,
|
|
17743
|
-
user_id TEXT NOT NULL,
|
|
17744
|
-
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
17745
|
-
last_used_at INTEGER,
|
|
17746
|
-
platform_key_id TEXT,
|
|
17747
|
-
scope TEXT,
|
|
17748
|
-
source TEXT NOT NULL DEFAULT 'local' CHECK (source IN ('local', 'standard_agents')),
|
|
17749
|
-
replica_active INTEGER NOT NULL DEFAULT 1,
|
|
17750
|
-
replica_updated_at INTEGER,
|
|
17751
|
-
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
17752
|
-
)
|
|
17753
|
-
`);
|
|
17754
|
-
sql.exec(`INSERT INTO api_keys SELECT * FROM api_keys_0012_backup`);
|
|
17755
|
-
sql.exec(`CREATE INDEX idx_api_keys_key_hash ON api_keys(key_hash)`);
|
|
17756
|
-
sql.exec(`CREATE INDEX idx_api_keys_user_id ON api_keys(user_id)`);
|
|
17757
|
-
sql.exec(`CREATE INDEX idx_api_keys_key_prefix ON api_keys(key_prefix)`);
|
|
17758
|
-
sql.exec(`CREATE INDEX idx_api_keys_platform_key_id ON api_keys(platform_key_id)`);
|
|
17759
|
-
sql.exec(`CREATE INDEX idx_api_keys_replica_active ON api_keys(replica_active)`);
|
|
17760
|
-
sql.exec(`
|
|
17761
|
-
CREATE TABLE sessions (
|
|
17762
|
-
id TEXT PRIMARY KEY NOT NULL,
|
|
17763
|
-
user_id TEXT NOT NULL,
|
|
17764
|
-
token_hash TEXT NOT NULL,
|
|
17765
|
-
expires_at INTEGER NOT NULL,
|
|
17766
|
-
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
17767
|
-
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
17768
|
-
)
|
|
17769
|
-
`);
|
|
17770
|
-
sql.exec(`INSERT INTO sessions SELECT * FROM sessions_0012_backup`);
|
|
17771
|
-
sql.exec(`CREATE INDEX idx_sessions_token_hash ON sessions(token_hash)`);
|
|
17772
|
-
sql.exec(`CREATE INDEX idx_sessions_user_id ON sessions(user_id)`);
|
|
17773
|
-
sql.exec(`CREATE INDEX idx_sessions_expires_at ON sessions(expires_at)`);
|
|
17774
|
-
sql.exec(`DROP TABLE oauth_accounts_0012_backup`);
|
|
17775
|
-
sql.exec(`DROP TABLE api_keys_0012_backup`);
|
|
17776
|
-
sql.exec(`DROP TABLE sessions_0012_backup`);
|
|
17777
|
-
sql.exec(`
|
|
17778
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '12')
|
|
17779
|
-
`);
|
|
17780
|
-
}
|
|
17781
|
-
};
|
|
17782
|
-
|
|
17783
|
-
// src/durable-objects/agentbuilder-migrations/0013_add_thread_activity.ts
|
|
17784
|
-
var migration49 = {
|
|
17785
|
-
version: 13,
|
|
17786
|
-
async up(sql) {
|
|
17787
|
-
sql.exec(`ALTER TABLE threads ADD COLUMN last_activity_at INTEGER`);
|
|
17788
|
-
sql.exec(`ALTER TABLE threads ADD COLUMN executing_since INTEGER`);
|
|
17789
|
-
sql.exec(
|
|
17790
|
-
`CREATE INDEX IF NOT EXISTS idx_threads_last_activity_at ON threads(last_activity_at)`
|
|
17791
|
-
);
|
|
17792
|
-
sql.exec(`UPDATE threads SET last_activity_at = created_at`);
|
|
17793
|
-
sql.exec(`
|
|
17794
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '13')
|
|
17795
|
-
`);
|
|
17796
|
-
}
|
|
17797
|
-
};
|
|
17798
|
-
|
|
17799
|
-
// src/durable-objects/agentbuilder-migrations/0014_thread_activity_scale.ts
|
|
17800
|
-
var migration50 = {
|
|
17801
|
-
version: 14,
|
|
17802
|
-
async up(sql) {
|
|
17803
|
-
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_preview TEXT`);
|
|
17804
|
-
sql.exec(
|
|
17805
|
-
`CREATE INDEX IF NOT EXISTS idx_threads_executing_since
|
|
17806
|
-
ON threads(executing_since) WHERE executing_since IS NOT NULL`
|
|
17807
|
-
);
|
|
17808
|
-
sql.exec(
|
|
17809
|
-
`UPDATE threads SET last_activity_at = created_at WHERE last_activity_at IS NULL`
|
|
17810
|
-
);
|
|
17811
|
-
sql.exec(`
|
|
17812
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '14')
|
|
17813
|
-
`);
|
|
17814
|
-
}
|
|
17815
|
-
};
|
|
17816
|
-
|
|
17817
|
-
// src/durable-objects/agentbuilder-migrations/0015_clear_envelope_previews.ts
|
|
17818
|
-
var migration51 = {
|
|
17819
|
-
version: 15,
|
|
17820
|
-
async up(sql) {
|
|
17821
|
-
sql.exec(
|
|
17822
|
-
`UPDATE threads SET last_message_preview = NULL
|
|
17823
|
-
WHERE last_message_preview LIKE 'Subagent (reference: %'`
|
|
17824
|
-
);
|
|
17825
|
-
sql.exec(`
|
|
17826
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '15')
|
|
17827
|
-
`);
|
|
17828
|
-
}
|
|
17829
|
-
};
|
|
17830
|
-
|
|
17831
|
-
// src/durable-objects/agentbuilder-migrations/0016_add_origin_agent.ts
|
|
17832
|
-
var migration52 = {
|
|
17833
|
-
version: 16,
|
|
17834
|
-
async up(sql) {
|
|
17835
|
-
sql.exec(`ALTER TABLE threads ADD COLUMN origin_agent_name TEXT`);
|
|
17836
|
-
sql.exec(
|
|
17837
|
-
`CREATE INDEX IF NOT EXISTS idx_threads_origin_agent_name ON threads(origin_agent_name)`
|
|
17838
|
-
);
|
|
17839
|
-
sql.exec(`UPDATE threads SET origin_agent_name = agent_name`);
|
|
17840
|
-
sql.exec(`
|
|
17841
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '16')
|
|
17842
|
-
`);
|
|
17843
|
-
}
|
|
17844
|
-
};
|
|
17845
|
-
|
|
17846
|
-
// src/durable-objects/agentbuilder-migrations/0017_add_thread_message_recency.ts
|
|
17847
|
-
var migration53 = {
|
|
17848
|
-
version: 17,
|
|
17849
|
-
async up(sql) {
|
|
17850
|
-
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_at INTEGER`);
|
|
17851
|
-
sql.exec(`UPDATE threads SET last_message_at = created_at`);
|
|
17852
|
-
sql.exec(`
|
|
17853
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '17')
|
|
17854
|
-
`);
|
|
17855
|
-
}
|
|
17856
|
-
};
|
|
17857
|
-
|
|
17858
|
-
// src/durable-objects/agentbuilder-migrations/0018_auth_security.ts
|
|
17859
|
-
var migration54 = {
|
|
17860
|
-
version: 18,
|
|
17861
|
-
async up(sql) {
|
|
17862
|
-
sql.exec(`
|
|
17863
|
-
CREATE TABLE IF NOT EXISTS super_admin_sessions (
|
|
17864
|
-
token_hash TEXT PRIMARY KEY,
|
|
17865
|
-
created_at INTEGER NOT NULL,
|
|
17866
|
-
expires_at INTEGER NOT NULL
|
|
17867
|
-
)
|
|
17868
|
-
`);
|
|
17869
|
-
sql.exec(`
|
|
17870
|
-
CREATE INDEX IF NOT EXISTS idx_super_admin_sessions_expires
|
|
17871
|
-
ON super_admin_sessions(expires_at)
|
|
17872
|
-
`);
|
|
17873
|
-
sql.exec(`
|
|
17874
|
-
CREATE TABLE IF NOT EXISTS auth_rate_limits (
|
|
17875
|
-
bucket_key TEXT PRIMARY KEY,
|
|
17876
|
-
attempts INTEGER NOT NULL,
|
|
17877
|
-
reset_at INTEGER NOT NULL
|
|
17878
|
-
)
|
|
17879
|
-
`);
|
|
17880
|
-
sql.exec(`
|
|
17881
|
-
CREATE INDEX IF NOT EXISTS idx_auth_rate_limits_reset
|
|
17882
|
-
ON auth_rate_limits(reset_at)
|
|
17883
|
-
`);
|
|
17884
|
-
sql.exec(`
|
|
17885
|
-
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '18')
|
|
17886
|
-
`);
|
|
17887
|
-
}
|
|
17888
|
-
};
|
|
17889
|
-
|
|
17890
|
-
// src/durable-objects/agentbuilder-migrations/0019_scope_skills.ts
|
|
17891
|
-
var migration55 = {
|
|
17892
|
-
version: 19,
|
|
17893
|
-
async up(sql) {
|
|
17894
|
-
sql.exec(`
|
|
17895
|
-
CREATE TABLE skills_0019 (
|
|
17896
|
-
owner_id TEXT NOT NULL,
|
|
17897
|
-
name TEXT NOT NULL,
|
|
17898
|
-
description TEXT NOT NULL,
|
|
17899
|
-
version TEXT,
|
|
17900
|
-
enabled INTEGER NOT NULL DEFAULT 1,
|
|
17901
|
-
shared INTEGER NOT NULL DEFAULT 0,
|
|
17902
|
-
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
17903
|
-
updated_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
17904
|
-
PRIMARY KEY (owner_id, name)
|
|
17905
|
-
)
|
|
17906
|
-
`);
|
|
17907
|
-
sql.exec(`
|
|
17908
|
-
INSERT INTO skills_0019 (
|
|
17909
|
-
owner_id, name, description, version, enabled, shared, created_at, updated_at
|
|
17910
|
-
)
|
|
17911
|
-
SELECT '__instance_shared__', name, description, version, enabled, 1, created_at, updated_at
|
|
17912
|
-
FROM skills
|
|
17913
|
-
`);
|
|
17914
|
-
sql.exec(`
|
|
17915
|
-
CREATE TABLE skill_files_0019 (
|
|
17916
|
-
owner_id TEXT NOT NULL,
|
|
17917
|
-
skill_name TEXT NOT NULL,
|
|
17918
|
-
path TEXT NOT NULL,
|
|
17919
|
-
content TEXT NOT NULL,
|
|
17920
|
-
size INTEGER NOT NULL,
|
|
17921
|
-
PRIMARY KEY (owner_id, skill_name, path),
|
|
17922
|
-
FOREIGN KEY (owner_id, skill_name) REFERENCES skills_0019(owner_id, name) ON DELETE CASCADE
|
|
17923
|
-
)
|
|
17924
|
-
`);
|
|
17925
|
-
sql.exec(`
|
|
17926
|
-
INSERT INTO skill_files_0019 (owner_id, skill_name, path, content, size)
|
|
17927
|
-
SELECT '__instance_shared__', skill_name, path, content, size FROM skill_files
|
|
17928
|
-
`);
|
|
17929
|
-
sql.exec(`DROP TABLE skill_files`);
|
|
17930
|
-
sql.exec(`DROP TABLE skills`);
|
|
17931
|
-
sql.exec(`ALTER TABLE skills_0019 RENAME TO skills`);
|
|
17932
|
-
sql.exec(`ALTER TABLE skill_files_0019 RENAME TO skill_files`);
|
|
17933
|
-
sql.exec(`CREATE INDEX idx_skills_owner_enabled ON skills(owner_id, enabled)`);
|
|
17934
|
-
sql.exec(`CREATE INDEX idx_skills_shared_enabled ON skills(shared, enabled)`);
|
|
17935
|
-
sql.exec(`CREATE INDEX idx_skill_files_skill ON skill_files(owner_id, skill_name)`);
|
|
17936
|
-
sql.exec(`INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '19')`);
|
|
17937
|
-
}
|
|
17938
|
-
};
|
|
17939
|
-
|
|
17940
|
-
// src/durable-objects/agentbuilder-migrations/0020_websocket_tickets.ts
|
|
17941
|
-
var migration56 = {
|
|
17942
|
-
version: 20,
|
|
17943
|
-
async up(sql) {
|
|
18228
|
+
)
|
|
18229
|
+
`);
|
|
17944
18230
|
sql.exec(`
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
created_at INTEGER NOT NULL,
|
|
17950
|
-
expires_at INTEGER NOT NULL
|
|
18231
|
+
INSERT INTO users (
|
|
18232
|
+
id, username, password_hash, role, created_at, updated_at,
|
|
18233
|
+
platform_user_id, email, display_name, avatar_url, instance_role,
|
|
18234
|
+
source, replica_active, replica_updated_at, deleted_at, permissions
|
|
17951
18235
|
)
|
|
18236
|
+
SELECT
|
|
18237
|
+
id, username, password_hash, role, created_at, updated_at,
|
|
18238
|
+
platform_user_id, email, display_name, avatar_url, instance_role,
|
|
18239
|
+
source, replica_active, replica_updated_at, deleted_at, permissions
|
|
18240
|
+
FROM users_0012_old
|
|
17952
18241
|
`);
|
|
18242
|
+
sql.exec(`DROP TABLE users_0012_old`);
|
|
18243
|
+
sql.exec(`CREATE INDEX idx_users_username ON users(username)`);
|
|
18244
|
+
sql.exec(`CREATE INDEX idx_users_role ON users(role)`);
|
|
18245
|
+
sql.exec(`CREATE INDEX idx_users_platform_user_id ON users(platform_user_id)`);
|
|
18246
|
+
sql.exec(`CREATE INDEX idx_users_replica_active ON users(replica_active)`);
|
|
18247
|
+
sql.exec(`CREATE INDEX idx_users_instance_role ON users(instance_role)`);
|
|
17953
18248
|
sql.exec(`
|
|
17954
|
-
CREATE
|
|
17955
|
-
|
|
18249
|
+
CREATE TABLE oauth_accounts (
|
|
18250
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
18251
|
+
user_id TEXT NOT NULL,
|
|
18252
|
+
provider TEXT NOT NULL CHECK (provider IN ('github', 'google')),
|
|
18253
|
+
provider_user_id TEXT NOT NULL,
|
|
18254
|
+
provider_username TEXT,
|
|
18255
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
18256
|
+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
18257
|
+
)
|
|
17956
18258
|
`);
|
|
17957
|
-
sql.exec(`INSERT
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
// src/durable-objects/agentbuilder-migrations/0021_platform_handoff_jtis.ts
|
|
17962
|
-
var migration57 = {
|
|
17963
|
-
version: 21,
|
|
17964
|
-
async up(sql) {
|
|
18259
|
+
sql.exec(`INSERT INTO oauth_accounts SELECT * FROM oauth_accounts_0012_backup`);
|
|
18260
|
+
sql.exec(`CREATE UNIQUE INDEX idx_oauth_accounts_provider ON oauth_accounts(provider, provider_user_id)`);
|
|
18261
|
+
sql.exec(`CREATE INDEX idx_oauth_accounts_user_id ON oauth_accounts(user_id)`);
|
|
17965
18262
|
sql.exec(`
|
|
17966
|
-
CREATE TABLE
|
|
17967
|
-
|
|
17968
|
-
|
|
17969
|
-
|
|
18263
|
+
CREATE TABLE api_keys (
|
|
18264
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
18265
|
+
name TEXT NOT NULL,
|
|
18266
|
+
key_hash TEXT NOT NULL,
|
|
18267
|
+
key_prefix TEXT NOT NULL,
|
|
18268
|
+
last_five TEXT NOT NULL,
|
|
18269
|
+
user_id TEXT NOT NULL,
|
|
18270
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
18271
|
+
last_used_at INTEGER,
|
|
18272
|
+
platform_key_id TEXT,
|
|
18273
|
+
scope TEXT,
|
|
18274
|
+
source TEXT NOT NULL DEFAULT 'local' CHECK (source IN ('local', 'standard_agents')),
|
|
18275
|
+
replica_active INTEGER NOT NULL DEFAULT 1,
|
|
18276
|
+
replica_updated_at INTEGER,
|
|
18277
|
+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
17970
18278
|
)
|
|
17971
18279
|
`);
|
|
18280
|
+
sql.exec(`INSERT INTO api_keys SELECT * FROM api_keys_0012_backup`);
|
|
18281
|
+
sql.exec(`CREATE INDEX idx_api_keys_key_hash ON api_keys(key_hash)`);
|
|
18282
|
+
sql.exec(`CREATE INDEX idx_api_keys_user_id ON api_keys(user_id)`);
|
|
18283
|
+
sql.exec(`CREATE INDEX idx_api_keys_key_prefix ON api_keys(key_prefix)`);
|
|
18284
|
+
sql.exec(`CREATE INDEX idx_api_keys_platform_key_id ON api_keys(platform_key_id)`);
|
|
18285
|
+
sql.exec(`CREATE INDEX idx_api_keys_replica_active ON api_keys(replica_active)`);
|
|
17972
18286
|
sql.exec(`
|
|
17973
|
-
CREATE
|
|
17974
|
-
|
|
18287
|
+
CREATE TABLE sessions (
|
|
18288
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
18289
|
+
user_id TEXT NOT NULL,
|
|
18290
|
+
token_hash TEXT NOT NULL,
|
|
18291
|
+
expires_at INTEGER NOT NULL,
|
|
18292
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
18293
|
+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
18294
|
+
)
|
|
18295
|
+
`);
|
|
18296
|
+
sql.exec(`INSERT INTO sessions SELECT * FROM sessions_0012_backup`);
|
|
18297
|
+
sql.exec(`CREATE INDEX idx_sessions_token_hash ON sessions(token_hash)`);
|
|
18298
|
+
sql.exec(`CREATE INDEX idx_sessions_user_id ON sessions(user_id)`);
|
|
18299
|
+
sql.exec(`CREATE INDEX idx_sessions_expires_at ON sessions(expires_at)`);
|
|
18300
|
+
sql.exec(`DROP TABLE oauth_accounts_0012_backup`);
|
|
18301
|
+
sql.exec(`DROP TABLE api_keys_0012_backup`);
|
|
18302
|
+
sql.exec(`DROP TABLE sessions_0012_backup`);
|
|
18303
|
+
sql.exec(`
|
|
18304
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '12')
|
|
17975
18305
|
`);
|
|
17976
|
-
sql.exec(`INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '21')`);
|
|
17977
|
-
}
|
|
17978
|
-
};
|
|
17979
|
-
|
|
17980
|
-
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
17981
|
-
var migrations2 = [migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48, migration49, migration50, migration51, migration52, migration53, migration54, migration55, migration56, migration57];
|
|
17982
|
-
var LATEST_SCHEMA_VERSION2 = migrations2.reduce(
|
|
17983
|
-
(max, migration58) => Math.max(max, migration58.version),
|
|
17984
|
-
0
|
|
17985
|
-
);
|
|
17986
|
-
|
|
17987
|
-
// src/utils/crypto.ts
|
|
17988
|
-
var CryptoUtil = class {
|
|
17989
|
-
static algorithm = "aes-256-gcm";
|
|
17990
|
-
/**
|
|
17991
|
-
* Encrypt a string value
|
|
17992
|
-
*/
|
|
17993
|
-
static async encrypt(text, key) {
|
|
17994
|
-
const encoder = new TextEncoder();
|
|
17995
|
-
const data = encoder.encode(text);
|
|
17996
|
-
const cryptoKey = await crypto.subtle.importKey(
|
|
17997
|
-
"raw",
|
|
17998
|
-
hexToBuffer(key),
|
|
17999
|
-
{ name: "AES-GCM" },
|
|
18000
|
-
false,
|
|
18001
|
-
["encrypt"]
|
|
18002
|
-
);
|
|
18003
|
-
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
18004
|
-
const encrypted = await crypto.subtle.encrypt(
|
|
18005
|
-
{
|
|
18006
|
-
name: "AES-GCM",
|
|
18007
|
-
iv
|
|
18008
|
-
},
|
|
18009
|
-
cryptoKey,
|
|
18010
|
-
data
|
|
18011
|
-
);
|
|
18012
|
-
const combined = new Uint8Array(iv.length + encrypted.byteLength);
|
|
18013
|
-
combined.set(iv);
|
|
18014
|
-
combined.set(new Uint8Array(encrypted), iv.length);
|
|
18015
|
-
return bufferToBase64(combined);
|
|
18016
|
-
}
|
|
18017
|
-
/**
|
|
18018
|
-
* Decrypt a string value
|
|
18019
|
-
*/
|
|
18020
|
-
static async decrypt(encryptedText, key) {
|
|
18021
|
-
const combined = base64ToBuffer2(encryptedText);
|
|
18022
|
-
const iv = combined.slice(0, 12);
|
|
18023
|
-
const encrypted = combined.slice(12);
|
|
18024
|
-
const cryptoKey = await crypto.subtle.importKey(
|
|
18025
|
-
"raw",
|
|
18026
|
-
hexToBuffer(key),
|
|
18027
|
-
{ name: "AES-GCM" },
|
|
18028
|
-
false,
|
|
18029
|
-
["decrypt"]
|
|
18030
|
-
);
|
|
18031
|
-
const decrypted = await crypto.subtle.decrypt(
|
|
18032
|
-
{
|
|
18033
|
-
name: "AES-GCM",
|
|
18034
|
-
iv
|
|
18035
|
-
},
|
|
18036
|
-
cryptoKey,
|
|
18037
|
-
encrypted
|
|
18038
|
-
);
|
|
18039
|
-
const decoder = new TextDecoder();
|
|
18040
|
-
return decoder.decode(decrypted);
|
|
18041
|
-
}
|
|
18042
|
-
};
|
|
18043
|
-
function hexToBuffer(hex) {
|
|
18044
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
18045
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
18046
|
-
bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
|
|
18047
|
-
}
|
|
18048
|
-
return bytes;
|
|
18049
|
-
}
|
|
18050
|
-
function bufferToBase64(buffer) {
|
|
18051
|
-
let binary = "";
|
|
18052
|
-
for (let i = 0; i < buffer.byteLength; i++) {
|
|
18053
|
-
binary += String.fromCharCode(buffer[i]);
|
|
18054
|
-
}
|
|
18055
|
-
return btoa(binary);
|
|
18056
|
-
}
|
|
18057
|
-
function base64ToBuffer2(base64) {
|
|
18058
|
-
const binary = atob(base64);
|
|
18059
|
-
const bytes = new Uint8Array(binary.length);
|
|
18060
|
-
for (let i = 0; i < binary.length; i++) {
|
|
18061
|
-
bytes[i] = binary.charCodeAt(i);
|
|
18062
|
-
}
|
|
18063
|
-
return bytes;
|
|
18064
|
-
}
|
|
18065
|
-
async function encryptEnvs(env, encryptionKey) {
|
|
18066
|
-
const plaintext = JSON.stringify(env);
|
|
18067
|
-
return CryptoUtil.encrypt(plaintext, encryptionKey);
|
|
18068
|
-
}
|
|
18069
|
-
async function decryptEnvs(encrypted, encryptionKey) {
|
|
18070
|
-
const plaintext = await CryptoUtil.decrypt(encrypted, encryptionKey);
|
|
18071
|
-
const parsed = JSON.parse(plaintext);
|
|
18072
|
-
if (!parsed || typeof parsed !== "object") {
|
|
18073
|
-
return {};
|
|
18074
|
-
}
|
|
18075
|
-
const result = {};
|
|
18076
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
18077
|
-
if (value === void 0 || value === null) continue;
|
|
18078
|
-
result[key] = String(value);
|
|
18079
|
-
}
|
|
18080
|
-
return result;
|
|
18081
|
-
}
|
|
18082
|
-
|
|
18083
|
-
// src/packing/resolver.ts
|
|
18084
|
-
var NamespaceResolutionError = class extends Error {
|
|
18085
|
-
constructor(itemType, itemName, namespace, message) {
|
|
18086
|
-
super(message);
|
|
18087
|
-
this.itemType = itemType;
|
|
18088
|
-
this.itemName = itemName;
|
|
18089
|
-
this.namespace = namespace;
|
|
18090
|
-
this.name = "NamespaceResolutionError";
|
|
18091
|
-
}
|
|
18092
|
-
};
|
|
18093
|
-
function parseQualifiedName(name) {
|
|
18094
|
-
if (name.startsWith("@")) {
|
|
18095
|
-
const firstSlash = name.indexOf("/");
|
|
18096
|
-
if (firstSlash === -1) {
|
|
18097
|
-
return [null, name];
|
|
18098
|
-
}
|
|
18099
|
-
const secondSlash = name.indexOf("/", firstSlash + 1);
|
|
18100
|
-
if (secondSlash === -1) {
|
|
18101
|
-
return [null, name];
|
|
18102
|
-
}
|
|
18103
|
-
return [name.substring(0, secondSlash), name.substring(secondSlash + 1)];
|
|
18104
|
-
}
|
|
18105
|
-
const separatorIndex = name.indexOf("/");
|
|
18106
|
-
if (separatorIndex === -1) {
|
|
18107
|
-
return [null, name];
|
|
18108
|
-
}
|
|
18109
|
-
return [name.substring(0, separatorIndex), name.substring(separatorIndex + 1)];
|
|
18110
|
-
}
|
|
18111
|
-
function qualifyName(packageId, shortName) {
|
|
18112
|
-
return `${packageId}/${shortName}`;
|
|
18113
|
-
}
|
|
18114
|
-
function getShortName(name) {
|
|
18115
|
-
const [, shortName] = parseQualifiedName(name);
|
|
18116
|
-
return shortName;
|
|
18117
|
-
}
|
|
18118
|
-
function resolveTool(registry, name, namespace) {
|
|
18119
|
-
const [pkgId, shortName] = parseQualifiedName(name);
|
|
18120
|
-
if (pkgId !== null) {
|
|
18121
|
-
const pkg = registry.packages[pkgId];
|
|
18122
|
-
if (!pkg) {
|
|
18123
|
-
throw new NamespaceResolutionError(
|
|
18124
|
-
"tool",
|
|
18125
|
-
name,
|
|
18126
|
-
namespace,
|
|
18127
|
-
`Package "${pkgId}" not found`
|
|
18128
|
-
);
|
|
18129
|
-
}
|
|
18130
|
-
throw new NamespaceResolutionError(
|
|
18131
|
-
"tool",
|
|
18132
|
-
name,
|
|
18133
|
-
namespace,
|
|
18134
|
-
`Cannot access tool "${shortName}" from package "${pkgId}". Only entry point agents are accessible cross-package.`
|
|
18135
|
-
);
|
|
18136
|
-
}
|
|
18137
|
-
if (namespace.type === "packed") {
|
|
18138
|
-
const pkg = registry.packages[namespace.packageId];
|
|
18139
|
-
if (!pkg) {
|
|
18140
|
-
throw new NamespaceResolutionError(
|
|
18141
|
-
"tool",
|
|
18142
|
-
name,
|
|
18143
|
-
namespace,
|
|
18144
|
-
`Package "${namespace.packageId}" not found`
|
|
18145
|
-
);
|
|
18146
|
-
}
|
|
18147
|
-
const loader2 = pkg.tools[shortName];
|
|
18148
|
-
if (!loader2) {
|
|
18149
|
-
throw new NamespaceResolutionError(
|
|
18150
|
-
"tool",
|
|
18151
|
-
name,
|
|
18152
|
-
namespace,
|
|
18153
|
-
`Tool "${shortName}" not found in package "${namespace.packageId}"`
|
|
18154
|
-
);
|
|
18155
|
-
}
|
|
18156
|
-
return loader2;
|
|
18157
18306
|
}
|
|
18158
|
-
|
|
18159
|
-
|
|
18160
|
-
|
|
18161
|
-
|
|
18162
|
-
|
|
18163
|
-
|
|
18164
|
-
|
|
18307
|
+
};
|
|
18308
|
+
|
|
18309
|
+
// src/durable-objects/agentbuilder-migrations/0013_add_thread_activity.ts
|
|
18310
|
+
var migration49 = {
|
|
18311
|
+
version: 13,
|
|
18312
|
+
async up(sql) {
|
|
18313
|
+
sql.exec(`ALTER TABLE threads ADD COLUMN last_activity_at INTEGER`);
|
|
18314
|
+
sql.exec(`ALTER TABLE threads ADD COLUMN executing_since INTEGER`);
|
|
18315
|
+
sql.exec(
|
|
18316
|
+
`CREATE INDEX IF NOT EXISTS idx_threads_last_activity_at ON threads(last_activity_at)`
|
|
18165
18317
|
);
|
|
18318
|
+
sql.exec(`UPDATE threads SET last_activity_at = created_at`);
|
|
18319
|
+
sql.exec(`
|
|
18320
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '13')
|
|
18321
|
+
`);
|
|
18166
18322
|
}
|
|
18167
|
-
|
|
18168
|
-
|
|
18169
|
-
|
|
18170
|
-
|
|
18171
|
-
|
|
18172
|
-
|
|
18173
|
-
|
|
18174
|
-
|
|
18175
|
-
|
|
18176
|
-
|
|
18323
|
+
};
|
|
18324
|
+
|
|
18325
|
+
// src/durable-objects/agentbuilder-migrations/0014_thread_activity_scale.ts
|
|
18326
|
+
var migration50 = {
|
|
18327
|
+
version: 14,
|
|
18328
|
+
async up(sql) {
|
|
18329
|
+
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_preview TEXT`);
|
|
18330
|
+
sql.exec(
|
|
18331
|
+
`CREATE INDEX IF NOT EXISTS idx_threads_executing_since
|
|
18332
|
+
ON threads(executing_since) WHERE executing_since IS NOT NULL`
|
|
18177
18333
|
);
|
|
18178
|
-
|
|
18179
|
-
|
|
18180
|
-
const pkg = registry.packages[namespace.packageId];
|
|
18181
|
-
if (!pkg) {
|
|
18182
|
-
throw new NamespaceResolutionError(
|
|
18183
|
-
"prompt",
|
|
18184
|
-
name,
|
|
18185
|
-
namespace,
|
|
18186
|
-
`Package "${namespace.packageId}" not found`
|
|
18187
|
-
);
|
|
18188
|
-
}
|
|
18189
|
-
const loader2 = pkg.prompts[shortName];
|
|
18190
|
-
if (!loader2) {
|
|
18191
|
-
throw new NamespaceResolutionError(
|
|
18192
|
-
"prompt",
|
|
18193
|
-
name,
|
|
18194
|
-
namespace,
|
|
18195
|
-
`Prompt "${shortName}" not found in package "${namespace.packageId}"`
|
|
18196
|
-
);
|
|
18197
|
-
}
|
|
18198
|
-
return loader2;
|
|
18199
|
-
}
|
|
18200
|
-
const loader = registry.global.prompts[shortName];
|
|
18201
|
-
if (!loader) {
|
|
18202
|
-
throw new NamespaceResolutionError(
|
|
18203
|
-
"prompt",
|
|
18204
|
-
name,
|
|
18205
|
-
namespace,
|
|
18206
|
-
`Prompt "${shortName}" not found in global namespace`
|
|
18334
|
+
sql.exec(
|
|
18335
|
+
`UPDATE threads SET last_activity_at = created_at WHERE last_activity_at IS NULL`
|
|
18207
18336
|
);
|
|
18337
|
+
sql.exec(`
|
|
18338
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '14')
|
|
18339
|
+
`);
|
|
18208
18340
|
}
|
|
18209
|
-
|
|
18210
|
-
|
|
18211
|
-
|
|
18212
|
-
|
|
18213
|
-
|
|
18214
|
-
|
|
18215
|
-
|
|
18216
|
-
|
|
18217
|
-
|
|
18218
|
-
`Cannot use qualified model name "${name}". Models must be unqualified. If this is a provider model name, ensure no package named "${possiblePkgId}" exists.`
|
|
18341
|
+
};
|
|
18342
|
+
|
|
18343
|
+
// src/durable-objects/agentbuilder-migrations/0015_clear_envelope_previews.ts
|
|
18344
|
+
var migration51 = {
|
|
18345
|
+
version: 15,
|
|
18346
|
+
async up(sql) {
|
|
18347
|
+
sql.exec(
|
|
18348
|
+
`UPDATE threads SET last_message_preview = NULL
|
|
18349
|
+
WHERE last_message_preview LIKE 'Subagent (reference: %'`
|
|
18219
18350
|
);
|
|
18351
|
+
sql.exec(`
|
|
18352
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '15')
|
|
18353
|
+
`);
|
|
18220
18354
|
}
|
|
18221
|
-
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18225
|
-
|
|
18226
|
-
|
|
18227
|
-
|
|
18228
|
-
|
|
18229
|
-
|
|
18230
|
-
const globalLoader = registry.global.models[lookupName];
|
|
18231
|
-
if (globalLoader) {
|
|
18232
|
-
return globalLoader;
|
|
18233
|
-
}
|
|
18234
|
-
throw new NamespaceResolutionError(
|
|
18235
|
-
"model",
|
|
18236
|
-
name,
|
|
18237
|
-
namespace,
|
|
18238
|
-
`Model "${lookupName}" not found in package "${namespace.packageId}" or global namespace`
|
|
18355
|
+
};
|
|
18356
|
+
|
|
18357
|
+
// src/durable-objects/agentbuilder-migrations/0016_add_origin_agent.ts
|
|
18358
|
+
var migration52 = {
|
|
18359
|
+
version: 16,
|
|
18360
|
+
async up(sql) {
|
|
18361
|
+
sql.exec(`ALTER TABLE threads ADD COLUMN origin_agent_name TEXT`);
|
|
18362
|
+
sql.exec(
|
|
18363
|
+
`CREATE INDEX IF NOT EXISTS idx_threads_origin_agent_name ON threads(origin_agent_name)`
|
|
18239
18364
|
);
|
|
18365
|
+
sql.exec(`UPDATE threads SET origin_agent_name = agent_name`);
|
|
18366
|
+
sql.exec(`
|
|
18367
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '16')
|
|
18368
|
+
`);
|
|
18240
18369
|
}
|
|
18241
|
-
|
|
18242
|
-
|
|
18243
|
-
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18247
|
-
|
|
18248
|
-
);
|
|
18370
|
+
};
|
|
18371
|
+
|
|
18372
|
+
// src/durable-objects/agentbuilder-migrations/0017_add_thread_message_recency.ts
|
|
18373
|
+
var migration53 = {
|
|
18374
|
+
version: 17,
|
|
18375
|
+
async up(sql) {
|
|
18376
|
+
sql.exec(`ALTER TABLE threads ADD COLUMN last_message_at INTEGER`);
|
|
18377
|
+
sql.exec(`UPDATE threads SET last_message_at = created_at`);
|
|
18378
|
+
sql.exec(`
|
|
18379
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '17')
|
|
18380
|
+
`);
|
|
18249
18381
|
}
|
|
18250
|
-
|
|
18251
|
-
|
|
18252
|
-
|
|
18253
|
-
|
|
18254
|
-
|
|
18255
|
-
|
|
18256
|
-
|
|
18257
|
-
|
|
18258
|
-
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
)
|
|
18280
|
-
|
|
18281
|
-
return loader;
|
|
18382
|
+
};
|
|
18383
|
+
|
|
18384
|
+
// src/durable-objects/agentbuilder-migrations/0018_auth_security.ts
|
|
18385
|
+
var migration54 = {
|
|
18386
|
+
version: 18,
|
|
18387
|
+
async up(sql) {
|
|
18388
|
+
sql.exec(`
|
|
18389
|
+
CREATE TABLE IF NOT EXISTS super_admin_sessions (
|
|
18390
|
+
token_hash TEXT PRIMARY KEY,
|
|
18391
|
+
created_at INTEGER NOT NULL,
|
|
18392
|
+
expires_at INTEGER NOT NULL
|
|
18393
|
+
)
|
|
18394
|
+
`);
|
|
18395
|
+
sql.exec(`
|
|
18396
|
+
CREATE INDEX IF NOT EXISTS idx_super_admin_sessions_expires
|
|
18397
|
+
ON super_admin_sessions(expires_at)
|
|
18398
|
+
`);
|
|
18399
|
+
sql.exec(`
|
|
18400
|
+
CREATE TABLE IF NOT EXISTS auth_rate_limits (
|
|
18401
|
+
bucket_key TEXT PRIMARY KEY,
|
|
18402
|
+
attempts INTEGER NOT NULL,
|
|
18403
|
+
reset_at INTEGER NOT NULL
|
|
18404
|
+
)
|
|
18405
|
+
`);
|
|
18406
|
+
sql.exec(`
|
|
18407
|
+
CREATE INDEX IF NOT EXISTS idx_auth_rate_limits_reset
|
|
18408
|
+
ON auth_rate_limits(reset_at)
|
|
18409
|
+
`);
|
|
18410
|
+
sql.exec(`
|
|
18411
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '18')
|
|
18412
|
+
`);
|
|
18282
18413
|
}
|
|
18283
|
-
|
|
18284
|
-
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
|
|
18288
|
-
|
|
18289
|
-
|
|
18290
|
-
|
|
18291
|
-
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
|
|
18298
|
-
|
|
18299
|
-
|
|
18300
|
-
)
|
|
18301
|
-
|
|
18302
|
-
|
|
18414
|
+
};
|
|
18415
|
+
|
|
18416
|
+
// src/durable-objects/agentbuilder-migrations/0019_scope_skills.ts
|
|
18417
|
+
var migration55 = {
|
|
18418
|
+
version: 19,
|
|
18419
|
+
async up(sql) {
|
|
18420
|
+
sql.exec(`
|
|
18421
|
+
CREATE TABLE skills_0019 (
|
|
18422
|
+
owner_id TEXT NOT NULL,
|
|
18423
|
+
name TEXT NOT NULL,
|
|
18424
|
+
description TEXT NOT NULL,
|
|
18425
|
+
version TEXT,
|
|
18426
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
18427
|
+
shared INTEGER NOT NULL DEFAULT 0,
|
|
18428
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
18429
|
+
updated_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
18430
|
+
PRIMARY KEY (owner_id, name)
|
|
18431
|
+
)
|
|
18432
|
+
`);
|
|
18433
|
+
sql.exec(`
|
|
18434
|
+
INSERT INTO skills_0019 (
|
|
18435
|
+
owner_id, name, description, version, enabled, shared, created_at, updated_at
|
|
18436
|
+
)
|
|
18437
|
+
SELECT '__instance_shared__', name, description, version, enabled, 1, created_at, updated_at
|
|
18438
|
+
FROM skills
|
|
18439
|
+
`);
|
|
18440
|
+
sql.exec(`
|
|
18441
|
+
CREATE TABLE skill_files_0019 (
|
|
18442
|
+
owner_id TEXT NOT NULL,
|
|
18443
|
+
skill_name TEXT NOT NULL,
|
|
18444
|
+
path TEXT NOT NULL,
|
|
18445
|
+
content TEXT NOT NULL,
|
|
18446
|
+
size INTEGER NOT NULL,
|
|
18447
|
+
PRIMARY KEY (owner_id, skill_name, path),
|
|
18448
|
+
FOREIGN KEY (owner_id, skill_name) REFERENCES skills_0019(owner_id, name) ON DELETE CASCADE
|
|
18449
|
+
)
|
|
18450
|
+
`);
|
|
18451
|
+
sql.exec(`
|
|
18452
|
+
INSERT INTO skill_files_0019 (owner_id, skill_name, path, content, size)
|
|
18453
|
+
SELECT '__instance_shared__', skill_name, path, content, size FROM skill_files
|
|
18454
|
+
`);
|
|
18455
|
+
sql.exec(`DROP TABLE skill_files`);
|
|
18456
|
+
sql.exec(`DROP TABLE skills`);
|
|
18457
|
+
sql.exec(`ALTER TABLE skills_0019 RENAME TO skills`);
|
|
18458
|
+
sql.exec(`ALTER TABLE skill_files_0019 RENAME TO skill_files`);
|
|
18459
|
+
sql.exec(`CREATE INDEX idx_skills_owner_enabled ON skills(owner_id, enabled)`);
|
|
18460
|
+
sql.exec(`CREATE INDEX idx_skills_shared_enabled ON skills(shared, enabled)`);
|
|
18461
|
+
sql.exec(`CREATE INDEX idx_skill_files_skill ON skill_files(owner_id, skill_name)`);
|
|
18462
|
+
sql.exec(`INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '19')`);
|
|
18303
18463
|
}
|
|
18304
|
-
|
|
18305
|
-
|
|
18306
|
-
|
|
18464
|
+
};
|
|
18465
|
+
|
|
18466
|
+
// src/durable-objects/agentbuilder-migrations/0020_websocket_tickets.ts
|
|
18467
|
+
var migration56 = {
|
|
18468
|
+
version: 20,
|
|
18469
|
+
async up(sql) {
|
|
18470
|
+
sql.exec(`
|
|
18471
|
+
CREATE TABLE websocket_tickets (
|
|
18472
|
+
ticket_hash TEXT PRIMARY KEY,
|
|
18473
|
+
pathname TEXT NOT NULL,
|
|
18474
|
+
auth_json TEXT NOT NULL,
|
|
18475
|
+
created_at INTEGER NOT NULL,
|
|
18476
|
+
expires_at INTEGER NOT NULL
|
|
18477
|
+
)
|
|
18478
|
+
`);
|
|
18479
|
+
sql.exec(`
|
|
18480
|
+
CREATE INDEX idx_websocket_tickets_expires
|
|
18481
|
+
ON websocket_tickets(expires_at)
|
|
18482
|
+
`);
|
|
18483
|
+
sql.exec(`INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '20')`);
|
|
18307
18484
|
}
|
|
18308
|
-
|
|
18309
|
-
|
|
18310
|
-
|
|
18311
|
-
|
|
18312
|
-
|
|
18313
|
-
|
|
18314
|
-
|
|
18485
|
+
};
|
|
18486
|
+
|
|
18487
|
+
// src/durable-objects/agentbuilder-migrations/0021_platform_handoff_jtis.ts
|
|
18488
|
+
var migration57 = {
|
|
18489
|
+
version: 21,
|
|
18490
|
+
async up(sql) {
|
|
18491
|
+
sql.exec(`
|
|
18492
|
+
CREATE TABLE platform_handoff_jtis (
|
|
18493
|
+
jti TEXT PRIMARY KEY,
|
|
18494
|
+
consumed_at INTEGER NOT NULL,
|
|
18495
|
+
expires_at INTEGER NOT NULL
|
|
18496
|
+
)
|
|
18497
|
+
`);
|
|
18498
|
+
sql.exec(`
|
|
18499
|
+
CREATE INDEX idx_platform_handoff_jtis_expires
|
|
18500
|
+
ON platform_handoff_jtis(expires_at)
|
|
18501
|
+
`);
|
|
18502
|
+
sql.exec(`INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '21')`);
|
|
18315
18503
|
}
|
|
18316
|
-
|
|
18317
|
-
|
|
18318
|
-
|
|
18319
|
-
|
|
18320
|
-
|
|
18321
|
-
)
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18504
|
+
};
|
|
18505
|
+
|
|
18506
|
+
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
18507
|
+
var migrations2 = [migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46, migration47, migration48, migration49, migration50, migration51, migration52, migration53, migration54, migration55, migration56, migration57];
|
|
18508
|
+
var LATEST_SCHEMA_VERSION2 = migrations2.reduce(
|
|
18509
|
+
(max, migration58) => Math.max(max, migration58.version),
|
|
18510
|
+
0
|
|
18511
|
+
);
|
|
18512
|
+
|
|
18513
|
+
// src/utils/crypto.ts
|
|
18514
|
+
var CryptoUtil = class {
|
|
18515
|
+
static algorithm = "aes-256-gcm";
|
|
18516
|
+
/**
|
|
18517
|
+
* Encrypt a string value
|
|
18518
|
+
*/
|
|
18519
|
+
static async encrypt(text, key) {
|
|
18520
|
+
const encoder = new TextEncoder();
|
|
18521
|
+
const data = encoder.encode(text);
|
|
18522
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
18523
|
+
"raw",
|
|
18524
|
+
hexToBuffer(key),
|
|
18525
|
+
{ name: "AES-GCM" },
|
|
18526
|
+
false,
|
|
18527
|
+
["encrypt"]
|
|
18528
|
+
);
|
|
18529
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
18530
|
+
const encrypted = await crypto.subtle.encrypt(
|
|
18531
|
+
{
|
|
18532
|
+
name: "AES-GCM",
|
|
18533
|
+
iv
|
|
18534
|
+
},
|
|
18535
|
+
cryptoKey,
|
|
18536
|
+
data
|
|
18331
18537
|
);
|
|
18538
|
+
const combined = new Uint8Array(iv.length + encrypted.byteLength);
|
|
18539
|
+
combined.set(iv);
|
|
18540
|
+
combined.set(new Uint8Array(encrypted), iv.length);
|
|
18541
|
+
return bufferToBase64(combined);
|
|
18332
18542
|
}
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
|
|
18543
|
+
/**
|
|
18544
|
+
* Decrypt a string value
|
|
18545
|
+
*/
|
|
18546
|
+
static async decrypt(encryptedText, key) {
|
|
18547
|
+
const combined = base64ToBuffer2(encryptedText);
|
|
18548
|
+
const iv = combined.slice(0, 12);
|
|
18549
|
+
const encrypted = combined.slice(12);
|
|
18550
|
+
const cryptoKey = await crypto.subtle.importKey(
|
|
18551
|
+
"raw",
|
|
18552
|
+
hexToBuffer(key),
|
|
18553
|
+
{ name: "AES-GCM" },
|
|
18554
|
+
false,
|
|
18555
|
+
["decrypt"]
|
|
18556
|
+
);
|
|
18557
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
18558
|
+
{
|
|
18559
|
+
name: "AES-GCM",
|
|
18560
|
+
iv
|
|
18561
|
+
},
|
|
18562
|
+
cryptoKey,
|
|
18563
|
+
encrypted
|
|
18564
|
+
);
|
|
18565
|
+
const decoder = new TextDecoder();
|
|
18566
|
+
return decoder.decode(decrypted);
|
|
18342
18567
|
}
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
|
|
18346
|
-
|
|
18347
|
-
|
|
18348
|
-
const pkg = registry.packages[namespace.packageId];
|
|
18349
|
-
return pkg ? Object.keys(pkg.tools) : [];
|
|
18568
|
+
};
|
|
18569
|
+
function hexToBuffer(hex) {
|
|
18570
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
18571
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
18572
|
+
bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
|
|
18350
18573
|
}
|
|
18351
|
-
return
|
|
18574
|
+
return bytes;
|
|
18352
18575
|
}
|
|
18353
|
-
function
|
|
18354
|
-
|
|
18355
|
-
|
|
18356
|
-
|
|
18357
|
-
const otherEntryPoints = Object.entries(registry.packages).filter(([id]) => id !== namespace.packageId).flatMap(
|
|
18358
|
-
([pkgId, pkg2]) => pkg2.entryAgents.map((name) => qualifyName(pkgId, name))
|
|
18359
|
-
);
|
|
18360
|
-
return [...ownAgents, ...otherEntryPoints];
|
|
18576
|
+
function bufferToBase64(buffer) {
|
|
18577
|
+
let binary = "";
|
|
18578
|
+
for (let i = 0; i < buffer.byteLength; i++) {
|
|
18579
|
+
binary += String.fromCharCode(buffer[i]);
|
|
18361
18580
|
}
|
|
18362
|
-
|
|
18363
|
-
const entryPoints = Object.values(registry.packages).flatMap((pkg) => pkg.entryAgents);
|
|
18364
|
-
return [.../* @__PURE__ */ new Set([...globalAgents, ...entryPoints])];
|
|
18581
|
+
return btoa(binary);
|
|
18365
18582
|
}
|
|
18366
|
-
function
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18583
|
+
function base64ToBuffer2(base64) {
|
|
18584
|
+
const binary = atob(base64);
|
|
18585
|
+
const bytes = new Uint8Array(binary.length);
|
|
18586
|
+
for (let i = 0; i < binary.length; i++) {
|
|
18587
|
+
bytes[i] = binary.charCodeAt(i);
|
|
18370
18588
|
}
|
|
18371
|
-
return
|
|
18589
|
+
return bytes;
|
|
18372
18590
|
}
|
|
18373
|
-
function
|
|
18374
|
-
|
|
18375
|
-
|
|
18376
|
-
const ownModels = pkg ? Object.keys(pkg.models) : [];
|
|
18377
|
-
const globalModels = Object.keys(registry.global.models);
|
|
18378
|
-
return [.../* @__PURE__ */ new Set([...ownModels, ...globalModels])];
|
|
18379
|
-
}
|
|
18380
|
-
return Object.keys(registry.global.models);
|
|
18591
|
+
async function encryptEnvs(env, encryptionKey) {
|
|
18592
|
+
const plaintext = JSON.stringify(env);
|
|
18593
|
+
return CryptoUtil.encrypt(plaintext, encryptionKey);
|
|
18381
18594
|
}
|
|
18382
|
-
function
|
|
18383
|
-
|
|
18384
|
-
|
|
18595
|
+
async function decryptEnvs(encrypted, encryptionKey) {
|
|
18596
|
+
const plaintext = await CryptoUtil.decrypt(encrypted, encryptionKey);
|
|
18597
|
+
const parsed = JSON.parse(plaintext);
|
|
18598
|
+
if (!parsed || typeof parsed !== "object") {
|
|
18599
|
+
return {};
|
|
18385
18600
|
}
|
|
18386
|
-
|
|
18387
|
-
|
|
18388
|
-
|
|
18389
|
-
|
|
18390
|
-
const firstSlash = name.indexOf("/");
|
|
18391
|
-
if (firstSlash === -1) return false;
|
|
18392
|
-
return name.indexOf("/", firstSlash + 1) !== -1;
|
|
18601
|
+
const result = {};
|
|
18602
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
18603
|
+
if (value === void 0 || value === null) continue;
|
|
18604
|
+
result[key] = String(value);
|
|
18393
18605
|
}
|
|
18394
|
-
return
|
|
18606
|
+
return result;
|
|
18395
18607
|
}
|
|
18396
18608
|
|
|
18397
18609
|
// src/durable-objects/DurableAgentBuilder.ts
|
|
18610
|
+
init_resolver();
|
|
18398
18611
|
init_types();
|
|
18399
18612
|
|
|
18400
18613
|
// src/skills/frontmatter.ts
|
|
@@ -18486,6 +18699,7 @@ function validateSkillFiles(files) {
|
|
|
18486
18699
|
|
|
18487
18700
|
// src/durable-objects/DurableAgentBuilder.ts
|
|
18488
18701
|
init_scope();
|
|
18702
|
+
init_ParentHookResolver();
|
|
18489
18703
|
var ENV_TYPES_PROPERTY = "__agentbuilder_env_types";
|
|
18490
18704
|
function parseStoredPermissions(value) {
|
|
18491
18705
|
if (typeof value !== "string" || !value.trim()) return null;
|
|
@@ -19167,16 +19381,29 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
19167
19381
|
} catch {
|
|
19168
19382
|
return;
|
|
19169
19383
|
}
|
|
19170
|
-
const
|
|
19171
|
-
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19384
|
+
const packageId = agentDef?.__package?.packageId;
|
|
19385
|
+
const rawPromptName = agentDef?.sideA?.prompt;
|
|
19386
|
+
const promptName = rawPromptName && packageId && !isQualifiedName(rawPromptName) ? `${packageId}/${rawPromptName}` : rawPromptName;
|
|
19387
|
+
const promptDef = promptName ? await this.loadPrompt(promptName) : void 0;
|
|
19388
|
+
const bindings = await resolveHooksForPrompt(
|
|
19389
|
+
{
|
|
19390
|
+
host: this,
|
|
19391
|
+
agentName: thread.agent_name,
|
|
19392
|
+
agent: agentDef,
|
|
19393
|
+
promptName,
|
|
19394
|
+
prompt: promptDef,
|
|
19395
|
+
isOptionalRelationshipEnabled: async (envName) => {
|
|
19396
|
+
const value = await this.resolveThreadEnv({
|
|
19397
|
+
threadId: thread.id,
|
|
19398
|
+
property: envName,
|
|
19399
|
+
promptName: promptName ?? agentDef.name ?? thread.agent_name
|
|
19400
|
+
});
|
|
19401
|
+
return ["true", "1", "yes"].includes((value ?? "").trim().toLowerCase());
|
|
19402
|
+
}
|
|
19403
|
+
},
|
|
19404
|
+
"after_thread_created"
|
|
19405
|
+
);
|
|
19406
|
+
if (bindings.length === 0) return;
|
|
19180
19407
|
const durableId = this.env.AGENT_BUILDER_THREAD.idFromName(thread.id);
|
|
19181
19408
|
const threadStub = this.env.AGENT_BUILDER_THREAD.get(durableId);
|
|
19182
19409
|
const { ThreadStateImpl: ThreadStateImpl2 } = await Promise.resolve().then(() => (init_ThreadStateImpl(), ThreadStateImpl_exports));
|
|
@@ -19191,16 +19418,14 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
19191
19418
|
terminated: thread.terminated,
|
|
19192
19419
|
created_at: thread.created_at
|
|
19193
19420
|
});
|
|
19194
|
-
for (const
|
|
19195
|
-
const hookLoader = hooksRegistry[hookId];
|
|
19196
|
-
if (!hookLoader) continue;
|
|
19421
|
+
for (const binding of bindings) {
|
|
19197
19422
|
try {
|
|
19198
|
-
|
|
19199
|
-
if (hookDef?.hook === "after_thread_created") {
|
|
19200
|
-
await hookDef.execute(threadState);
|
|
19201
|
-
}
|
|
19423
|
+
await binding.execute(threadState, binding.context);
|
|
19202
19424
|
} catch (error) {
|
|
19203
|
-
console.error(
|
|
19425
|
+
console.error(
|
|
19426
|
+
`[Hooks] \u2717 Error running after_thread_created hook '${binding.id}':`,
|
|
19427
|
+
error
|
|
19428
|
+
);
|
|
19204
19429
|
}
|
|
19205
19430
|
}
|
|
19206
19431
|
}
|
|
@@ -20412,6 +20637,15 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
20412
20637
|
* Load a prompt definition by name.
|
|
20413
20638
|
*/
|
|
20414
20639
|
async loadPrompt(name) {
|
|
20640
|
+
if (isQualifiedName(name)) {
|
|
20641
|
+
const [packageId, promptName] = parseQualifiedName(name);
|
|
20642
|
+
const pkg = packageId ? this.registry()?.packages?.[packageId] : void 0;
|
|
20643
|
+
const loader2 = pkg?.prompts?.[promptName];
|
|
20644
|
+
if (!loader2) {
|
|
20645
|
+
throw new Error(`Prompt not found: ${name}`);
|
|
20646
|
+
}
|
|
20647
|
+
return await loader2();
|
|
20648
|
+
}
|
|
20415
20649
|
const registry = this.prompts();
|
|
20416
20650
|
const loader = registry[name];
|
|
20417
20651
|
if (!loader) {
|
|
@@ -21701,6 +21935,7 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
21701
21935
|
init_StreamManager();
|
|
21702
21936
|
init_LLMRequest();
|
|
21703
21937
|
init_ThreadStateImpl();
|
|
21938
|
+
init_resolver();
|
|
21704
21939
|
|
|
21705
21940
|
// src/durable-objects/logDetailStream.ts
|
|
21706
21941
|
var LOG_DETAIL_HEAVY_FIELDS = [
|
|
@@ -22374,6 +22609,7 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
22374
22609
|
type: agentDef.type,
|
|
22375
22610
|
created_at: Date.now(),
|
|
22376
22611
|
max_session_turns: agentDef.maxSessionTurns,
|
|
22612
|
+
_package: agentDef.__package,
|
|
22377
22613
|
side_a_label: agentDef.sideA?.label,
|
|
22378
22614
|
side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
|
|
22379
22615
|
side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
|
|
@@ -27608,6 +27844,8 @@ Its execution was lost (the executor restarted or hung) and automatic recovery w
|
|
|
27608
27844
|
type: agentDef.type,
|
|
27609
27845
|
created_at: Date.now(),
|
|
27610
27846
|
max_session_turns: agentDef.maxSessionTurns,
|
|
27847
|
+
hooks: agentDef.hooks ?? [],
|
|
27848
|
+
_package: agentDef.__package,
|
|
27611
27849
|
side_a_label: agentDef.sideA?.label,
|
|
27612
27850
|
side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
|
|
27613
27851
|
side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
|
|
@@ -27833,6 +28071,8 @@ Its execution was lost (the executor restarted or hung) and automatic recovery w
|
|
|
27833
28071
|
type: agentDef.type,
|
|
27834
28072
|
created_at: Date.now(),
|
|
27835
28073
|
max_session_turns: agentDef.maxSessionTurns,
|
|
28074
|
+
hooks: agentDef.hooks ?? [],
|
|
28075
|
+
_package: agentDef.__package,
|
|
27836
28076
|
side_a_label: agentDef.sideA?.label,
|
|
27837
28077
|
side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
|
|
27838
28078
|
side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
|
|
@@ -27989,6 +28229,8 @@ Its execution was lost (the executor restarted or hung) and automatic recovery w
|
|
|
27989
28229
|
type: agentDef.type,
|
|
27990
28230
|
created_at: Date.now(),
|
|
27991
28231
|
max_session_turns: agentDef.maxSessionTurns,
|
|
28232
|
+
hooks: agentDef.hooks ?? [],
|
|
28233
|
+
_package: agentDef.__package,
|
|
27992
28234
|
side_a_label: agentDef.sideA?.label,
|
|
27993
28235
|
side_a_agent_prompt: qualifyPromptName(agentDef.sideA?.prompt),
|
|
27994
28236
|
side_a_stop_on_response: agentDef.sideA?.stopOnResponse ?? true,
|
|
@@ -29945,6 +30187,7 @@ function enhanceFlowState(flow) {
|
|
|
29945
30187
|
init_context();
|
|
29946
30188
|
init_ProviderRegistry();
|
|
29947
30189
|
init_types2();
|
|
30190
|
+
init_resolver();
|
|
29948
30191
|
|
|
29949
30192
|
export { CLIENT_STREAM_CHUNK_BYTES, CodeExecutionBridge, DurableAgentBuilder, DurableThread, DurableUserHub, FlowStateSdk, NamespaceResolutionError, ProviderRegistry, ThreadWatchdog, applyRuntimeCors, authenticate, buildImageDescription, callClient, callClientStream, canAccessThread, cat, createNamespaceContext, createThreadEndpointHandler, decodeStreamChunk, defineController2 as defineController, emitThreadEvent, encodeStreamChunk, endpointCallerFromAuth, enhanceFlowState, exists, find, forceTurn, generateImageDescription, getFileStats, getMessages, getMessagesToSummarize, getShortName, getThumbnail, getUnsummarizedImageAttachments, getVisibleAgentNames, getVisibleModelNames, getVisiblePromptNames, getVisibleToolNames, grep, hasImageAttachments, head, injectMessage, isAdminOnlyApiRoute, isHostedInstance, isPublicApiRoute, isQualifiedName, isSameOriginBrowserRequest, isTrustedLocalDevelopmentRequest, linkFile, mkdir, move, optimizeImageContext, parseQualifiedName, qualifyName, queueTool, readFile, readdir, reloadHistory, rename, replaceImagesWithDescriptions, requireAdmin, requireAuth, resolveAgent, resolveHook, resolveModel, resolvePrompt, resolveTool, rmdir, runtimeCorsHeaders, runtimePreflightResponse, stat, supportsClientForwarding, tail, unlink, updateThread, writeFile, writeImage };
|
|
29950
30193
|
//# sourceMappingURL=runtime.js.map
|