@agent-native/core 0.204.0-nightly-20261008011018 → 0.204.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/action.d.ts +1 -0
- package/dist/action.js +4 -2
- package/dist/cli/agent.js +2 -11
- package/dist/client/use-db-sync.d.ts +13 -0
- package/dist/client/use-db-sync.js +22 -1
- package/dist/collab/client.js +36 -3
- package/dist/collab/routes.d.ts +7 -2
- package/dist/collab/routes.js +15 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.js +15 -8
- package/dist/deploy/workspace-deploy.js +88 -13
- package/dist/jobs/actions/manage-recurring-job.d.ts +1 -1
- package/dist/mcp/actions/create-org-service-token.js +1 -0
- package/dist/mcp/build-server.js +12 -9
- package/dist/mcp-client/oauth-routes.js +2 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/routes.d.ts +6 -6
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +3 -3
- package/dist/scripts/dev/index.js +2 -8
- package/dist/scripts/parse-args.d.ts +7 -0
- package/dist/scripts/parse-args.js +76 -0
- package/dist/scripts/utils.d.ts +1 -1
- package/dist/scripts/utils.js +1 -1
- package/dist/secrets/routes.d.ts +11 -11
- package/dist/server/action-discovery.js +4 -42
- package/dist/server/agent-chat/script-entries.js +3 -8
- package/dist/server/agent-chat-plugin.js +8 -42
- package/dist/server/agent-engine-default-model-route.d.ts +2 -2
- package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
- package/dist/server/auth.js +5 -2
- package/dist/server/google-oauth.js +8 -4
- package/dist/server/identity-sso.js +2 -1
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/poll.d.ts +9 -0
- package/dist/server/poll.js +86 -7
- package/dist/server/query-echo-safe-redirect.d.ts +10 -0
- package/dist/server/query-echo-safe-redirect.js +102 -0
- package/dist/server/workspace-provider-oauth.js +2 -1
- package/dist/templates/chat/.agents/skills/actions/references/action-fields.md +1 -0
- package/dist/templates/default/.agents/skills/actions/references/action-fields.md +1 -0
- package/dist/templates/headless/.agents/skills/actions/references/action-fields.md +1 -0
- package/dist/templates/workspace-core/.agents/skills/actions/references/action-fields.md +1 -0
- package/dist/triggers/actions/manage-automation.d.ts +7 -7
- package/docs/content/external-agents-catalog.mdx +19 -0
- package/package.json +4 -4
- package/src/templates/chat/.agents/skills/actions/references/action-fields.md +1 -0
- package/src/templates/default/.agents/skills/actions/references/action-fields.md +1 -0
- package/src/templates/headless/.agents/skills/actions/references/action-fields.md +1 -0
- package/src/templates/workspace-core/.agents/skills/actions/references/action-fields.md +1 -0
|
@@ -23,6 +23,82 @@ export function parseArgs(args) {
|
|
|
23
23
|
}
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
|
+
export function serializeCliArgs(args) {
|
|
27
|
+
return Object.entries(args).flatMap(([key, raw]) => {
|
|
28
|
+
const value = raw != null && typeof raw === "object"
|
|
29
|
+
? JSON.stringify(raw)
|
|
30
|
+
: String(raw);
|
|
31
|
+
return value.startsWith("--") ? [`--${key}=${value}`] : [`--${key}`, value];
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function normalizeShellArgs(input, options = {}) {
|
|
35
|
+
const tokens = [];
|
|
36
|
+
let current = "";
|
|
37
|
+
let inDouble = false;
|
|
38
|
+
let inSingle = false;
|
|
39
|
+
let wasQuoted = false;
|
|
40
|
+
let escape = false;
|
|
41
|
+
const pushToken = () => {
|
|
42
|
+
tokens.push({ value: current, quoted: wasQuoted });
|
|
43
|
+
current = "";
|
|
44
|
+
wasQuoted = false;
|
|
45
|
+
};
|
|
46
|
+
for (let i = 0; i < input.length; i++) {
|
|
47
|
+
const ch = input[i];
|
|
48
|
+
if (escape) {
|
|
49
|
+
current += ch;
|
|
50
|
+
escape = false;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (options.backslashEscapes && ch === "\\") {
|
|
54
|
+
if (inSingle) {
|
|
55
|
+
current += ch;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
escape = true;
|
|
59
|
+
}
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (ch === "'" && !inDouble) {
|
|
63
|
+
inSingle = !inSingle;
|
|
64
|
+
wasQuoted = true;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (ch === '"' && !inSingle) {
|
|
68
|
+
inDouble = !inDouble;
|
|
69
|
+
wasQuoted = true;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if ((options.splitAllWhitespace
|
|
73
|
+
? /\s/.test(ch)
|
|
74
|
+
: ch === " " || ch === "\t") &&
|
|
75
|
+
!inSingle &&
|
|
76
|
+
!inDouble) {
|
|
77
|
+
if (current.length > 0 || wasQuoted)
|
|
78
|
+
pushToken();
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
current += ch;
|
|
82
|
+
}
|
|
83
|
+
if (current.length > 0 || wasQuoted)
|
|
84
|
+
pushToken();
|
|
85
|
+
const normalized = [];
|
|
86
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
87
|
+
const token = tokens[i];
|
|
88
|
+
const next = tokens[i + 1];
|
|
89
|
+
if (token.value.startsWith("--") &&
|
|
90
|
+
!token.value.includes("=") &&
|
|
91
|
+
next?.quoted &&
|
|
92
|
+
next.value.startsWith("--")) {
|
|
93
|
+
normalized.push(`${token.value}=${next.value}`);
|
|
94
|
+
i++;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
normalized.push(token.value);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return normalized;
|
|
101
|
+
}
|
|
26
102
|
export function camelCaseArgs(args) {
|
|
27
103
|
const result = {};
|
|
28
104
|
for (const [key, value] of Object.entries(args)) {
|
package/dist/scripts/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { findWorkspaceRoot } from "./workspace-root.js";
|
|
2
2
|
export { fail, type FailOptions } from "../action.js";
|
|
3
|
-
export { parseArgs, camelCaseArgs } from "./parse-args.js";
|
|
3
|
+
export { parseArgs, serializeCliArgs, camelCaseArgs } from "./parse-args.js";
|
|
4
4
|
export declare function loadEnv(envPath?: string): void;
|
|
5
5
|
export declare function isValidPath(p: string): boolean;
|
|
6
6
|
export declare function isValidProjectPath(project: string): boolean;
|
package/dist/scripts/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import dotenv from "dotenv";
|
|
|
4
4
|
import { findWorkspaceRoot } from "./workspace-root.js";
|
|
5
5
|
export { findWorkspaceRoot } from "./workspace-root.js";
|
|
6
6
|
export { fail } from "../action.js";
|
|
7
|
-
export { parseArgs, camelCaseArgs } from "./parse-args.js";
|
|
7
|
+
export { parseArgs, serializeCliArgs, camelCaseArgs } from "./parse-args.js";
|
|
8
8
|
export function loadEnv(envPath) {
|
|
9
9
|
const appEnv = envPath ?? path.join(process.cwd(), ".env");
|
|
10
10
|
const shellKeys = new Set(Object.keys(process.env));
|
package/dist/secrets/routes.d.ts
CHANGED
|
@@ -58,47 +58,47 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
|
|
|
58
58
|
error: string;
|
|
59
59
|
errorCode?: undefined;
|
|
60
60
|
retryable?: undefined;
|
|
61
|
-
ok?: undefined;
|
|
62
61
|
status?: undefined;
|
|
62
|
+
ok?: undefined;
|
|
63
63
|
} | {
|
|
64
64
|
error: string;
|
|
65
65
|
errorCode: string;
|
|
66
66
|
retryable?: undefined;
|
|
67
|
-
ok?: undefined;
|
|
68
67
|
status?: undefined;
|
|
68
|
+
ok?: undefined;
|
|
69
69
|
} | {
|
|
70
70
|
error: string;
|
|
71
71
|
errorCode: string;
|
|
72
72
|
retryable: boolean;
|
|
73
|
-
ok?: undefined;
|
|
74
73
|
status?: undefined;
|
|
74
|
+
ok?: undefined;
|
|
75
75
|
} | {
|
|
76
|
-
error?: undefined;
|
|
77
76
|
errorCode?: undefined;
|
|
78
77
|
retryable?: undefined;
|
|
79
78
|
ok: boolean;
|
|
80
79
|
status: string;
|
|
80
|
+
error?: undefined;
|
|
81
81
|
} | {
|
|
82
|
-
ok?: undefined;
|
|
83
82
|
error: string;
|
|
84
83
|
removed?: undefined;
|
|
84
|
+
ok?: undefined;
|
|
85
85
|
} | {
|
|
86
|
-
error?: undefined;
|
|
87
86
|
ok: boolean;
|
|
88
87
|
removed: boolean;
|
|
88
|
+
error?: undefined;
|
|
89
89
|
}>>;
|
|
90
90
|
export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
91
|
-
ok?: undefined;
|
|
92
91
|
error: string;
|
|
93
92
|
note?: undefined;
|
|
93
|
+
ok?: undefined;
|
|
94
94
|
} | {
|
|
95
|
-
error?: undefined;
|
|
96
95
|
ok: boolean;
|
|
97
96
|
note?: undefined;
|
|
98
|
-
} | {
|
|
99
97
|
error?: undefined;
|
|
98
|
+
} | {
|
|
100
99
|
ok: boolean;
|
|
101
100
|
note: string;
|
|
101
|
+
error?: undefined;
|
|
102
102
|
} | {
|
|
103
103
|
note?: undefined;
|
|
104
104
|
ok: boolean;
|
|
@@ -126,11 +126,11 @@ export declare function createAdHocSecretHandler(): import("h3").EventHandlerWit
|
|
|
126
126
|
} | {
|
|
127
127
|
error: string;
|
|
128
128
|
} | {
|
|
129
|
-
error?: undefined;
|
|
130
129
|
ok: boolean;
|
|
131
130
|
key: string;
|
|
132
|
-
} | {
|
|
133
131
|
error?: undefined;
|
|
132
|
+
} | {
|
|
134
133
|
ok: boolean;
|
|
135
134
|
removed: boolean;
|
|
135
|
+
error?: undefined;
|
|
136
136
|
}>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nodePath from "node:path";
|
|
2
2
|
import "../authorization/check-action.js";
|
|
3
3
|
import { CORE_ACTION_GROUPS } from "../framework-tools.js";
|
|
4
|
+
import { normalizeShellArgs, serializeCliArgs } from "../scripts/parse-args.js";
|
|
4
5
|
import { captureCliOutput } from "./cli-capture.js";
|
|
5
6
|
let _fs;
|
|
6
7
|
async function getFs() {
|
|
@@ -54,39 +55,6 @@ export function mergePackageActions(registry) {
|
|
|
54
55
|
registry[name] = entry;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
function splitShellArgs(input) {
|
|
58
|
-
const tokens = [];
|
|
59
|
-
let current = "";
|
|
60
|
-
let inDouble = false;
|
|
61
|
-
let inSingle = false;
|
|
62
|
-
let wasQuoted = false;
|
|
63
|
-
for (let i = 0; i < input.length; i++) {
|
|
64
|
-
const ch = input[i];
|
|
65
|
-
if (ch === '"' && !inSingle) {
|
|
66
|
-
inDouble = !inDouble;
|
|
67
|
-
wasQuoted = true;
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
if (ch === "'" && !inDouble) {
|
|
71
|
-
inSingle = !inSingle;
|
|
72
|
-
wasQuoted = true;
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if ((ch === " " || ch === "\t") && !inDouble && !inSingle) {
|
|
76
|
-
if (current.length > 0 || wasQuoted) {
|
|
77
|
-
tokens.push(current);
|
|
78
|
-
}
|
|
79
|
-
current = "";
|
|
80
|
-
wasQuoted = false;
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
current += ch;
|
|
84
|
-
}
|
|
85
|
-
if (current.length > 0 || wasQuoted) {
|
|
86
|
-
tokens.push(current);
|
|
87
|
-
}
|
|
88
|
-
return tokens;
|
|
89
|
-
}
|
|
90
58
|
function wrapDefaultExport(name, defaultFn) {
|
|
91
59
|
const tool = {
|
|
92
60
|
description: `Run the "${name}" action. Pass arguments as key-value pairs.`,
|
|
@@ -103,15 +71,9 @@ function wrapDefaultExport(name, defaultFn) {
|
|
|
103
71
|
return {
|
|
104
72
|
tool,
|
|
105
73
|
run: async (args) => {
|
|
106
|
-
const cliArgs =
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
for (const [k, v] of Object.entries(args)) {
|
|
112
|
-
cliArgs.push(`--${k}`, v);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
74
|
+
const cliArgs = args.args && Object.keys(args).length === 1
|
|
75
|
+
? normalizeShellArgs(args.args)
|
|
76
|
+
: serializeCliArgs(args);
|
|
115
77
|
return captureCliOutput(() => defaultFn(cliArgs));
|
|
116
78
|
},
|
|
117
79
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { renameThread, resolveThreadAccess, setThreadArchived, setThreadPinned, } from "../../chat-threads/store.js";
|
|
2
2
|
import { dbExecToolParameters } from "../../scripts/db/tool-schemas.js";
|
|
3
|
+
import { serializeCliArgs } from "../../scripts/parse-args.js";
|
|
3
4
|
import { captureCliOutput } from "../cli-capture.js";
|
|
4
5
|
import { getAmbientUserEmail, getRequestOrgId, getRequestRunContext, getRequestUserEmail, } from "../request-context.js";
|
|
5
6
|
function wrapCliScript(tool, cliDefault, opts) {
|
|
@@ -7,18 +8,12 @@ function wrapCliScript(tool, cliDefault, opts) {
|
|
|
7
8
|
tool,
|
|
8
9
|
...(opts?.readOnly ? { readOnly: true } : {}),
|
|
9
10
|
run: async (args) => {
|
|
10
|
-
const
|
|
11
|
-
for (const [k, v] of Object.entries(args)) {
|
|
11
|
+
for (const k of Object.keys(args)) {
|
|
12
12
|
if (opts?.allowedArgs && !opts.allowedArgs.includes(k)) {
|
|
13
13
|
throw new Error(`Unknown argument: ${k}`);
|
|
14
14
|
}
|
|
15
|
-
const raw = v;
|
|
16
|
-
const value = raw != null && typeof raw === "object"
|
|
17
|
-
? JSON.stringify(raw)
|
|
18
|
-
: String(raw);
|
|
19
|
-
cliArgs.push(`--${k}`, value);
|
|
20
15
|
}
|
|
21
|
-
return captureCliOutput(() => cliDefault(
|
|
16
|
+
return captureCliOutput(() => cliDefault(serializeCliArgs(args)));
|
|
22
17
|
},
|
|
23
18
|
};
|
|
24
19
|
}
|
|
@@ -46,6 +46,7 @@ import { setProgressPreListHook } from "../progress/store.js";
|
|
|
46
46
|
import { getSkillNameFromPath } from "../resources/metadata.js";
|
|
47
47
|
import { resourceList, resourceListAccessible, resourceGet, ensurePersonalDefaults, isWorkspaceResourceOwner, SHARED_OWNER, WORKSPACE_OWNER, } from "../resources/store.js";
|
|
48
48
|
import { normalizeDatabaseToolsMode } from "../scripts/db/tool-mode.js";
|
|
49
|
+
import { normalizeShellArgs, serializeCliArgs } from "../scripts/parse-args.js";
|
|
49
50
|
import { getSetting, putSetting } from "../settings/store.js";
|
|
50
51
|
import { retryContextFromRequest, } from "../shared/agent-chat-run-not-started.js";
|
|
51
52
|
import { ANALYTICS_CLIENT_PLATFORM_BODY_FIELD, normalizeAnalyticsClientPlatform, } from "../shared/analytics-platform.js";
|
|
@@ -1043,54 +1044,19 @@ export function createAgentChatPlugin(options) {
|
|
|
1043
1044
|
}
|
|
1044
1045
|
const tokens = [];
|
|
1045
1046
|
if (typeof input?.args === "string" && input.args.trim()) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
for (let i = 0; i < input.args.length; i++) {
|
|
1051
|
-
const char = input.args[i];
|
|
1052
|
-
if (escape) {
|
|
1053
|
-
current += char;
|
|
1054
|
-
escape = false;
|
|
1055
|
-
continue;
|
|
1056
|
-
}
|
|
1057
|
-
if (char === "\\") {
|
|
1058
|
-
if (inSingle) {
|
|
1059
|
-
current += char;
|
|
1060
|
-
}
|
|
1061
|
-
else {
|
|
1062
|
-
escape = true;
|
|
1063
|
-
}
|
|
1064
|
-
continue;
|
|
1065
|
-
}
|
|
1066
|
-
if (char === "'" && !inDouble) {
|
|
1067
|
-
inSingle = !inSingle;
|
|
1068
|
-
continue;
|
|
1069
|
-
}
|
|
1070
|
-
if (char === '"' && !inSingle) {
|
|
1071
|
-
inDouble = !inDouble;
|
|
1072
|
-
continue;
|
|
1073
|
-
}
|
|
1074
|
-
if (/\s/.test(char) && !inSingle && !inDouble) {
|
|
1075
|
-
if (current.length > 0) {
|
|
1076
|
-
tokens.push(current);
|
|
1077
|
-
current = "";
|
|
1078
|
-
}
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
current += char;
|
|
1082
|
-
}
|
|
1083
|
-
if (current.length > 0) {
|
|
1084
|
-
tokens.push(current);
|
|
1085
|
-
}
|
|
1047
|
+
tokens.push(...normalizeShellArgs(input.args, {
|
|
1048
|
+
backslashEscapes: true,
|
|
1049
|
+
splitAllWhitespace: true,
|
|
1050
|
+
}));
|
|
1086
1051
|
}
|
|
1087
1052
|
else if (input && typeof input === "object") {
|
|
1053
|
+
const actionArgs = {};
|
|
1088
1054
|
for (const [k, v] of Object.entries(input)) {
|
|
1089
1055
|
if (k === "args" || v === undefined || v === null)
|
|
1090
1056
|
continue;
|
|
1091
|
-
|
|
1092
|
-
tokens.push(`--${k}`, strVal);
|
|
1057
|
+
actionArgs[k] = v;
|
|
1093
1058
|
}
|
|
1059
|
+
tokens.push(...serializeCliArgs(actionArgs));
|
|
1094
1060
|
}
|
|
1095
1061
|
const BLOCKED_OPERATORS = new Set([
|
|
1096
1062
|
";",
|
|
@@ -8,17 +8,17 @@ export declare const AGENT_ENGINE_API_KEY_ACTION_NAME = "agent-engine-api-key";
|
|
|
8
8
|
* resolveEngine's credential detection.
|
|
9
9
|
*/
|
|
10
10
|
export declare function createAgentEngineDisconnectHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
11
|
-
ok?: undefined;
|
|
12
11
|
error: string;
|
|
13
12
|
scope?: undefined;
|
|
13
|
+
ok?: undefined;
|
|
14
14
|
} | {
|
|
15
15
|
ok: boolean;
|
|
16
16
|
error: any;
|
|
17
17
|
scope?: undefined;
|
|
18
18
|
} | {
|
|
19
|
-
error?: undefined;
|
|
20
19
|
ok: boolean;
|
|
21
20
|
scope: "org" | "user";
|
|
21
|
+
error?: undefined;
|
|
22
22
|
}>>;
|
|
23
23
|
export interface DefaultModelSelectionRequest {
|
|
24
24
|
engine: string;
|
package/dist/server/auth.js
CHANGED
|
@@ -85,6 +85,7 @@ import * as loopback from "./loopback.js";
|
|
|
85
85
|
import { encodeMagicLinkSignupAttribution, MAGIC_LINK_ATTRIBUTION_PARAM, } from "./magic-link-attribution.js";
|
|
86
86
|
import { safeOAuthReturnUrl } from "./oauth-return-url.js";
|
|
87
87
|
import { getDeploySettingsRequiredHtml, getOnboardingHtml, getResetPasswordHtml, } from "./onboarding-html.js";
|
|
88
|
+
import { queryEchoSafeRedirect } from "./query-echo-safe-redirect.js";
|
|
88
89
|
import { getRequestContext, markRequestIdentityAuthenticatedAtMs, hasContinuationLocalRequestContext, hasExplicitPersonalOrgScope, markExplicitPersonalOrgScope, runWithRequestContext, } from "./request-context.js";
|
|
89
90
|
import { captureAuthError } from "./sentry.js";
|
|
90
91
|
import { isTestIdentity } from "./test-identity.js";
|
|
@@ -4901,7 +4902,9 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
4901
4902
|
response.status < 300) {
|
|
4902
4903
|
setFirstRunOnboardingCookie(event);
|
|
4903
4904
|
}
|
|
4904
|
-
return
|
|
4905
|
+
return isResponse
|
|
4906
|
+
? queryEchoSafeRedirect(event, response)
|
|
4907
|
+
: response;
|
|
4905
4908
|
}));
|
|
4906
4909
|
app.use("/_agent-native/auth/login", defineEventHandler(async (event) => {
|
|
4907
4910
|
if (getMethod(event) !== "POST") {
|
|
@@ -4968,7 +4971,7 @@ async function mountBetterAuthRoutes(app, options) {
|
|
|
4968
4971
|
? query.return[0]
|
|
4969
4972
|
: query.return;
|
|
4970
4973
|
setFirstRunOnboardingCookie(event);
|
|
4971
|
-
return redirectWithStagedCookies(event, safeReturnPath(rawReturn), 302);
|
|
4974
|
+
return queryEchoSafeRedirect(event, redirectWithStagedCookies(event, safeReturnPath(rawReturn), 302));
|
|
4972
4975
|
}));
|
|
4973
4976
|
app.use("/_agent-native/auth/magic-link", defineEventHandler(async (event) => {
|
|
4974
4977
|
if (getMethod(event) === "POST" &&
|
|
@@ -14,6 +14,7 @@ import { setIdentityGoogleAuthCookie } from "./identity-auth-provider.js";
|
|
|
14
14
|
import { isNetlifyDeployPermalinkGoogleOAuthClientOrigin, isNetlifyDeployPermalinkGoogleOAuthClientRequest, } from "./identity-sso-store.js";
|
|
15
15
|
import { appendSessionToOAuthReturnUrl } from "./oauth-return-url.js";
|
|
16
16
|
import { EXPLICIT_PUBLIC_ORIGIN_ENV_KEYS, firstOriginFromEnv, getConfiguredOriginAllowlist, isLoopbackHost, normalizeOrigin, WORKSPACE_GATEWAY_ORIGIN_ENV_KEYS, } from "./origin-allowlist.js";
|
|
17
|
+
import { queryEchoSafeRedirect } from "./query-echo-safe-redirect.js";
|
|
17
18
|
import { isWorkspaceOAuthCallbackRelayEnabled } from "./workspace-oauth.js";
|
|
18
19
|
function safeReturnPath(raw) {
|
|
19
20
|
return normalizeAppPath(raw) ?? "/";
|
|
@@ -669,9 +670,6 @@ export function oauthCallbackResponse(event, email, opts) {
|
|
|
669
670
|
</script></body></html>`);
|
|
670
671
|
}
|
|
671
672
|
const location = appendSessionToOAuthReturnUrl(opts.returnUrl, opts.sessionToken);
|
|
672
|
-
setResponseStatus(event, 302);
|
|
673
|
-
setResponseHeader(event, "Location", location);
|
|
674
|
-
setResponseHeader(event, "Referrer-Policy", "no-referrer");
|
|
675
673
|
const headers = new Headers({
|
|
676
674
|
Location: location,
|
|
677
675
|
"Referrer-Policy": "no-referrer",
|
|
@@ -679,7 +677,13 @@ export function oauthCallbackResponse(event, email, opts) {
|
|
|
679
677
|
for (const cookie of event.res?.headers?.getSetCookie?.() ?? []) {
|
|
680
678
|
headers.append("set-cookie", cookie);
|
|
681
679
|
}
|
|
682
|
-
|
|
680
|
+
const response = queryEchoSafeRedirect(event, new Response(null, { status: 302, headers }));
|
|
681
|
+
if (response.status === 302) {
|
|
682
|
+
setResponseStatus(event, 302);
|
|
683
|
+
setResponseHeader(event, "Location", location);
|
|
684
|
+
}
|
|
685
|
+
setResponseHeader(event, "Referrer-Policy", "no-referrer");
|
|
686
|
+
return response;
|
|
683
687
|
}
|
|
684
688
|
export function oauthErrorPage(message, status = 400) {
|
|
685
689
|
const safe = escapeHtml(message);
|
|
@@ -16,6 +16,7 @@ import { createOAuthSession, getAppUrl, getOrigin } from "./google-oauth.js";
|
|
|
16
16
|
import { hasIdentityGoogleAuthCookie } from "./identity-auth-provider.js";
|
|
17
17
|
import { IDENTITY_SSO_PROVIDER_ID } from "./identity-sso-provider.js";
|
|
18
18
|
import { consumeSsoState, createSsoState, CANONICAL_IDENTITY_SSO_HUB_URL, NETLIFY_PREVIEW_IDENTITY_SSO_HUB_URL, getIdentityHubUrl, identitySsoLoginButtonHtml, isCanonicalIdentitySsoClientRequest, isDesktopSsoUserAgent, isIdentitySsoExplicitlyEnabled, isIdentitySsoEnabled, isNetlifyDeployPermalinkIdentitySsoClientRequest, isJtiReplayed, SSO_STATE_TTL_MS, } from "./identity-sso-store.js";
|
|
19
|
+
import { queryEchoSafeRedirect } from "./query-echo-safe-redirect.js";
|
|
19
20
|
import { getRequestContext, hasContinuationLocalRequestContext, runWithRequestContext, } from "./request-context.js";
|
|
20
21
|
export { getIdentityHubUrl, identitySsoLoginButtonHtml, isIdentitySsoEnabled };
|
|
21
22
|
export { IDENTITY_SSO_PROVIDER_ID };
|
|
@@ -63,7 +64,7 @@ function redirect(event, location) {
|
|
|
63
64
|
const staged = event.res?.headers?.getSetCookie?.() ?? [];
|
|
64
65
|
for (const cookie of staged)
|
|
65
66
|
headers.append("set-cookie", cookie);
|
|
66
|
-
return new Response("", { status: 302, headers });
|
|
67
|
+
return queryEchoSafeRedirect(event, new Response("", { status: 302, headers }));
|
|
67
68
|
}
|
|
68
69
|
function errorPage(message, loginPath) {
|
|
69
70
|
const safe = message
|
package/dist/server/index.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ export { createOnboardingPlugin, defaultOnboardingPlugin, } from "../onboarding/
|
|
|
86
86
|
export { registerFileUploadProvider, unregisterFileUploadProvider, listFileUploadProviders, getActiveFileUploadProvider, getActiveFileUploadProviderForRequest, uploadFile, builderFileUploadProvider, type FileUploadInput, type FileUploadProvider, type FileUploadResult, } from "../file-upload/index.js";
|
|
87
87
|
export { createIntegrationsPlugin, defaultIntegrationsPlugin, enqueueRemoteCommand, slackAdapter, telegramAdapter, whatsappAdapter, discordAdapter, microsoftTeamsAdapter, emailAdapter, assertPlatformCapability, type PlatformAdapter, type IncomingMessage, type OutgoingMessage, type PlatformAdapterCapabilities, type ImmediateWebhookResponse, type IntegrationStatus, type IntegrationsPluginOptions, type IntegrationExecutionContext, BUILT_IN_INTEGRATION_CATALOG, INTEGRATION_CATEGORIES, getIntegrationCatalogEntry, listBuiltInChannelIntegrations, listIntegrationCatalog, type BuiltInChannelId, type ChannelCapabilities, type IntegrationAvailability, type IntegrationCatalogEntry, type IntegrationCategory, type IntegrationCredentialRequirement, type IntegrationIconKey, type IntegrationSupportMaturity, } from "../integrations/index.js";
|
|
88
88
|
export { isElectron, isMobile, getOrigin, getAppBasePath, getAppUrl, resolveOAuthRedirectUri, isAllowedOAuthRedirectUri, encodeOAuthState, decodeOAuthState, encodeNetlifyPreviewGoogleOAuthRelayState, decodeNetlifyPreviewGoogleOAuthRelayState, wrapNetlifyPreviewGoogleOAuthState, getNetlifyPreviewGoogleOAuthCallbackUrl, isNetlifyPreviewGoogleOAuthCallbackUrl, isNetlifyPreviewGoogleOAuthRelayState, AGENT_NATIVE_GOOGLE_OAUTH_RELAY_SECRET_ENV, NETLIFY_PREVIEW_GOOGLE_OAUTH_CALLBACK_URL, logOAuthStateDecodeFailure, resolveOAuthOwner, createOAuthSession, oauthCallbackResponse, oauthErrorPage, oauthDesktopExchangePage, type OAuthStatePayload, type OAuthStateDecodeFailureReason, type DecodeOAuthStateResult, type OAuthOwnerResult, type OAuthSessionResult, } from "./google-oauth.js";
|
|
89
|
+
export { queryEchoSafeRedirect } from "./query-echo-safe-redirect.js";
|
|
89
90
|
export { buildWorkspaceProviderAuthorizationUrl, createWorkspaceProviderOAuthHandler, exchangeWorkspaceProviderOAuthCode, handleWorkspaceProviderOAuthCallback, handleWorkspaceProviderOAuthStart, hasWorkspaceProviderOAuthCredentials, isGoogleWorkspaceOAuthProvider, isWorkspaceProviderOAuthFlowValid, mergeWorkspaceOAuthValues, resolveWorkspaceProviderIdentity, workspaceProviderOAuthPath, type GenericWorkspaceOAuthProvider, type WorkspaceProviderOAuthFlow, } from "./workspace-provider-oauth.js";
|
|
90
91
|
export { CredentialStoreUnavailableError, FeatureNotConfiguredError, hasBuilderPrivateKey, isBuilderEnvManaged, getBuilderProxyOrigin, getBuilderImageGenerationBaseUrl, getBuilderEmbeddingsBaseUrl, getBuilderVideoGenerationBaseUrl, getBuilderWebSearchBaseUrl, getBuilderAuthHeader, resolveBuilderPrivateKey, resolveBuilderAuthHeader, resolveHasBuilderPrivateKey, resolveHasCompleteBuilderConnection, resolveBuilderCredentials, resolveBuilderCredentialsDetailed, resolveBuilderGatewayCredentialsDetailed, resolveBuilderGatewayAuth, resolveBuilderGatewayCredentials, resolveHasBuilderGatewayCredential, resolveBuilderCredentialSource, resolveBuilderCredential, readDeployCredentialEnv, resolveVercelDeploymentProtectionHeaders, writeBuilderCredentials, deleteBuilderCredentials, resolveSecret, resolveSecretDetailed, prefetchSecrets, BuilderCredentialLookupError, type BuilderCredentialsDetailed, type ResolvedSecretDetail, } from "./credential-provider.js";
|
|
91
92
|
export { GEMINI_API_KEY, LEGACY_GEMINI_API_KEY, canonicalSecretKey, readGeminiDeployCredentialEnv, resolveGeminiApiKey, resolveGeminiApiKeyDetailed, resolveSecretWithAliases, resolveSecretWithAliasesDetailed, secretKeyNames, type ResolvedAliasedSecret, } from "./secret-key-aliases.js";
|
package/dist/server/index.js
CHANGED
|
@@ -81,6 +81,7 @@ export { createOnboardingPlugin, defaultOnboardingPlugin, } from "../onboarding/
|
|
|
81
81
|
export { registerFileUploadProvider, unregisterFileUploadProvider, listFileUploadProviders, getActiveFileUploadProvider, getActiveFileUploadProviderForRequest, uploadFile, builderFileUploadProvider, } from "../file-upload/index.js";
|
|
82
82
|
export { createIntegrationsPlugin, defaultIntegrationsPlugin, enqueueRemoteCommand, slackAdapter, telegramAdapter, whatsappAdapter, discordAdapter, microsoftTeamsAdapter, emailAdapter, assertPlatformCapability, BUILT_IN_INTEGRATION_CATALOG, INTEGRATION_CATEGORIES, getIntegrationCatalogEntry, listBuiltInChannelIntegrations, listIntegrationCatalog, } from "../integrations/index.js";
|
|
83
83
|
export { isElectron, isMobile, getOrigin, getAppBasePath, getAppUrl, resolveOAuthRedirectUri, isAllowedOAuthRedirectUri, encodeOAuthState, decodeOAuthState, encodeNetlifyPreviewGoogleOAuthRelayState, decodeNetlifyPreviewGoogleOAuthRelayState, wrapNetlifyPreviewGoogleOAuthState, getNetlifyPreviewGoogleOAuthCallbackUrl, isNetlifyPreviewGoogleOAuthCallbackUrl, isNetlifyPreviewGoogleOAuthRelayState, AGENT_NATIVE_GOOGLE_OAUTH_RELAY_SECRET_ENV, NETLIFY_PREVIEW_GOOGLE_OAUTH_CALLBACK_URL, logOAuthStateDecodeFailure, resolveOAuthOwner, createOAuthSession, oauthCallbackResponse, oauthErrorPage, oauthDesktopExchangePage, } from "./google-oauth.js";
|
|
84
|
+
export { queryEchoSafeRedirect } from "./query-echo-safe-redirect.js";
|
|
84
85
|
export { buildWorkspaceProviderAuthorizationUrl, createWorkspaceProviderOAuthHandler, exchangeWorkspaceProviderOAuthCode, handleWorkspaceProviderOAuthCallback, handleWorkspaceProviderOAuthStart, hasWorkspaceProviderOAuthCredentials, isGoogleWorkspaceOAuthProvider, isWorkspaceProviderOAuthFlowValid, mergeWorkspaceOAuthValues, resolveWorkspaceProviderIdentity, workspaceProviderOAuthPath, } from "./workspace-provider-oauth.js";
|
|
85
86
|
export { CredentialStoreUnavailableError, FeatureNotConfiguredError, hasBuilderPrivateKey, isBuilderEnvManaged, getBuilderProxyOrigin, getBuilderImageGenerationBaseUrl, getBuilderEmbeddingsBaseUrl, getBuilderVideoGenerationBaseUrl, getBuilderWebSearchBaseUrl, getBuilderAuthHeader, resolveBuilderPrivateKey, resolveBuilderAuthHeader, resolveHasBuilderPrivateKey, resolveHasCompleteBuilderConnection, resolveBuilderCredentials, resolveBuilderCredentialsDetailed, resolveBuilderGatewayCredentialsDetailed, resolveBuilderGatewayAuth, resolveBuilderGatewayCredentials, resolveHasBuilderGatewayCredential, resolveBuilderCredentialSource, resolveBuilderCredential, readDeployCredentialEnv, resolveVercelDeploymentProtectionHeaders, writeBuilderCredentials, deleteBuilderCredentials, resolveSecret, resolveSecretDetailed, prefetchSecrets, BuilderCredentialLookupError, } from "./credential-provider.js";
|
|
86
87
|
export { GEMINI_API_KEY, LEGACY_GEMINI_API_KEY, canonicalSecretKey, readGeminiDeployCredentialEnv, resolveGeminiApiKey, resolveGeminiApiKeyDetailed, resolveSecretWithAliases, resolveSecretWithAliasesDetailed, secretKeyNames, } from "./secret-key-aliases.js";
|
package/dist/server/poll.d.ts
CHANGED
|
@@ -86,6 +86,10 @@ export declare class AppSyncState {
|
|
|
86
86
|
private accessCacheTtl;
|
|
87
87
|
private durableEventId;
|
|
88
88
|
getVersion(): number;
|
|
89
|
+
getPollBaseline(useDurableEvents: boolean): Promise<{
|
|
90
|
+
version: number;
|
|
91
|
+
cursor: string;
|
|
92
|
+
}>;
|
|
89
93
|
getPollEmitter(): EventEmitter;
|
|
90
94
|
wireLocalEmitters(): void;
|
|
91
95
|
ensureSyncEventsTable(): Promise<boolean>;
|
|
@@ -154,6 +158,7 @@ export declare class AppSyncState {
|
|
|
154
158
|
getChangesSinceForUser(since: number, userEmail: string, orgId: string | undefined, cursor?: SyncCursor): ChangeReadResult;
|
|
155
159
|
getDurableChangesSinceForUser(since: number, userEmail: string, orgId: string | undefined, cursor?: SyncCursor): Promise<ChangeReadResult>;
|
|
156
160
|
getCombinedChangesSinceForUser(since: number, userEmail: string, orgId: string | undefined, useDurableEvents: boolean, cursor?: SyncCursor): Promise<ChangeReadResult>;
|
|
161
|
+
private readCombinedChangesSinceForUser;
|
|
157
162
|
seedVersionFromDb(): Promise<void>;
|
|
158
163
|
checkExternalDbChanges(options: {
|
|
159
164
|
durableEvents: boolean;
|
|
@@ -164,6 +169,10 @@ declare function hostedRealtimeTransportEnabled(): boolean;
|
|
|
164
169
|
export declare const __hostedRealtimeTransportEnabledForTests: typeof hostedRealtimeTransportEnabled;
|
|
165
170
|
export declare function getDefaultAppSyncState(): AppSyncState;
|
|
166
171
|
export declare function getVersion(): number;
|
|
172
|
+
export declare function getCurrentPollBaseline(state?: AppSyncState): Promise<{
|
|
173
|
+
version: number;
|
|
174
|
+
cursor: string;
|
|
175
|
+
}>;
|
|
167
176
|
export declare function getPollEmitter(): EventEmitter;
|
|
168
177
|
export declare function invalidateCollabAccessCache(resourceType: string, resourceId: string): void;
|
|
169
178
|
export declare function __resetCollabAccessCacheForTests(): void;
|