@sentry/junior 0.90.0 → 0.92.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.
Files changed (131) hide show
  1. package/dist/{agent-hooks-MXAF7RQL.js → agent-hooks-BYSSWCNW.js} +7 -7
  2. package/dist/api/people/list.d.ts +3 -3
  3. package/dist/api/people/list.js +15 -15
  4. package/dist/api/people/list.query.d.ts +2 -2
  5. package/dist/api/people/profile.d.ts +3 -3
  6. package/dist/api/people/profile.js +12 -12
  7. package/dist/api/people/profile.query.d.ts +2 -2
  8. package/dist/api/people/shared.d.ts +13 -13
  9. package/dist/api/people/types.d.ts +12 -12
  10. package/dist/api-reference.d.ts +1 -1
  11. package/dist/app.js +406 -267
  12. package/dist/{catalog-runtime-DXE6NXHT.js → catalog-runtime-NZHMSMYC.js} +2 -2
  13. package/dist/chat/actor.d.ts +75 -0
  14. package/dist/chat/agent/prompt.d.ts +4 -4
  15. package/dist/chat/agent/request.d.ts +21 -13
  16. package/dist/chat/agent/resume.d.ts +5 -4
  17. package/dist/chat/agent/tools.d.ts +2 -2
  18. package/dist/chat/capabilities/jr-rpc-command.d.ts +1 -1
  19. package/dist/chat/conversation-privacy.d.ts +11 -0
  20. package/dist/chat/conversations/sql/migrations.d.ts +1 -1
  21. package/dist/chat/conversations/sql/schema/conversations.d.ts +2 -19
  22. package/dist/chat/conversations/sql/schema.d.ts +2 -19
  23. package/dist/chat/conversations/sql/store.d.ts +3 -3
  24. package/dist/chat/conversations/store.d.ts +4 -4
  25. package/dist/chat/credentials/context.d.ts +4 -4
  26. package/dist/chat/current-instruction.d.ts +5 -3
  27. package/dist/chat/logging.d.ts +2 -2
  28. package/dist/chat/no-reply.d.ts +1 -1
  29. package/dist/chat/oauth-authorization-message.d.ts +6 -0
  30. package/dist/chat/oauth-flow.d.ts +1 -1
  31. package/dist/chat/pi/messages.d.ts +2 -2
  32. package/dist/chat/pi/transcript.d.ts +15 -0
  33. package/dist/chat/plugins/agent-hooks.d.ts +3 -3
  34. package/dist/chat/plugins/credential-hooks.d.ts +2 -8
  35. package/dist/chat/prompt.d.ts +3 -6
  36. package/dist/chat/runtime/reply-executor.d.ts +1 -1
  37. package/dist/chat/runtime/turn-input.d.ts +1 -1
  38. package/dist/chat/sandbox/egress/schemas.d.ts +2 -2
  39. package/dist/chat/sandbox/egress/session.d.ts +1 -1
  40. package/dist/chat/services/context-compaction.d.ts +1 -1
  41. package/dist/chat/services/conversation-memory.d.ts +1 -1
  42. package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
  43. package/dist/chat/services/message-actor-identity.d.ts +4 -4
  44. package/dist/chat/services/pending-auth.d.ts +2 -2
  45. package/dist/chat/services/plugin-auth-orchestration.d.ts +1 -1
  46. package/dist/chat/services/provider-default-config.d.ts +1 -1
  47. package/dist/chat/services/subscribed-decision.d.ts +1 -1
  48. package/dist/chat/services/turn-result.d.ts +1 -1
  49. package/dist/chat/services/turn-session-record.d.ts +11 -8
  50. package/dist/chat/services/turn-thinking-level.d.ts +1 -1
  51. package/dist/chat/slack/assistant-thread/title.d.ts +1 -1
  52. package/dist/chat/slack/mrkdwn.d.ts +6 -0
  53. package/dist/chat/slack/tools/canvas/create.d.ts +41 -1
  54. package/dist/chat/slack/tools/canvas/edit.d.ts +60 -1
  55. package/dist/chat/slack/tools/canvas/read.d.ts +60 -1
  56. package/dist/chat/slack/tools/canvas/write.d.ts +41 -1
  57. package/dist/chat/slack/tools/channel-list-messages.d.ts +45 -1
  58. package/dist/chat/slack/tools/context.d.ts +3 -3
  59. package/dist/chat/slack/tools/list/add-items.d.ts +42 -1
  60. package/dist/chat/slack/tools/list/create.d.ts +40 -1
  61. package/dist/chat/slack/tools/list/get-items.d.ts +40 -1
  62. package/dist/chat/slack/tools/list/update-item.d.ts +46 -1
  63. package/dist/chat/slack/tools/message-add-reaction.d.ts +40 -1
  64. package/dist/chat/slack/tools/send-message.d.ts +45 -1
  65. package/dist/chat/slack/tools/thread-read.d.ts +44 -1
  66. package/dist/chat/slack/tools/user-lookup.d.ts +45 -1
  67. package/dist/chat/slack/user.d.ts +3 -3
  68. package/dist/chat/slack/vision-context.d.ts +2 -2
  69. package/dist/chat/sql/schema.d.ts +2 -19
  70. package/dist/chat/state/conversation-details.d.ts +4 -4
  71. package/dist/chat/state/conversation.d.ts +1 -1
  72. package/dist/chat/state/session-log.d.ts +140 -26
  73. package/dist/chat/state/turn-session.d.ts +18 -5
  74. package/dist/chat/task-execution/slack-work.d.ts +2 -2
  75. package/dist/chat/task-execution/state.d.ts +4 -4
  76. package/dist/chat/tool-support/zod-tool.d.ts +16 -4
  77. package/dist/chat/tools/advisor/tool.d.ts +41 -1
  78. package/dist/chat/tools/definition.d.ts +10 -0
  79. package/dist/chat/tools/execute-tool.d.ts +41 -1
  80. package/dist/chat/tools/resource-events.d.ts +124 -3
  81. package/dist/chat/tools/runtime/report-progress.d.ts +40 -1
  82. package/dist/chat/tools/sandbox/bash.d.ts +41 -1
  83. package/dist/chat/tools/sandbox/edit-file.d.ts +44 -1
  84. package/dist/chat/tools/sandbox/find-files.d.ts +42 -1
  85. package/dist/chat/tools/sandbox/grep.d.ts +46 -1
  86. package/dist/chat/tools/sandbox/list-dir.d.ts +41 -1
  87. package/dist/chat/tools/sandbox/read-file.d.ts +42 -1
  88. package/dist/chat/tools/sandbox/write-file.d.ts +41 -1
  89. package/dist/chat/tools/search-tools.d.ts +102 -1
  90. package/dist/chat/tools/skill/call-mcp-tool.d.ts +10 -1
  91. package/dist/chat/tools/skill/load-skill.d.ts +40 -1
  92. package/dist/chat/tools/skill/search-mcp-tools.d.ts +100 -1
  93. package/dist/chat/tools/system-time.d.ts +38 -1
  94. package/dist/chat/tools/types.d.ts +4 -4
  95. package/dist/chat/tools/web/fetch-tool.d.ts +41 -1
  96. package/dist/chat/tools/web/image-generate.d.ts +62 -1
  97. package/dist/chat/tools/web/search.d.ts +41 -1
  98. package/dist/{chunk-HXL2ZV74.js → chunk-3F54A3YM.js} +82 -11
  99. package/dist/{chunk-BKSZL4QO.js → chunk-7DVIELX3.js} +670 -401
  100. package/dist/{chunk-GCWD2VHP.js → chunk-7FS3K243.js} +284 -124
  101. package/dist/{chunk-AOISHLSF.js → chunk-ACJENBVF.js} +143 -20
  102. package/dist/{chunk-IRRMABQD.js → chunk-APIVR44P.js} +10 -10
  103. package/dist/{chunk-PHZHJTCK.js → chunk-BMQ5DXHV.js} +30 -52
  104. package/dist/{chunk-XP7F4LYB.js → chunk-BTH37NCU.js} +4 -4
  105. package/dist/{chunk-5GBUZI6M.js → chunk-H7KUZAMZ.js} +4 -4
  106. package/dist/{chunk-TYUXD3FN.js → chunk-MC4ZZE4Q.js} +1 -1
  107. package/dist/{chunk-QCKGI74V.js → chunk-N25HRI6B.js} +10 -10
  108. package/dist/{chunk-2S7M37HY.js → chunk-NIFONS4W.js} +86 -47
  109. package/dist/{chunk-ONFOWI2D.js → chunk-OJP53WIU.js} +16 -15
  110. package/dist/{chunk-NW7AXDA5.js → chunk-OZJXGX4U.js} +2 -2
  111. package/dist/{chunk-KC42JAAQ.js → chunk-PFXC67GJ.js} +3 -3
  112. package/dist/{chunk-ZUK7BL63.js → chunk-S6QKIGRM.js} +66 -54
  113. package/dist/{chunk-IX76WFJV.js → chunk-TF5VLGA7.js} +10 -10
  114. package/dist/{chunk-DACFZ5CI.js → chunk-VY7TVOIK.js} +16 -12
  115. package/dist/{chunk-AN2437E3.js → chunk-YTNPU7I2.js} +2 -2
  116. package/dist/{chunk-3MPOMK3K.js → chunk-YYBX2BD5.js} +61 -3
  117. package/dist/{chunk-RS6ANWVT.js → chunk-ZATRYQLR.js} +1 -1
  118. package/dist/cli/chat.js +20 -20
  119. package/dist/cli/check.js +3 -3
  120. package/dist/cli/plugins.js +9 -9
  121. package/dist/cli/snapshot-warmup.js +6 -6
  122. package/dist/cli/upgrade.js +9 -9
  123. package/dist/{db-CXI7PR5U.js → db-GCK43OO3.js} +4 -4
  124. package/dist/instrumentation.js +1 -1
  125. package/dist/reporting/conversations.d.ts +3 -3
  126. package/dist/reporting.d.ts +1 -1
  127. package/dist/reporting.js +48 -50
  128. package/dist/{runner-FKL3RAHA.js → runner-XWTFA26U.js} +20 -18
  129. package/dist/{validation-I7GD2YWS.js → validation-KYAWETI4.js} +3 -3
  130. package/package.json +6 -6
  131. package/dist/chat/requester.d.ts +0 -68
@@ -12,5 +12,104 @@ interface SearchMcpToolManager {
12
12
  getAvailableProviderCatalog(): ProviderSummary[];
13
13
  }
14
14
  /** Create the progressive MCP catalog search tool used before callMcpTool. */
15
- export declare function createSearchMcpToolsTool(mcpToolManager: SearchMcpToolManager): import("../definition").AnyToolDefinition;
15
+ export declare function createSearchMcpToolsTool(mcpToolManager: SearchMcpToolManager): Omit<import("../definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
16
+ inputSchema: import("../definition").JsonSchemaObject;
17
+ outputSchema: import("../definition").JsonSchemaObject;
18
+ prepareArguments(args: unknown): {
19
+ query?: string | undefined;
20
+ provider?: string | undefined;
21
+ max_results?: number | undefined;
22
+ };
23
+ execute?: ((input: unknown, options: import("../definition").ToolExecuteOptions) => {
24
+ ok: boolean;
25
+ status: "error" | "success";
26
+ query: string | null;
27
+ provider: string | null;
28
+ total_active_tools: number;
29
+ returned_tools: number;
30
+ execution_tool: "callMcpTool";
31
+ execution_example: {
32
+ tool_name: string;
33
+ arguments: Record<string, string>;
34
+ };
35
+ available_providers: {
36
+ provider: string;
37
+ description: string;
38
+ active: boolean;
39
+ }[];
40
+ tools: {
41
+ tool_name: string;
42
+ mcp_tool_name: string;
43
+ provider: string;
44
+ description: string;
45
+ signature: string;
46
+ call: {
47
+ tool_name: string;
48
+ arguments: Record<string, string>;
49
+ };
50
+ input_schema: Record<string, unknown>;
51
+ input_schema_summary: string;
52
+ title?: string | undefined;
53
+ output_schema?: Record<string, unknown> | undefined;
54
+ annotations?: Record<string, unknown> | undefined;
55
+ }[];
56
+ target?: string | undefined;
57
+ data?: unknown;
58
+ truncated?: boolean | undefined;
59
+ continuation?: {
60
+ arguments: Record<string, unknown>;
61
+ reason?: string | undefined;
62
+ } | undefined;
63
+ error?: string | {
64
+ kind: string;
65
+ message: string;
66
+ retryable?: boolean | undefined;
67
+ } | undefined;
68
+ } | Promise<{
69
+ ok: boolean;
70
+ status: "error" | "success";
71
+ query: string | null;
72
+ provider: string | null;
73
+ total_active_tools: number;
74
+ returned_tools: number;
75
+ execution_tool: "callMcpTool";
76
+ execution_example: {
77
+ tool_name: string;
78
+ arguments: Record<string, string>;
79
+ };
80
+ available_providers: {
81
+ provider: string;
82
+ description: string;
83
+ active: boolean;
84
+ }[];
85
+ tools: {
86
+ tool_name: string;
87
+ mcp_tool_name: string;
88
+ provider: string;
89
+ description: string;
90
+ signature: string;
91
+ call: {
92
+ tool_name: string;
93
+ arguments: Record<string, string>;
94
+ };
95
+ input_schema: Record<string, unknown>;
96
+ input_schema_summary: string;
97
+ title?: string | undefined;
98
+ output_schema?: Record<string, unknown> | undefined;
99
+ annotations?: Record<string, unknown> | undefined;
100
+ }[];
101
+ target?: string | undefined;
102
+ data?: unknown;
103
+ truncated?: boolean | undefined;
104
+ continuation?: {
105
+ arguments: Record<string, unknown>;
106
+ reason?: string | undefined;
107
+ } | undefined;
108
+ error?: string | {
109
+ kind: string;
110
+ message: string;
111
+ retryable?: boolean | undefined;
112
+ } | undefined;
113
+ }>) | undefined;
114
+ };
16
115
  export {};
@@ -1 +1,38 @@
1
- export declare function createSystemTimeTool(): import("./definition").AnyToolDefinition;
1
+ export declare function createSystemTimeTool(): Omit<import("./definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
2
+ inputSchema: import("./definition").JsonSchemaObject;
3
+ outputSchema: import("./definition").JsonSchemaObject;
4
+ prepareArguments(args: unknown): Record<string, never>;
5
+ execute?: ((input: unknown, options: import("./definition").ToolExecuteOptions) => {
6
+ [x: string]: unknown;
7
+ ok: boolean;
8
+ status: "error" | "success";
9
+ target?: string | undefined;
10
+ data?: unknown;
11
+ truncated?: boolean | undefined;
12
+ continuation?: {
13
+ arguments: Record<string, unknown>;
14
+ reason?: string | undefined;
15
+ } | undefined;
16
+ error?: string | {
17
+ kind: string;
18
+ message: string;
19
+ retryable?: boolean | undefined;
20
+ } | undefined;
21
+ } | Promise<{
22
+ [x: string]: unknown;
23
+ ok: boolean;
24
+ status: "error" | "success";
25
+ target?: string | undefined;
26
+ data?: unknown;
27
+ truncated?: boolean | undefined;
28
+ continuation?: {
29
+ arguments: Record<string, unknown>;
30
+ reason?: string | undefined;
31
+ } | undefined;
32
+ error?: string | {
33
+ kind: string;
34
+ message: string;
35
+ retryable?: boolean | undefined;
36
+ } | undefined;
37
+ }>) | undefined;
38
+ };
@@ -8,7 +8,7 @@ import type { Skill } from "@/chat/skills";
8
8
  import type { LoadSkillMetadata } from "@/chat/tools/skill/load-skill";
9
9
  import type { AdvisorToolRuntimeContext } from "@/chat/tools/advisor/tool";
10
10
  import type { JuniorToolResult } from "@/chat/tool-support/structured-result";
11
- import type { LocalRequester, Requester, SlackRequester } from "@/chat/requester";
11
+ import type { LocalActor, Actor, SlackActor } from "@/chat/actor";
12
12
  export interface ImageGenerateToolDeps {
13
13
  fetch?: typeof fetch;
14
14
  }
@@ -56,7 +56,7 @@ interface BaseToolRuntimeContext {
56
56
  conversationId?: string;
57
57
  /** Runtime-owned default outbound destination for this invocation. */
58
58
  destination: Destination;
59
- requester?: Requester;
59
+ actor?: Actor;
60
60
  /** Runtime-owned source where this invocation came from. */
61
61
  source: Source;
62
62
  /** Runtime surface that owns final delivery semantics for this turn. */
@@ -70,12 +70,12 @@ interface BaseToolRuntimeContext {
70
70
  }
71
71
  interface SlackToolRuntimeContext extends BaseToolRuntimeContext {
72
72
  destination: SlackDestination;
73
- requester?: SlackRequester;
73
+ actor?: SlackActor;
74
74
  source: SlackSource;
75
75
  }
76
76
  interface LocalToolRuntimeContext extends BaseToolRuntimeContext {
77
77
  destination: LocalDestination;
78
- requester?: LocalRequester;
78
+ actor?: LocalActor;
79
79
  source: LocalSource;
80
80
  slack?: never;
81
81
  }
@@ -2,4 +2,44 @@ import type { ToolHooks } from "@/chat/tools/types";
2
2
  /** Create the fetch tool with delivery guidance scoped to active file-send capability. */
3
3
  export declare function createWebFetchTool(hooks: ToolHooks, options?: {
4
4
  canSendFilesToActiveConversation?: boolean;
5
- }): import("../definition").AnyToolDefinition;
5
+ }): Omit<import("../definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
6
+ inputSchema: import("../definition").JsonSchemaObject;
7
+ outputSchema: import("../definition").JsonSchemaObject;
8
+ prepareArguments(args: unknown): {
9
+ url: string;
10
+ max_chars?: number | undefined;
11
+ };
12
+ execute?: ((input: unknown, options: import("../definition").ToolExecuteOptions) => {
13
+ [x: string]: unknown;
14
+ ok: boolean;
15
+ status: "error" | "success";
16
+ target?: string | undefined;
17
+ data?: unknown;
18
+ truncated?: boolean | undefined;
19
+ continuation?: {
20
+ arguments: Record<string, unknown>;
21
+ reason?: string | undefined;
22
+ } | undefined;
23
+ error?: string | {
24
+ kind: string;
25
+ message: string;
26
+ retryable?: boolean | undefined;
27
+ } | undefined;
28
+ } | Promise<{
29
+ [x: string]: unknown;
30
+ ok: boolean;
31
+ status: "error" | "success";
32
+ target?: string | undefined;
33
+ data?: unknown;
34
+ truncated?: boolean | undefined;
35
+ continuation?: {
36
+ arguments: Record<string, unknown>;
37
+ reason?: string | undefined;
38
+ } | undefined;
39
+ error?: string | {
40
+ kind: string;
41
+ message: string;
42
+ retryable?: boolean | undefined;
43
+ } | undefined;
44
+ }>) | undefined;
45
+ };
@@ -2,4 +2,65 @@ import type { ImageGenerateToolDeps, ToolHooks } from "@/chat/tools/types";
2
2
  /** Create the image tool with sandbox artifact guidance matched to file-send capability. */
3
3
  export declare function createImageGenerateTool(hooks: Required<Pick<ToolHooks, "writeGeneratedArtifacts">>, options?: {
4
4
  canSendFilesToActiveConversation?: boolean;
5
- }, deps?: ImageGenerateToolDeps): import("../definition").AnyToolDefinition;
5
+ }, deps?: ImageGenerateToolDeps): Omit<import("../definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
6
+ inputSchema: import("../definition").JsonSchemaObject;
7
+ outputSchema: import("../definition").JsonSchemaObject;
8
+ prepareArguments(args: unknown): {
9
+ prompt: string;
10
+ };
11
+ execute?: ((input: unknown, options: import("../definition").ToolExecuteOptions) => {
12
+ ok: boolean;
13
+ status: "error" | "success";
14
+ model: string;
15
+ prompt: string;
16
+ enrichedPrompt: string;
17
+ image_count: number;
18
+ images: {
19
+ filename: string;
20
+ path: string;
21
+ attachment_path: string;
22
+ bytes: number;
23
+ media_type?: string | undefined;
24
+ }[];
25
+ delivery: string;
26
+ target?: string | undefined;
27
+ data?: unknown;
28
+ truncated?: boolean | undefined;
29
+ continuation?: {
30
+ arguments: Record<string, unknown>;
31
+ reason?: string | undefined;
32
+ } | undefined;
33
+ error?: string | {
34
+ kind: string;
35
+ message: string;
36
+ retryable?: boolean | undefined;
37
+ } | undefined;
38
+ } | Promise<{
39
+ ok: boolean;
40
+ status: "error" | "success";
41
+ model: string;
42
+ prompt: string;
43
+ enrichedPrompt: string;
44
+ image_count: number;
45
+ images: {
46
+ filename: string;
47
+ path: string;
48
+ attachment_path: string;
49
+ bytes: number;
50
+ media_type?: string | undefined;
51
+ }[];
52
+ delivery: string;
53
+ target?: string | undefined;
54
+ data?: unknown;
55
+ truncated?: boolean | undefined;
56
+ continuation?: {
57
+ arguments: Record<string, unknown>;
58
+ reason?: string | undefined;
59
+ } | undefined;
60
+ error?: string | {
61
+ kind: string;
62
+ message: string;
63
+ retryable?: boolean | undefined;
64
+ } | undefined;
65
+ }>) | undefined;
66
+ };
@@ -1,2 +1,42 @@
1
1
  import type { WebSearchToolDeps } from "@/chat/tools/types";
2
- export declare function createWebSearchTool(override?: WebSearchToolDeps): import("../definition").AnyToolDefinition;
2
+ export declare function createWebSearchTool(override?: WebSearchToolDeps): Omit<import("../definition").AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
3
+ inputSchema: import("../definition").JsonSchemaObject;
4
+ outputSchema: import("../definition").JsonSchemaObject;
5
+ prepareArguments(args: unknown): {
6
+ query: string;
7
+ max_results?: number | undefined;
8
+ };
9
+ execute?: ((input: unknown, options: import("../definition").ToolExecuteOptions) => {
10
+ [x: string]: unknown;
11
+ ok: boolean;
12
+ status: "error" | "success";
13
+ target?: string | undefined;
14
+ data?: unknown;
15
+ truncated?: boolean | undefined;
16
+ continuation?: {
17
+ arguments: Record<string, unknown>;
18
+ reason?: string | undefined;
19
+ } | undefined;
20
+ error?: string | {
21
+ kind: string;
22
+ message: string;
23
+ retryable?: boolean | undefined;
24
+ } | undefined;
25
+ } | Promise<{
26
+ [x: string]: unknown;
27
+ ok: boolean;
28
+ status: "error" | "success";
29
+ target?: string | undefined;
30
+ data?: unknown;
31
+ truncated?: boolean | undefined;
32
+ continuation?: {
33
+ arguments: Record<string, unknown>;
34
+ reason?: string | undefined;
35
+ } | undefined;
36
+ error?: string | {
37
+ kind: string;
38
+ message: string;
39
+ retryable?: boolean | undefined;
40
+ } | undefined;
41
+ }>) | undefined;
42
+ };
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  getCurrentConversationPrivacy,
3
3
  resolveConversationPrivacy,
4
+ toCanonicalInputMessage,
5
+ toCanonicalOutputMessage,
4
6
  toGenAiMessageMetadata,
5
7
  toGenAiMessagesTraceAttributes,
6
8
  toGenAiTextMetadata
7
- } from "./chunk-3MPOMK3K.js";
9
+ } from "./chunk-YYBX2BD5.js";
8
10
  import {
9
11
  extractGenAiUsageAttributes,
10
12
  logException,
@@ -12,13 +14,79 @@ import {
12
14
  serializeGenAiAttribute,
13
15
  setSpanAttributes,
14
16
  withSpan
15
- } from "./chunk-ZUK7BL63.js";
17
+ } from "./chunk-S6QKIGRM.js";
18
+
19
+ // src/chat/xml.ts
20
+ function escapeXml(value) {
21
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;");
22
+ }
23
+
24
+ // src/chat/current-instruction.ts
25
+ var CURRENT_INSTRUCTION_TAG = "current-instruction";
26
+ var CURRENT_INSTRUCTION_OPEN_PREFIX = `<${CURRENT_INSTRUCTION_TAG}`;
27
+ var CURRENT_INSTRUCTION_OPEN_BARE = `<${CURRENT_INSTRUCTION_TAG}>`;
28
+ var CURRENT_INSTRUCTION_OPEN_ATTR_PREFIX = `<${CURRENT_INSTRUCTION_TAG} `;
29
+ var CURRENT_INSTRUCTION_CLOSE = `
30
+ </${CURRENT_INSTRUCTION_TAG}>`;
31
+ function unescapeXml(value) {
32
+ return value.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&gt;", ">").replaceAll("&lt;", "<").replaceAll("&amp;", "&");
33
+ }
34
+ function isCurrentInstructionOpeningTag(value) {
35
+ return value === CURRENT_INSTRUCTION_OPEN_BARE || value.startsWith(CURRENT_INSTRUCTION_OPEN_ATTR_PREFIX) && value.endsWith(">");
36
+ }
37
+ function readCurrentInstructionBody(text) {
38
+ const start = text.indexOf(CURRENT_INSTRUCTION_OPEN_PREFIX);
39
+ if (start < 0) {
40
+ return void 0;
41
+ }
42
+ const openingEnd = text.indexOf(">\n", start);
43
+ if (openingEnd < 0) {
44
+ return void 0;
45
+ }
46
+ const openingTag = text.slice(start, openingEnd + 1);
47
+ if (!isCurrentInstructionOpeningTag(openingTag)) {
48
+ return void 0;
49
+ }
50
+ const bodyStart = openingEnd + 2;
51
+ const bodyEnd = text.indexOf(CURRENT_INSTRUCTION_CLOSE, bodyStart);
52
+ if (bodyEnd < bodyStart) {
53
+ return void 0;
54
+ }
55
+ return text.slice(bodyStart, bodyEnd);
56
+ }
57
+ function renderCurrentInstruction(instruction, attrs) {
58
+ const renderedAttrs = [
59
+ attrs?.authorId ? `author_id="${escapeXml(attrs.authorId)}"` : void 0,
60
+ attrs?.authorName ? `author_name="${escapeXml(attrs.authorName)}"` : void 0,
61
+ attrs?.slackTs ? `slack_ts="${escapeXml(attrs.slackTs)}"` : void 0
62
+ ].filter((attr) => Boolean(attr)).join(" ");
63
+ const openingTag = renderedAttrs ? `<${CURRENT_INSTRUCTION_TAG} ${renderedAttrs}>` : `<${CURRENT_INSTRUCTION_TAG}>`;
64
+ return [
65
+ openingTag,
66
+ escapeXml(instruction),
67
+ `</${CURRENT_INSTRUCTION_TAG}>`
68
+ ].join("\n");
69
+ }
70
+ function unwrapCurrentInstruction(text) {
71
+ const body = readCurrentInstructionBody(text);
72
+ return body === void 0 ? void 0 : unescapeXml(body);
73
+ }
16
74
 
17
75
  // src/chat/turn-context-tag.ts
18
76
  var TURN_CONTEXT_TAG = "runtime-turn-context";
19
77
 
20
78
  // src/chat/pi/transcript.ts
21
79
  var RUNTIME_TURN_CONTEXT_START = `<${TURN_CONTEXT_TAG}>`;
80
+ var EMBEDDED_THREAD_CONTEXT_TAGS = [
81
+ "recent-thread-messages",
82
+ "thread-compactions",
83
+ "thread-transcript",
84
+ "thread-background"
85
+ ];
86
+ var EMBEDDED_THREAD_CONTEXT_PATTERN = new RegExp(
87
+ `<(${EMBEDDED_THREAD_CONTEXT_TAGS.join("|")})(?:\\s[^>]*)?>[\\s\\S]*?</\\1>`,
88
+ "g"
89
+ );
22
90
  function isAssistantMessage(value) {
23
91
  return typeof value === "object" && value !== null && value.role === "assistant";
24
92
  }
@@ -84,6 +152,10 @@ function hasRuntimeTurnContext(messages) {
84
152
  )
85
153
  );
86
154
  }
155
+ function instructionTextForProjection(text) {
156
+ const withoutContext = text.replace(EMBEDDED_THREAD_CONTEXT_PATTERN, "").trim();
157
+ return unwrapCurrentInstruction(withoutContext) ?? withoutContext;
158
+ }
87
159
  function stripRuntimeTurnContext(messages) {
88
160
  return messages.flatMap((message) => {
89
161
  const content = getUserMessageContent(message);
@@ -219,7 +291,7 @@ async function completeText(params) {
219
291
  const effectivePrivacy = privacy ?? "private";
220
292
  const messageAttributeMode = params.messageAttributeMode ?? (effectivePrivacy === "public" ? "content" : "metadata");
221
293
  const requestMessagesAttribute = serializeGenAiAttribute(
222
- messageAttributeMode === "metadata" ? params.messages.map(toGenAiMessageMetadata) : params.messages
294
+ messageAttributeMode === "metadata" ? params.messages.map(toGenAiMessageMetadata) : params.messages.map(toCanonicalInputMessage)
223
295
  );
224
296
  const systemInstructionsAttribute = params.system ? serializeGenAiAttribute(
225
297
  messageAttributeMode === "metadata" ? [toGenAiTextMetadata(params.system)] : [{ type: "text", content: params.system }]
@@ -232,7 +304,7 @@ async function completeText(params) {
232
304
  "server.address": GEN_AI_SERVER_ADDRESS,
233
305
  "server.port": GEN_AI_SERVER_PORT,
234
306
  "app.conversation.privacy": effectivePrivacy,
235
- ...params.thinkingLevel ? { "app.ai.reasoning_effort": params.thinkingLevel } : {}
307
+ ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : {}
236
308
  };
237
309
  const startAttributes = {
238
310
  ...baseAttributes,
@@ -274,12 +346,7 @@ async function completeText(params) {
274
346
  role: "assistant",
275
347
  content: outputText ? [toGenAiTextMetadata(outputText)] : []
276
348
  }
277
- ] : [
278
- {
279
- role: "assistant",
280
- content: outputText ? [{ type: "text", text: outputText }] : []
281
- }
282
- ]
349
+ ] : [toCanonicalOutputMessage(message)]
283
350
  );
284
351
  const usageAttributes = extractGenAiUsageAttributes(message);
285
352
  const endAttributes = {
@@ -353,7 +420,7 @@ async function completeObject(params) {
353
420
  "gen_ai.output.type": "json",
354
421
  "server.address": GEN_AI_SERVER_ADDRESS,
355
422
  "server.port": GEN_AI_SERVER_PORT,
356
- ...params.thinkingLevel ? { "app.ai.reasoning_effort": params.thinkingLevel } : {}
423
+ ...params.thinkingLevel ? { "gen_ai.request.reasoning.level": params.thinkingLevel } : {}
357
424
  }
358
425
  );
359
426
  setSpanAttributes({
@@ -728,6 +795,9 @@ function setSlackReactionConfig(overrides) {
728
795
 
729
796
  export {
730
797
  toOptionalTrimmed,
798
+ escapeXml,
799
+ renderCurrentInstruction,
800
+ unwrapCurrentInstruction,
731
801
  TURN_CONTEXT_TAG,
732
802
  isAssistantMessage,
733
803
  isToolResultMessage,
@@ -738,6 +808,7 @@ export {
738
808
  getTerminalAssistantMessages,
739
809
  trimTrailingAssistantMessages,
740
810
  hasRuntimeTurnContext,
811
+ instructionTextForProjection,
741
812
  stripRuntimeTurnContext,
742
813
  isProviderRetryError,
743
814
  nextProviderRetry,