@standardagents/builder 0.27.1 → 0.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/built-in-routes.js +1 -1
- package/dist/index.js +119 -9
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +119 -9
- package/dist/runtime.js.map +1 -1
- package/package.json +5 -5
package/dist/runtime.js
CHANGED
|
@@ -17272,9 +17272,9 @@ var DurableThread = class _DurableThread extends DurableObject {
|
|
|
17272
17272
|
* Each migration is run in order, starting from the current version + 1.
|
|
17273
17273
|
*/
|
|
17274
17274
|
async runMigrations(fromVersion) {
|
|
17275
|
-
for (const
|
|
17276
|
-
if (
|
|
17277
|
-
await
|
|
17275
|
+
for (const migration47 of migrations) {
|
|
17276
|
+
if (migration47.version > fromVersion) {
|
|
17277
|
+
await migration47.up(this.ctx.storage.sql);
|
|
17278
17278
|
}
|
|
17279
17279
|
}
|
|
17280
17280
|
}
|
|
@@ -21976,9 +21976,119 @@ var migration45 = {
|
|
|
21976
21976
|
}
|
|
21977
21977
|
};
|
|
21978
21978
|
|
|
21979
|
+
// src/durable-objects/agentbuilder-migrations/0012_allow_api_instance_role.ts
|
|
21980
|
+
var migration46 = {
|
|
21981
|
+
version: 12,
|
|
21982
|
+
async up(sql) {
|
|
21983
|
+
sql.exec(`CREATE TABLE oauth_accounts_0012_backup AS SELECT * FROM oauth_accounts`);
|
|
21984
|
+
sql.exec(`CREATE TABLE api_keys_0012_backup AS SELECT * FROM api_keys`);
|
|
21985
|
+
sql.exec(`CREATE TABLE sessions_0012_backup AS SELECT * FROM sessions`);
|
|
21986
|
+
sql.exec(`DROP TABLE oauth_accounts`);
|
|
21987
|
+
sql.exec(`DROP TABLE api_keys`);
|
|
21988
|
+
sql.exec(`DROP TABLE sessions`);
|
|
21989
|
+
sql.exec(`ALTER TABLE users RENAME TO users_0012_old`);
|
|
21990
|
+
sql.exec(`
|
|
21991
|
+
CREATE TABLE users (
|
|
21992
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
21993
|
+
username TEXT UNIQUE NOT NULL,
|
|
21994
|
+
password_hash TEXT NOT NULL,
|
|
21995
|
+
role TEXT NOT NULL DEFAULT 'admin' CHECK (role IN ('admin')),
|
|
21996
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
21997
|
+
updated_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
21998
|
+
platform_user_id TEXT,
|
|
21999
|
+
email TEXT,
|
|
22000
|
+
display_name TEXT,
|
|
22001
|
+
avatar_url TEXT,
|
|
22002
|
+
instance_role TEXT NOT NULL DEFAULT 'admin' CHECK (instance_role IN ('admin', 'user', 'api')),
|
|
22003
|
+
source TEXT NOT NULL DEFAULT 'local' CHECK (source IN ('local', 'standard_agents')),
|
|
22004
|
+
replica_active INTEGER NOT NULL DEFAULT 1,
|
|
22005
|
+
replica_updated_at INTEGER,
|
|
22006
|
+
deleted_at INTEGER,
|
|
22007
|
+
permissions TEXT
|
|
22008
|
+
)
|
|
22009
|
+
`);
|
|
22010
|
+
sql.exec(`
|
|
22011
|
+
INSERT INTO users (
|
|
22012
|
+
id, username, password_hash, role, created_at, updated_at,
|
|
22013
|
+
platform_user_id, email, display_name, avatar_url, instance_role,
|
|
22014
|
+
source, replica_active, replica_updated_at, deleted_at, permissions
|
|
22015
|
+
)
|
|
22016
|
+
SELECT
|
|
22017
|
+
id, username, password_hash, role, created_at, updated_at,
|
|
22018
|
+
platform_user_id, email, display_name, avatar_url, instance_role,
|
|
22019
|
+
source, replica_active, replica_updated_at, deleted_at, permissions
|
|
22020
|
+
FROM users_0012_old
|
|
22021
|
+
`);
|
|
22022
|
+
sql.exec(`DROP TABLE users_0012_old`);
|
|
22023
|
+
sql.exec(`CREATE INDEX idx_users_username ON users(username)`);
|
|
22024
|
+
sql.exec(`CREATE INDEX idx_users_role ON users(role)`);
|
|
22025
|
+
sql.exec(`CREATE INDEX idx_users_platform_user_id ON users(platform_user_id)`);
|
|
22026
|
+
sql.exec(`CREATE INDEX idx_users_replica_active ON users(replica_active)`);
|
|
22027
|
+
sql.exec(`CREATE INDEX idx_users_instance_role ON users(instance_role)`);
|
|
22028
|
+
sql.exec(`
|
|
22029
|
+
CREATE TABLE oauth_accounts (
|
|
22030
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
22031
|
+
user_id TEXT NOT NULL,
|
|
22032
|
+
provider TEXT NOT NULL CHECK (provider IN ('github', 'google')),
|
|
22033
|
+
provider_user_id TEXT NOT NULL,
|
|
22034
|
+
provider_username TEXT,
|
|
22035
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
22036
|
+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
22037
|
+
)
|
|
22038
|
+
`);
|
|
22039
|
+
sql.exec(`INSERT INTO oauth_accounts SELECT * FROM oauth_accounts_0012_backup`);
|
|
22040
|
+
sql.exec(`CREATE UNIQUE INDEX idx_oauth_accounts_provider ON oauth_accounts(provider, provider_user_id)`);
|
|
22041
|
+
sql.exec(`CREATE INDEX idx_oauth_accounts_user_id ON oauth_accounts(user_id)`);
|
|
22042
|
+
sql.exec(`
|
|
22043
|
+
CREATE TABLE api_keys (
|
|
22044
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
22045
|
+
name TEXT NOT NULL,
|
|
22046
|
+
key_hash TEXT NOT NULL,
|
|
22047
|
+
key_prefix TEXT NOT NULL,
|
|
22048
|
+
last_five TEXT NOT NULL,
|
|
22049
|
+
user_id TEXT NOT NULL,
|
|
22050
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
22051
|
+
last_used_at INTEGER,
|
|
22052
|
+
platform_key_id TEXT,
|
|
22053
|
+
scope TEXT,
|
|
22054
|
+
source TEXT NOT NULL DEFAULT 'local' CHECK (source IN ('local', 'standard_agents')),
|
|
22055
|
+
replica_active INTEGER NOT NULL DEFAULT 1,
|
|
22056
|
+
replica_updated_at INTEGER,
|
|
22057
|
+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
22058
|
+
)
|
|
22059
|
+
`);
|
|
22060
|
+
sql.exec(`INSERT INTO api_keys SELECT * FROM api_keys_0012_backup`);
|
|
22061
|
+
sql.exec(`CREATE INDEX idx_api_keys_key_hash ON api_keys(key_hash)`);
|
|
22062
|
+
sql.exec(`CREATE INDEX idx_api_keys_user_id ON api_keys(user_id)`);
|
|
22063
|
+
sql.exec(`CREATE INDEX idx_api_keys_key_prefix ON api_keys(key_prefix)`);
|
|
22064
|
+
sql.exec(`CREATE INDEX idx_api_keys_platform_key_id ON api_keys(platform_key_id)`);
|
|
22065
|
+
sql.exec(`CREATE INDEX idx_api_keys_replica_active ON api_keys(replica_active)`);
|
|
22066
|
+
sql.exec(`
|
|
22067
|
+
CREATE TABLE sessions (
|
|
22068
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
22069
|
+
user_id TEXT NOT NULL,
|
|
22070
|
+
token_hash TEXT NOT NULL,
|
|
22071
|
+
expires_at INTEGER NOT NULL,
|
|
22072
|
+
created_at INTEGER DEFAULT (strftime('%s', 'now')),
|
|
22073
|
+
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
22074
|
+
)
|
|
22075
|
+
`);
|
|
22076
|
+
sql.exec(`INSERT INTO sessions SELECT * FROM sessions_0012_backup`);
|
|
22077
|
+
sql.exec(`CREATE INDEX idx_sessions_token_hash ON sessions(token_hash)`);
|
|
22078
|
+
sql.exec(`CREATE INDEX idx_sessions_user_id ON sessions(user_id)`);
|
|
22079
|
+
sql.exec(`CREATE INDEX idx_sessions_expires_at ON sessions(expires_at)`);
|
|
22080
|
+
sql.exec(`DROP TABLE oauth_accounts_0012_backup`);
|
|
22081
|
+
sql.exec(`DROP TABLE api_keys_0012_backup`);
|
|
22082
|
+
sql.exec(`DROP TABLE sessions_0012_backup`);
|
|
22083
|
+
sql.exec(`
|
|
22084
|
+
INSERT OR REPLACE INTO _metadata (key, value) VALUES ('schema_version', '12')
|
|
22085
|
+
`);
|
|
22086
|
+
}
|
|
22087
|
+
};
|
|
22088
|
+
|
|
21979
22089
|
// src/durable-objects/agentbuilder-migrations/index.ts
|
|
21980
|
-
var migrations2 = [migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45];
|
|
21981
|
-
var LATEST_SCHEMA_VERSION2 =
|
|
22090
|
+
var migrations2 = [migration35, migration36, migration37, migration38, migration39, migration40, migration41, migration42, migration43, migration44, migration45, migration46];
|
|
22091
|
+
var LATEST_SCHEMA_VERSION2 = 12;
|
|
21982
22092
|
|
|
21983
22093
|
// src/utils/crypto.ts
|
|
21984
22094
|
var CryptoUtil = class {
|
|
@@ -22740,9 +22850,9 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
22740
22850
|
}
|
|
22741
22851
|
}
|
|
22742
22852
|
async runMigrations(fromVersion) {
|
|
22743
|
-
for (const
|
|
22744
|
-
if (
|
|
22745
|
-
await
|
|
22853
|
+
for (const migration47 of migrations2) {
|
|
22854
|
+
if (migration47.version > fromVersion) {
|
|
22855
|
+
await migration47.up(this.ctx.storage.sql);
|
|
22746
22856
|
}
|
|
22747
22857
|
}
|
|
22748
22858
|
}
|
|
@@ -24097,7 +24207,7 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
|
|
|
24097
24207
|
return cursor.toArray().map((row) => ({
|
|
24098
24208
|
id: row.id,
|
|
24099
24209
|
username: row.username,
|
|
24100
|
-
role: row.role === "user" ? "user" : "admin",
|
|
24210
|
+
role: row.role === "user" ? "user" : row.role === "api" ? "api" : "admin",
|
|
24101
24211
|
platform_user_id: row.platform_user_id ?? null,
|
|
24102
24212
|
email: row.email ?? null,
|
|
24103
24213
|
display_name: row.display_name ?? null,
|