@circuitwall/jarela 2.5.1 → 2.5.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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +5 -5
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/credentials/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/events/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +22 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +22 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +22 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +19 -2
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +19 -2
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +19 -2
- package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +12 -2
- package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +12 -2
- package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/route.js +12 -2
- package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +52 -45
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/tools/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page.js +72982 -72980
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +5 -5
- package/.next/standalone/.next/server/chunks/1433.js +1 -1
- package/.next/standalone/.next/server/chunks/210.js +6 -6
- package/.next/standalone/.next/server/chunks/2471.js +17 -17
- package/.next/standalone/.next/server/chunks/3524.js +31 -15
- package/.next/standalone/.next/server/chunks/3566.js +1 -1
- package/.next/standalone/.next/server/chunks/4189.js +1 -1
- package/.next/standalone/.next/server/chunks/{9590.js → 423.js} +10 -3
- package/.next/standalone/.next/server/chunks/4508.js +2 -2
- package/.next/standalone/.next/server/chunks/4596.js +5 -2
- package/.next/standalone/.next/server/chunks/46.js +7 -0
- package/.next/standalone/.next/server/chunks/540.js +29 -5
- package/.next/standalone/.next/server/chunks/5585.js +41 -3
- package/.next/standalone/.next/server/chunks/5908.js +10 -10
- package/.next/standalone/.next/server/chunks/{3399.js → 6058.js} +882 -400
- package/.next/standalone/.next/server/chunks/{9164.js → 6190.js} +13777 -13530
- package/.next/standalone/.next/server/chunks/6649.js +1 -1
- package/.next/standalone/.next/server/chunks/{1388.js → 8842.js} +5961 -5793
- package/.next/standalone/.next/server/chunks/9032.js +5 -5
- package/.next/standalone/.next/server/chunks/{7547.js → 9217.js} +485 -3
- package/.next/standalone/.next/server/instrumentation.js +7 -0
- package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
- package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/standalone/.next/server/middleware.js +7 -0
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/preview-props.json +3 -3
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/app/{page-dd05bcb5f5b81157.js → page-4112e14360a9909e.js} +1576 -1574
- package/.next/standalone/docs/adoption/changesets.json +139 -0
- package/.next/standalone/package.json +2 -1
- package/CHANGELOG.md +38 -0
- package/browser-extension/background.js +5 -539
- package/browser-extension/lib/form-editing.mjs +541 -0
- package/components/chat/MessageBubble.tsx +4 -736
- package/components/chat/MessageContent.tsx +749 -0
- package/components/layout/MenuPanel.tsx +1 -1
- package/hooks/useSSE.test.ts +46 -0
- package/lib/agents/llm.ts +1 -1
- package/lib/agents/output-validator/validator.test.ts +4 -0
- package/lib/agents/output-validator/validator.ts +1 -1
- package/lib/agents/prompt-registry.test.ts +11 -0
- package/lib/agents/prompt-registry.ts +13 -0
- package/lib/agents/retry-prompts.ts +17 -0
- package/lib/agents/run-retry.ts +671 -0
- package/lib/agents/run-thread.retry.test.ts +176 -2
- package/lib/agents/run-thread.test.ts +6 -6
- package/lib/agents/run-thread.ts +9 -717
- package/lib/agents/stream-collector.test.ts +28 -4
- package/lib/agents/stream-collector.ts +5 -28
- package/lib/agents/tool-outcomes.ts +61 -0
- package/lib/documents/remote/confluence.test.ts +65 -0
- package/lib/documents/remote/confluence.ts +35 -9
- package/lib/documents/remote/jira.ts +1 -1
- package/lib/health/probes.test.ts +32 -0
- package/lib/health/probes.ts +29 -14
- package/lib/integrations/atlassian/manifest.ts +5 -3
- package/lib/integrations/github/manifest.ts +7 -4
- package/lib/integrations/gmail-oauth.ts +16 -1
- package/lib/integrations/microsoft-oauth.ts +17 -2
- package/lib/integrations/outlook/manifest.ts +10 -8
- package/lib/stores/integrations.ts +1 -0
- package/lib/tools/communications/calendar-aliases.test.ts +77 -1
- package/lib/tools/communications/gmail.test.ts +13 -0
- package/lib/tools/communications/ms-graph.test.ts +26 -3
- package/lib/tools/communications/ms-graph.ts +9 -11
- package/lib/tools/communications/outlook-calendar.ts +94 -17
- package/lib/tools/packages/default-packages/atlassian.ts +8 -2
- package/package.json +2 -1
- package/scripts/standalone-footprint.mjs +1 -1
- /package/.next/standalone/.next/static/{XFZTDssHBZKKX2mzH2ld0 → VZXMorlOmSmi3dUr7K5UX}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{XFZTDssHBZKKX2mzH2ld0 → VZXMorlOmSmi3dUr7K5UX}/_ssgManifest.js +0 -0
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { collectStream } from "./stream-collector";
|
|
3
3
|
import type { StreamChunk } from "./base";
|
|
4
|
+
import { ToolOutcomes } from "./tool-outcomes";
|
|
4
5
|
|
|
5
6
|
async function* fromArray(chunks: StreamChunk[]): AsyncIterable<StreamChunk> {
|
|
6
7
|
for (const c of chunks) yield c;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
describe("collectStream", () => {
|
|
11
|
+
it.each([
|
|
12
|
+
["unresolved", undefined, undefined, [], ["memory_upsert"]],
|
|
13
|
+
["native error", "error", "write failed", [], ["memory_upsert"]],
|
|
14
|
+
["structured failure", "success", { ok: false, error: "write failed" }, [], ["memory_upsert"]],
|
|
15
|
+
["confirmed success", "success", { ok: true }, ["memory_upsert"], ["memory_upsert"]],
|
|
16
|
+
["rejected", "success", { ok: false, status: "rejected" }, [], []],
|
|
17
|
+
])("distinguishes %s from possible state changes", (_name, status, result, successful, possible) => {
|
|
18
|
+
const outcomes = new ToolOutcomes();
|
|
19
|
+
outcomes.observe({ type: "tool_call", data: { id: "write-1", name: "memory_upsert", arguments: {} } });
|
|
20
|
+
if (result !== undefined) outcomes.observe({ type: "tool_result", data: { id: "write-1", name: "memory_upsert", result, status } });
|
|
21
|
+
expect(outcomes.successfulNames()).toEqual(successful);
|
|
22
|
+
expect(outcomes.possiblyChangedNames()).toEqual(possible);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("does not treat a successful proxy envelope as proof that its target succeeded", async () => {
|
|
26
|
+
const out = await collectStream(fromArray([
|
|
27
|
+
{ type: "tool_call", data: { id: "proxy-1", name: "invoke_tool", arguments: { name: "memory_upsert" } } },
|
|
28
|
+
{ type: "tool_result", data: { id: "proxy-1", name: "invoke_tool", result: { ok: true, result: JSON.stringify({ ok: false, error: "not saved" }) } } },
|
|
29
|
+
{ type: "done", data: {} },
|
|
30
|
+
]));
|
|
31
|
+
expect(out.usedTools).toEqual([]);
|
|
32
|
+
});
|
|
33
|
+
|
|
10
34
|
it("accumulates text_delta and returns terminal=done", async () => {
|
|
11
35
|
const out = await collectStream(fromArray([
|
|
12
36
|
{ type: "text_delta", data: { delta: "Hello " } },
|
|
@@ -130,7 +154,7 @@ describe("collectStream", () => {
|
|
|
130
154
|
expect(out.usedTools).toEqual([]);
|
|
131
155
|
});
|
|
132
156
|
|
|
133
|
-
it("
|
|
157
|
+
it("does not treat a proxied call with no result as confirmed success", async () => {
|
|
134
158
|
const out = await collectStream(fromArray([
|
|
135
159
|
{
|
|
136
160
|
type: "tool_call",
|
|
@@ -138,16 +162,16 @@ describe("collectStream", () => {
|
|
|
138
162
|
},
|
|
139
163
|
{ type: "done", data: {} },
|
|
140
164
|
]));
|
|
141
|
-
expect(out.usedTools).toEqual([
|
|
165
|
+
expect(out.usedTools).toEqual([]);
|
|
142
166
|
});
|
|
143
167
|
|
|
144
|
-
it("
|
|
168
|
+
it("excludes failed direct calls from confirmed successes", async () => {
|
|
145
169
|
const out = await collectStream(fromArray([
|
|
146
170
|
{ type: "tool_call", data: { id: "call-1", name: "web_search", arguments: { q: "x" } } },
|
|
147
171
|
{ type: "tool_result", data: { id: "call-1", name: "web_search", result: { ok: false } } },
|
|
148
172
|
{ type: "done", data: {} },
|
|
149
173
|
]));
|
|
150
|
-
expect(out.usedTools).toEqual([
|
|
174
|
+
expect(out.usedTools).toEqual([]);
|
|
151
175
|
});
|
|
152
176
|
|
|
153
177
|
it("does not let one rejected proxied call suppress a different, genuinely successful one", async () => {
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
import type { StreamChunk } from "@/lib/agents/base";
|
|
13
13
|
import type { RouteDecisionMetadata } from "@/api/types";
|
|
14
14
|
import type { PersistedToolEvent } from "@/lib/stores/threads";
|
|
15
|
-
import {
|
|
15
|
+
import type { AssistantUsageSnapshot } from "@/lib/agents/run-thread";
|
|
16
|
+
import { ToolOutcomes } from "./tool-outcomes";
|
|
16
17
|
import { errorMessage } from "@/lib/utils/error";
|
|
17
18
|
|
|
18
19
|
export interface CollectedRun {
|
|
@@ -58,28 +59,15 @@ export async function collectStream(
|
|
|
58
59
|
terminal: "done",
|
|
59
60
|
};
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
// dispatcher, lib/tools/system/invoke-tool.ts), and it never throws — a
|
|
63
|
-
// rejected/errored proxy call still comes back as a normal tool_result.
|
|
64
|
-
// Recording the literal wrapper name in usedTools would make every
|
|
65
|
-
// downstream write-detection check (persistAssistantMessage's stall/
|
|
66
|
-
// fabrication footers, isWriteLikeToolName) treat any proxied call —
|
|
67
|
-
// succeeded or not, read or write — as "a write tool ran". Resolve each
|
|
68
|
-
// call to its real target name, and only count it once its result confirms
|
|
69
|
-
// the underlying call wasn't rejected/errored. A call with no result yet
|
|
70
|
-
// (stream ended mid-call) fails open and is still counted, matching prior
|
|
71
|
-
// behavior for that case.
|
|
72
|
-
const toolCallNames = new Map<string, string>();
|
|
73
|
-
const failedProxyCallIds = new Set<string>();
|
|
62
|
+
const toolOutcomes = new ToolOutcomes();
|
|
74
63
|
const finalizeUsedTools = () => {
|
|
75
|
-
result.usedTools =
|
|
76
|
-
.filter(([id]) => !failedProxyCallIds.has(id))
|
|
77
|
-
.map(([, name]) => name);
|
|
64
|
+
result.usedTools = toolOutcomes.successfulNames();
|
|
78
65
|
};
|
|
79
66
|
|
|
80
67
|
try {
|
|
81
68
|
for await (const chunk of stream) {
|
|
82
69
|
opts.onChunk?.(chunk);
|
|
70
|
+
toolOutcomes.observe(chunk);
|
|
83
71
|
switch (chunk.type) {
|
|
84
72
|
case "text_delta": {
|
|
85
73
|
result.assistantContent += (chunk.data.delta as string) ?? "";
|
|
@@ -95,12 +83,7 @@ export async function collectStream(
|
|
|
95
83
|
case "tool_call": {
|
|
96
84
|
const d = chunk.data as { id?: string; name?: string; arguments?: unknown };
|
|
97
85
|
const rawName = d.name ?? "";
|
|
98
|
-
const args = d.arguments && typeof d.arguments === "object"
|
|
99
|
-
? d.arguments as Record<string, unknown>
|
|
100
|
-
: {};
|
|
101
86
|
const id = d.id ?? `call-${result.toolEvents.length}`;
|
|
102
|
-
const name = unwrapInvokedToolName(rawName, args);
|
|
103
|
-
if (name) toolCallNames.set(id, name);
|
|
104
87
|
result.toolEvents.push({
|
|
105
88
|
id,
|
|
106
89
|
phase: "call",
|
|
@@ -112,12 +95,6 @@ export async function collectStream(
|
|
|
112
95
|
case "tool_result": {
|
|
113
96
|
const d = chunk.data as { id?: string; name?: string; result?: unknown };
|
|
114
97
|
const id = d.id ?? `result-${result.toolEvents.length}`;
|
|
115
|
-
if (d.name === "invoke_tool") {
|
|
116
|
-
const payload = d.result as { ok?: unknown } | null | undefined;
|
|
117
|
-
if (payload && typeof payload === "object" && payload.ok === false) {
|
|
118
|
-
failedProxyCallIds.add(id);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
98
|
result.toolEvents.push({
|
|
122
99
|
id,
|
|
123
100
|
phase: "result",
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { StreamChunk } from "./base";
|
|
2
|
+
|
|
3
|
+
type Outcome = "pending" | "succeeded" | "failed" | "rejected";
|
|
4
|
+
type ToolCall = { name: string; outcome: Outcome };
|
|
5
|
+
|
|
6
|
+
function resultRecord(value: unknown): Record<string, unknown> | null {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
try { value = JSON.parse(value); } catch { return null; }
|
|
9
|
+
}
|
|
10
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
11
|
+
? value as Record<string, unknown>
|
|
12
|
+
: null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function failed(result: Record<string, unknown> | null): boolean {
|
|
16
|
+
return !!result && (result.ok === false || result.success === false
|
|
17
|
+
|| result.isError === true || result.is_error === true
|
|
18
|
+
|| result.status === "error" || result.status === "failed"
|
|
19
|
+
|| (result.error !== undefined && result.error !== null && result.error !== false && result.error !== ""));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function unwrapInvokedToolName(name: string, args: Record<string, unknown>): string {
|
|
23
|
+
if (name !== "invoke_tool") return name;
|
|
24
|
+
const target = args.name;
|
|
25
|
+
return typeof target === "string" && target.trim() ? target.trim() : name;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class ToolOutcomes {
|
|
29
|
+
private readonly calls = new Map<string, ToolCall>();
|
|
30
|
+
|
|
31
|
+
observe(chunk: StreamChunk): void {
|
|
32
|
+
const data = chunk.data;
|
|
33
|
+
if (typeof data.id !== "string") return;
|
|
34
|
+
if (chunk.type === "tool_call") {
|
|
35
|
+
const args = resultRecord(data.arguments) ?? {};
|
|
36
|
+
const name = unwrapInvokedToolName(typeof data.name === "string" ? data.name : "", args);
|
|
37
|
+
if (name) this.calls.set(data.id, { name, outcome: "pending" });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (chunk.type !== "tool_result") return;
|
|
41
|
+
const call = this.calls.get(data.id);
|
|
42
|
+
if (!call) return;
|
|
43
|
+
const result = resultRecord(data.result);
|
|
44
|
+
if (result?.status === "rejected" || result?.status === "blocked") {
|
|
45
|
+
call.outcome = "rejected";
|
|
46
|
+
} else if (data.status === "error" || failed(result)
|
|
47
|
+
|| (data.name === "invoke_tool" && failed(resultRecord(result?.result)))) {
|
|
48
|
+
call.outcome = "failed";
|
|
49
|
+
} else {
|
|
50
|
+
call.outcome = "succeeded";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
successfulNames(): string[] {
|
|
55
|
+
return [...this.calls.values()].filter((call) => call.outcome === "succeeded").map((call) => call.name);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
possiblyChangedNames(): string[] {
|
|
59
|
+
return [...this.calls.values()].filter((call) => call.outcome !== "rejected").map((call) => call.name);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
const mocks = vi.hoisted(() => ({
|
|
4
|
+
atlassianFetch: vi.fn(),
|
|
5
|
+
updateDocumentSourceCursor: vi.fn(),
|
|
6
|
+
upsertRemoteDocument: vi.fn(),
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
vi.mock("@/lib/tools/runtime/auth-registry", () => ({
|
|
10
|
+
resolvePackageAuth: () => ({
|
|
11
|
+
url: "https://example.atlassian.net",
|
|
12
|
+
email: "test@example.com",
|
|
13
|
+
apiToken: "test-token",
|
|
14
|
+
}),
|
|
15
|
+
}));
|
|
16
|
+
vi.mock("@/lib/tools/packages/optional-package", () => ({
|
|
17
|
+
optionalFunction: () => (...args: unknown[]) => mocks.atlassianFetch(...args),
|
|
18
|
+
}));
|
|
19
|
+
vi.mock("@/lib/stores/document-sources", () => ({
|
|
20
|
+
parseSourceConfig: (source: { config?: unknown }) => source.config,
|
|
21
|
+
updateDocumentSourceCursor: mocks.updateDocumentSourceCursor,
|
|
22
|
+
}));
|
|
23
|
+
vi.mock("./upsert", () => ({
|
|
24
|
+
upsertRemoteDocument: mocks.upsertRemoteDocument,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
import { runConfluenceIndexer } from "./confluence";
|
|
28
|
+
|
|
29
|
+
describe("runConfluenceIndexer pagination", () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.clearAllMocks();
|
|
32
|
+
mocks.upsertRemoteDocument.mockResolvedValue({
|
|
33
|
+
status: "added", chunks: 1, embedded: 1, embedError: null,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("uses the documented search endpoint and follows its next cursor", async () => {
|
|
38
|
+
mocks.atlassianFetch
|
|
39
|
+
.mockResolvedValueOnce({
|
|
40
|
+
results: [{ content: { id: "page-1", title: "First", version: { when: "2026-01-01T00:00:00Z" } } }],
|
|
41
|
+
_links: { next: "/wiki/rest/api/search?cursor=next%2Fpage" },
|
|
42
|
+
})
|
|
43
|
+
.mockResolvedValueOnce({
|
|
44
|
+
results: [{ content: { id: "page-2", title: "Second", version: { when: "2026-01-02T00:00:00Z" } } }],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const result = await runConfluenceIndexer({
|
|
48
|
+
id: "source-1",
|
|
49
|
+
kind: "confluence_space",
|
|
50
|
+
config: { space_key: "ENG" },
|
|
51
|
+
last_cursor: null,
|
|
52
|
+
} as never);
|
|
53
|
+
|
|
54
|
+
expect(mocks.atlassianFetch).toHaveBeenCalledTimes(2);
|
|
55
|
+
const firstPath = mocks.atlassianFetch.mock.calls[0][1] as string;
|
|
56
|
+
const secondPath = mocks.atlassianFetch.mock.calls[1][1] as string;
|
|
57
|
+
expect(firstPath).toContain("/wiki/rest/api/search?");
|
|
58
|
+
expect(new URLSearchParams(firstPath.split("?")[1]).get("expand")).toBe(
|
|
59
|
+
"content.body.storage,content.version,content.history.lastUpdated",
|
|
60
|
+
);
|
|
61
|
+
expect(new URLSearchParams(secondPath.split("?")[1]).get("cursor")).toBe("next/page");
|
|
62
|
+
expect(result.scanned).toBe(2);
|
|
63
|
+
expect(mocks.updateDocumentSourceCursor).toHaveBeenCalledWith("source-1", "2026-01-02T00:00:00Z");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { htmlToText } from "./flatten";
|
|
18
18
|
import { upsertRemoteDocument, type UpsertResult } from "./upsert";
|
|
19
19
|
|
|
20
|
-
interface AtlassianAuth { url: string; email: string; apiToken: string }
|
|
20
|
+
interface AtlassianAuth { url: string; email: string; apiToken: string; cloudId?: string }
|
|
21
21
|
const atlassianFetch = optionalFunction<(auth: AtlassianAuth, path: string, init?: RequestInit) => Promise<unknown>>(
|
|
22
22
|
"@circuitwall/atlassian-langchain",
|
|
23
23
|
"atlassianFetch",
|
|
@@ -35,9 +35,12 @@ interface ConfluencePage {
|
|
|
35
35
|
body?: { storage?: { value?: string } };
|
|
36
36
|
_links?: { webui?: string };
|
|
37
37
|
}
|
|
38
|
+
interface ConfluenceSearchResult {
|
|
39
|
+
content?: ConfluencePage;
|
|
40
|
+
}
|
|
38
41
|
interface ConfluenceSearchResp {
|
|
39
|
-
results?:
|
|
40
|
-
|
|
42
|
+
results?: ConfluenceSearchResult[];
|
|
43
|
+
_links?: { next?: string };
|
|
41
44
|
size?: number;
|
|
42
45
|
limit?: number;
|
|
43
46
|
}
|
|
@@ -98,19 +101,34 @@ export async function runConfluenceIndexer(source: DocumentSourceRow): Promise<C
|
|
|
98
101
|
if ("error" in auth) throw new Error(auth.error);
|
|
99
102
|
|
|
100
103
|
const cql = buildCql(source, source.last_cursor);
|
|
101
|
-
let
|
|
104
|
+
let cursor: string | undefined;
|
|
105
|
+
const seenCursors = new Set<string>();
|
|
102
106
|
let highWater = source.last_cursor;
|
|
103
107
|
|
|
104
108
|
while (stats.scanned < MAX_PAGES_PER_RUN) {
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
if (cursor) {
|
|
110
|
+
if (seenCursors.has(cursor)) break;
|
|
111
|
+
seenCursors.add(cursor);
|
|
112
|
+
}
|
|
113
|
+
const params = new URLSearchParams({
|
|
114
|
+
cql,
|
|
115
|
+
expand: "content.body.storage,content.version,content.history.lastUpdated",
|
|
116
|
+
limit: String(PAGE_LIMIT),
|
|
117
|
+
});
|
|
118
|
+
if (cursor) params.set("cursor", cursor);
|
|
119
|
+
const url = `/wiki/rest/api/search?${params}`;
|
|
107
120
|
const data = await atlassianFetch(auth, url) as ConfluenceSearchResp & { error?: string };
|
|
108
121
|
if ((data as { error?: string }).error) throw new Error((data as { error?: string }).error);
|
|
109
122
|
const results = data.results ?? [];
|
|
110
123
|
if (results.length === 0) break;
|
|
111
124
|
|
|
112
|
-
for (const
|
|
125
|
+
for (const result of results) {
|
|
113
126
|
stats.scanned++;
|
|
127
|
+
const page = result.content;
|
|
128
|
+
if (!page?.id || !page.title) {
|
|
129
|
+
stats.errors++;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
114
132
|
try {
|
|
115
133
|
const text = `${page.title}\n\n${htmlToText(page.body?.storage?.value ?? "")}`.trim();
|
|
116
134
|
const updatedAt = pageUpdatedAt(page);
|
|
@@ -130,8 +148,16 @@ export async function runConfluenceIndexer(source: DocumentSourceRow): Promise<C
|
|
|
130
148
|
stats.errors++;
|
|
131
149
|
}
|
|
132
150
|
}
|
|
133
|
-
|
|
134
|
-
if (
|
|
151
|
+
const next = data._links?.next;
|
|
152
|
+
if (!next) break;
|
|
153
|
+
let nextCursor: string | null = null;
|
|
154
|
+
try {
|
|
155
|
+
nextCursor = new URL(next, auth.url).searchParams.get("cursor");
|
|
156
|
+
} catch {
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (!nextCursor || seenCursors.has(nextCursor)) break;
|
|
160
|
+
cursor = nextCursor;
|
|
135
161
|
}
|
|
136
162
|
|
|
137
163
|
if (highWater && highWater !== source.last_cursor) {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import { adfToText } from "./flatten";
|
|
19
19
|
import { upsertRemoteDocument, type UpsertResult } from "./upsert";
|
|
20
20
|
|
|
21
|
-
interface AtlassianAuth { url: string; email: string; apiToken: string }
|
|
21
|
+
interface AtlassianAuth { url: string; email: string; apiToken: string; cloudId?: string }
|
|
22
22
|
const atlassianFetch = optionalFunction<(auth: AtlassianAuth, path: string, init?: RequestInit) => Promise<unknown>>(
|
|
23
23
|
"@circuitwall/atlassian-langchain",
|
|
24
24
|
"atlassianFetch",
|
|
@@ -46,6 +46,7 @@ function wipe(): void {
|
|
|
46
46
|
delete process.env.ATLASSIAN_URL;
|
|
47
47
|
delete process.env.ATLASSIAN_EMAIL;
|
|
48
48
|
delete process.env.ATLASSIAN_API_TOKEN;
|
|
49
|
+
delete process.env.ATLASSIAN_CLOUD_ID;
|
|
49
50
|
delete process.env.GITHUB_TOKEN;
|
|
50
51
|
delete process.env.GH_TOKEN;
|
|
51
52
|
delete process.env.JIRA_ALIGN_URL;
|
|
@@ -124,6 +125,37 @@ describe("health probes", () => {
|
|
|
124
125
|
mockFetch(() => new Response("boom", { status: 500 }));
|
|
125
126
|
expect((await probeAtlassian()).status).toBe("error");
|
|
126
127
|
});
|
|
128
|
+
it("checks both products and routes scoped tokens to each product gateway", async () => {
|
|
129
|
+
saveIntegration("atlassian", {
|
|
130
|
+
url: "https://example.atlassian.net", email: "a@b", api_token: "ok", cloud_id: "cloud-123",
|
|
131
|
+
});
|
|
132
|
+
const urls: string[] = [];
|
|
133
|
+
mockFetch((input) => {
|
|
134
|
+
urls.push(String(input));
|
|
135
|
+
return jsonResponse(urls.length === 1
|
|
136
|
+
? { displayName: "Test", emailAddress: "a@b", accountId: "x" }
|
|
137
|
+
: { results: [] });
|
|
138
|
+
});
|
|
139
|
+
const result = await probeAtlassian();
|
|
140
|
+
expect(result.status).toBe("ok");
|
|
141
|
+
expect(result.detail?.confluenceAccess).toBe(true);
|
|
142
|
+
expect(urls).toEqual([
|
|
143
|
+
"https://api.atlassian.com/ex/jira/cloud-123/rest/api/3/myself",
|
|
144
|
+
"https://api.atlassian.com/ex/confluence/cloud-123/wiki/api/v2/spaces?limit=1",
|
|
145
|
+
]);
|
|
146
|
+
});
|
|
147
|
+
it("does not report healthy when Confluence access is denied", async () => {
|
|
148
|
+
let requestCount = 0;
|
|
149
|
+
mockFetch(() => {
|
|
150
|
+
requestCount++;
|
|
151
|
+
return requestCount === 1
|
|
152
|
+
? jsonResponse({ displayName: "Test", emailAddress: "a@b", accountId: "x" })
|
|
153
|
+
: new Response("forbidden", { status: 403 });
|
|
154
|
+
});
|
|
155
|
+
const result = await probeAtlassian();
|
|
156
|
+
expect(result.status).toBe("auth_failed");
|
|
157
|
+
expect(result.error).toMatch(/Confluence/);
|
|
158
|
+
});
|
|
127
159
|
});
|
|
128
160
|
|
|
129
161
|
describe("jira_align", () => {
|
package/lib/health/probes.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { resolvePackageAuth } from "@/lib/tools/runtime/auth-registry";
|
|
13
13
|
import { spawnSync } from "node:child_process";
|
|
14
14
|
|
|
15
|
-
type AtlassianAuth = { url: string; email: string; apiToken: string };
|
|
15
|
+
type AtlassianAuth = { url: string; email: string; apiToken: string; cloudId?: string };
|
|
16
16
|
type GitHubAuth = { token: string };
|
|
17
17
|
type JiraAlignAuth = { url: string; apiToken: string };
|
|
18
18
|
// Trigger registration of the default LangChain package auth resolvers
|
|
@@ -104,23 +104,38 @@ export async function probeAtlassian(): Promise<HealthResult> {
|
|
|
104
104
|
const auth = resolvePackageAuth<AtlassianAuth>("atlassian");
|
|
105
105
|
if ("error" in auth) return unconfigured(auth.error);
|
|
106
106
|
try {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const authHeaders = {
|
|
108
|
+
Authorization: "Basic " + Buffer.from(`${auth.email}:${auth.apiToken}`).toString("base64"),
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
};
|
|
111
|
+
const productUrl = (product: "jira" | "confluence", path: string) => auth.cloudId
|
|
112
|
+
? `https://api.atlassian.com/ex/${product}/${encodeURIComponent(auth.cloudId)}${path}`
|
|
113
|
+
: `${auth.url.replace(/\/+$/, "")}${path}`;
|
|
114
|
+
const jiraRes = await fetch(productUrl("jira", "/rest/api/3/myself"), {
|
|
115
|
+
headers: authHeaders,
|
|
112
116
|
signal: probeSignal(DEFAULT_PROBE_TIMEOUT_MS),
|
|
113
117
|
});
|
|
114
|
-
if (
|
|
115
|
-
|
|
118
|
+
if (jiraRes.status === 401) return authFailed("Jira rejected the Atlassian API token. Check the email, token, and token expiry.");
|
|
119
|
+
if (jiraRes.status === 403) return authFailed("Jira API access is forbidden. Check the token's Jira scopes and the account's site access.");
|
|
120
|
+
if (jiraRes.status === 429) return transient("Jira rate-limited the Atlassian probe (429).");
|
|
121
|
+
if (!jiraRes.ok) {
|
|
122
|
+
const body = await jiraRes.text().catch(() => "");
|
|
123
|
+
return probeError(`Jira ${jiraRes.status}: ${body.slice(0, 200)}`);
|
|
116
124
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
const me = await readJsonResponse<{ displayName?: string; emailAddress?: string; accountId?: string }>(jiraRes);
|
|
126
|
+
|
|
127
|
+
const confluenceRes = await fetch(productUrl("confluence", "/wiki/api/v2/spaces?limit=1"), {
|
|
128
|
+
headers: authHeaders,
|
|
129
|
+
signal: probeSignal(DEFAULT_PROBE_TIMEOUT_MS),
|
|
130
|
+
});
|
|
131
|
+
if (confluenceRes.status === 401) return authFailed("Confluence rejected the Atlassian API token. Check the token's Confluence scopes and expiry.");
|
|
132
|
+
if (confluenceRes.status === 403) return authFailed("Confluence API access is forbidden. Check the token's Confluence scopes and the account's site access.");
|
|
133
|
+
if (confluenceRes.status === 429) return transient("Confluence rate-limited the Atlassian probe (429).");
|
|
134
|
+
if (!confluenceRes.ok) {
|
|
135
|
+
const body = await confluenceRes.text().catch(() => "");
|
|
136
|
+
return probeError(`Confluence ${confluenceRes.status}: ${body.slice(0, 200)}`);
|
|
121
137
|
}
|
|
122
|
-
|
|
123
|
-
return ok({ displayName: me.displayName, email: me.emailAddress, accountId: me.accountId });
|
|
138
|
+
return ok({ displayName: me.displayName, email: me.emailAddress, accountId: me.accountId, confluenceAccess: true });
|
|
124
139
|
} catch (err) {
|
|
125
140
|
return transient(describeError(err));
|
|
126
141
|
}
|
|
@@ -20,8 +20,9 @@ export const atlassianManifest: IntegrationManifest = {
|
|
|
20
20
|
check: "credentials",
|
|
21
21
|
detail:
|
|
22
22
|
"An API token created at id.atlassian.com → Security → API tokens. " +
|
|
23
|
-
"The token is bound to your account email — you'll provide both."
|
|
24
|
-
|
|
23
|
+
"The token is bound to your account email — you'll provide both. For a scoped token, " +
|
|
24
|
+
"also provide the Atlassian Cloud ID so Jira and Confluence use their product API gateways.",
|
|
25
|
+
docs_url: "https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",
|
|
25
26
|
},
|
|
26
27
|
],
|
|
27
28
|
steps: [
|
|
@@ -38,7 +39,8 @@ export const atlassianManifest: IntegrationManifest = {
|
|
|
38
39
|
title: "Save the credentials in Jarela",
|
|
39
40
|
description:
|
|
40
41
|
"Propose enabling the integration. The user will be asked for the site URL, " +
|
|
41
|
-
"their account email, and the API token.
|
|
42
|
+
"their account email, and the API token. Scoped tokens also need the Cloud ID. " +
|
|
43
|
+
"The token is stored encrypted at rest.",
|
|
42
44
|
proposes: "enable_integration",
|
|
43
45
|
},
|
|
44
46
|
{
|
|
@@ -19,8 +19,10 @@ export const githubManifest: IntegrationManifest = {
|
|
|
19
19
|
check: "credentials",
|
|
20
20
|
detail:
|
|
21
21
|
"A Personal Access Token (classic or fine-grained) created at github.com/settings/tokens. " +
|
|
22
|
-
"
|
|
23
|
-
|
|
22
|
+
"Classic tokens need `repo` (or `public_repo` for public-only). Fine-grained tokens need " +
|
|
23
|
+
"Contents: read, Issues: read/write, and Pull requests: read/write on the selected repositories. " +
|
|
24
|
+
"`read:org` is only needed for organization-specific operations such as team reviewer lookup.",
|
|
25
|
+
docs_url: "https://docs.github.com/en/rest/overview/permissions-required-for-fine-grained-personal-access-tokens",
|
|
24
26
|
},
|
|
25
27
|
],
|
|
26
28
|
steps: [
|
|
@@ -29,8 +31,9 @@ export const githubManifest: IntegrationManifest = {
|
|
|
29
31
|
title: "Create a GitHub Personal Access Token",
|
|
30
32
|
description:
|
|
31
33
|
"Open github.com/settings/tokens → Generate new token. For classic tokens, tick `repo` (or " +
|
|
32
|
-
"`public_repo` for public repos only)
|
|
33
|
-
"
|
|
34
|
+
"`public_repo` for public repos only); add `read:org` only if you need organization team reviewer " +
|
|
35
|
+
"lookup. For fine-grained tokens, pick the repos and grant Contents: Read-only, Issues: Read+Write, " +
|
|
36
|
+
"and Pull requests: Read+Write. Copy the token immediately — GitHub only " +
|
|
34
37
|
"shows it once.",
|
|
35
38
|
docs_url: "https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens",
|
|
36
39
|
},
|
|
@@ -286,9 +286,24 @@ export async function googleFetch(
|
|
|
286
286
|
path: string,
|
|
287
287
|
init?: RequestInit,
|
|
288
288
|
): Promise<Record<string, unknown>> {
|
|
289
|
+
let target: URL;
|
|
290
|
+
try {
|
|
291
|
+
target = path.startsWith("http") ? new URL(path) : new URL(`${baseUrl}${path}`);
|
|
292
|
+
} catch {
|
|
293
|
+
return { error: `${service} request URL is invalid.` };
|
|
294
|
+
}
|
|
295
|
+
let base: URL;
|
|
296
|
+
try {
|
|
297
|
+
base = new URL(baseUrl);
|
|
298
|
+
} catch {
|
|
299
|
+
return { error: `${service} API base URL is invalid.` };
|
|
300
|
+
}
|
|
301
|
+
if (target.origin !== base.origin || target.username || target.password) {
|
|
302
|
+
return { error: `${service} requests must target ${base.hostname}; refusing to forward credentials.` };
|
|
303
|
+
}
|
|
304
|
+
const url = target.toString();
|
|
289
305
|
const token = await getGoogleAccessToken(auth);
|
|
290
306
|
if (typeof token !== "string") return token;
|
|
291
|
-
const url = path.startsWith("http") ? path : `${baseUrl}${path}`;
|
|
292
307
|
try {
|
|
293
308
|
const res = await fetch(url, {
|
|
294
309
|
...init,
|
|
@@ -41,6 +41,8 @@ const TENANT = process.env.OUTLOOK_TENANT?.trim() || "common";
|
|
|
41
41
|
// - Mail.ReadWrite → search/read mail, create drafts, mark read,
|
|
42
42
|
// move to folders (incl. DeletedItems).
|
|
43
43
|
// - Mail.Send → send mail when the user explicitly asks for it.
|
|
44
|
+
// - Files.Read.All → Microsoft Search over OneDrive/SharePoint files.
|
|
45
|
+
// - Sites.Read.All → Microsoft Search over SharePoint lists and sites.
|
|
44
46
|
// - Calendars.ReadWrite → list/get/create/update/delete events on the
|
|
45
47
|
// user's existing calendars.
|
|
46
48
|
// - Tasks.ReadWrite → list/get/create/update/complete/delete Microsoft
|
|
@@ -52,6 +54,8 @@ export const MICROSOFT_SCOPES = [
|
|
|
52
54
|
"User.Read",
|
|
53
55
|
"Mail.ReadWrite",
|
|
54
56
|
"Mail.Send",
|
|
57
|
+
"Files.Read.All",
|
|
58
|
+
"Sites.Read.All",
|
|
55
59
|
"Calendars.ReadWrite",
|
|
56
60
|
"Tasks.ReadWrite",
|
|
57
61
|
"People.Read",
|
|
@@ -210,7 +214,7 @@ const SCOPE_HINTS: Array<{ prefix: string; scope: string }> = [
|
|
|
210
214
|
{ prefix: "/me/contacts", scope: "Contacts.Read" },
|
|
211
215
|
{ prefix: "/me/drive", scope: "Files.Read" },
|
|
212
216
|
{ prefix: "/me/insights", scope: "Sites.Read.All" },
|
|
213
|
-
{ prefix: "/search/query", scope: "Mail.Read Files.Read.All" },
|
|
217
|
+
{ prefix: "/search/query", scope: "Mail.Read / Calendars.Read for mail and events; Files.Read.All for files; Sites.Read.All for lists and sites" },
|
|
214
218
|
{ prefix: "/me", scope: "User.Read" },
|
|
215
219
|
];
|
|
216
220
|
|
|
@@ -252,7 +256,18 @@ export async function graphFetch(
|
|
|
252
256
|
path: string,
|
|
253
257
|
init?: RequestInit,
|
|
254
258
|
): Promise<unknown> {
|
|
255
|
-
|
|
259
|
+
let target: URL;
|
|
260
|
+
try {
|
|
261
|
+
target = path.startsWith("http")
|
|
262
|
+
? new URL(path)
|
|
263
|
+
: new URL(`https://graph.microsoft.com/v1.0${path}`);
|
|
264
|
+
} catch {
|
|
265
|
+
return { error: "Microsoft Graph request URL is invalid." };
|
|
266
|
+
}
|
|
267
|
+
if (target.origin !== "https://graph.microsoft.com" || target.username || target.password) {
|
|
268
|
+
return { error: "Microsoft Graph requests must target graph.microsoft.com; refusing to forward credentials." };
|
|
269
|
+
}
|
|
270
|
+
const url = target.toString();
|
|
256
271
|
let attempt = 0;
|
|
257
272
|
let triedReauth = false;
|
|
258
273
|
|
|
@@ -4,19 +4,20 @@ export const outlookManifest: IntegrationManifest = {
|
|
|
4
4
|
id: "outlook",
|
|
5
5
|
name: "Outlook + Microsoft Calendar + To Do",
|
|
6
6
|
summary:
|
|
7
|
-
"Lets the agent search/read mail, create drafts
|
|
7
|
+
"Lets the agent search/read mail, create drafts, and send mail when explicitly asked, move messages between " +
|
|
8
8
|
"folders, read or modify Microsoft 365 calendar events, and manage Microsoft To Do " +
|
|
9
|
-
"task lists and tasks.
|
|
10
|
-
"send mail on the user's behalf.",
|
|
9
|
+
"task lists and tasks.",
|
|
11
10
|
category: "mail",
|
|
12
11
|
prerequisites: [
|
|
13
12
|
{
|
|
14
13
|
check: "oauth_app",
|
|
15
14
|
detail:
|
|
16
|
-
"An Azure app registration with delegated Mail.ReadWrite, Calendars.ReadWrite, " +
|
|
17
|
-
"Tasks.ReadWrite,
|
|
18
|
-
"
|
|
19
|
-
|
|
15
|
+
"An Azure app registration with delegated Mail.ReadWrite, Mail.Send, Calendars.ReadWrite, " +
|
|
16
|
+
"Tasks.ReadWrite, People.Read, Files.Read.All, Sites.Read.All, User.Read, and offline_access " +
|
|
17
|
+
"permissions. Files.Read.All and Sites.Read.All enable Microsoft Search across OneDrive/SharePoint. " +
|
|
18
|
+
"Mail, calendar, and To Do work with personal and M365 accounts; Microsoft Search requires a " +
|
|
19
|
+
"work/school account. Both account types are supported via the 'common' tenant.",
|
|
20
|
+
docs_url: "https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0",
|
|
20
21
|
},
|
|
21
22
|
{
|
|
22
23
|
check: "custom",
|
|
@@ -47,7 +48,8 @@ export const outlookManifest: IntegrationManifest = {
|
|
|
47
48
|
title: "Grant the required Graph permissions",
|
|
48
49
|
description:
|
|
49
50
|
"API permissions → Add a permission → Microsoft Graph → Delegated permissions. " +
|
|
50
|
-
"Add Mail.ReadWrite, Calendars.ReadWrite, Tasks.ReadWrite,
|
|
51
|
+
"Add Mail.ReadWrite, Mail.Send, Calendars.ReadWrite, Tasks.ReadWrite, People.Read, " +
|
|
52
|
+
"Files.Read.All, Sites.Read.All, User.Read, offline_access. " +
|
|
51
53
|
"No admin consent required for personal accounts; M365 tenants may need an admin to consent.",
|
|
52
54
|
},
|
|
53
55
|
{
|
|
@@ -93,6 +93,7 @@ export const INTEGRATIONS = {
|
|
|
93
93
|
description: "Used by jira_* and confluence_* tools. Get an API token at id.atlassian.com → Security → API tokens.",
|
|
94
94
|
fields: [
|
|
95
95
|
{ key: "url", label: "Site URL", placeholder: "https://your-team.atlassian.net", secret: false, required: true },
|
|
96
|
+
{ key: "cloud_id", label: "Cloud ID (scoped API tokens only)", placeholder: "UUID from your Atlassian cloudId", secret: false, required: false },
|
|
96
97
|
{ key: "email", label: "Account email", placeholder: "you@company.com", secret: false, required: true },
|
|
97
98
|
{ key: "api_token", label: "API token", placeholder: "ATATT3xFfGF0…", secret: true, required: true },
|
|
98
99
|
],
|