@sentry/junior 0.93.0 → 0.95.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/{agent-hooks-ZG7IDOIN.js → agent-hooks-FTQ5EGPO.js} +9 -10
- package/dist/api/people/list.js +7 -7
- package/dist/api/people/profile.js +7 -7
- package/dist/api/people/shared.d.ts +2 -2
- package/dist/api-reference.d.ts +1 -1
- package/dist/app.js +474 -231
- package/dist/{catalog-runtime-NZHMSMYC.js → catalog-runtime-2D7IVKUT.js} +3 -3
- package/dist/chat/advisor-request.d.ts +4 -0
- package/dist/chat/agent/request.d.ts +2 -0
- package/dist/chat/agent/resume.d.ts +2 -0
- package/dist/chat/conversations/history.d.ts +128 -0
- package/dist/chat/conversations/legacy-import.d.ts +38 -0
- package/dist/chat/conversations/messages.d.ts +39 -0
- package/dist/chat/conversations/projection.d.ts +94 -0
- package/dist/chat/conversations/retention.d.ts +36 -0
- package/dist/chat/conversations/sql/conversation-row.d.ts +14 -0
- package/dist/chat/conversations/sql/history.d.ts +4 -0
- package/dist/chat/conversations/sql/legacy-history-import.d.ts +55 -0
- package/dist/chat/conversations/sql/messages.d.ts +4 -0
- package/dist/chat/conversations/sql/migrations.d.ts +14 -3
- package/dist/chat/conversations/sql/purge.d.ts +53 -0
- package/dist/chat/conversations/sql/store.d.ts +7 -2
- package/dist/chat/conversations/store.d.ts +19 -0
- package/dist/chat/conversations/visible-compactions.d.ts +11 -0
- package/dist/chat/conversations/visible-messages.d.ts +47 -0
- package/dist/chat/db.d.ts +12 -1
- package/dist/chat/egress/credentialed.d.ts +1 -1
- package/dist/chat/identities/sql.d.ts +1 -1
- package/dist/chat/logging.d.ts +2 -1
- package/dist/chat/resource-events/store.d.ts +2 -1
- package/dist/chat/runtime/reply-executor.d.ts +8 -0
- package/dist/chat/runtime/thread-state.d.ts +2 -0
- package/dist/chat/sandbox/egress/schemas.d.ts +4 -0
- package/dist/chat/sandbox/egress/session.d.ts +2 -2
- package/dist/chat/sandbox/resources.d.ts +4 -0
- package/dist/chat/services/mcp-auth-orchestration.d.ts +8 -0
- package/dist/chat/services/plugin-auth-orchestration.d.ts +12 -0
- package/dist/chat/services/turn-session-record.d.ts +14 -2
- package/dist/chat/sleep.d.ts +2 -0
- package/dist/chat/state/conversation.d.ts +7 -4
- package/dist/chat/state/session-log.d.ts +23 -1
- package/dist/chat/state/turn-session.d.ts +6 -0
- package/dist/chat/tool-support/private-trace-result.d.ts +4 -0
- package/dist/chat/tool-support/zod-tool.d.ts +1 -0
- package/dist/chat/tools/advisor/tool.d.ts +9 -4
- package/dist/chat/tools/definition.d.ts +2 -0
- package/dist/chat/tools/execution/tool-error-handler.d.ts +2 -2
- package/dist/chat/tools/system-time.d.ts +8 -0
- package/dist/chat/xml.d.ts +2 -0
- package/dist/{chunk-NYWPISSO.js → chunk-2XXEKR44.js} +1 -1
- package/dist/{chunk-QGEWC27H.js → chunk-5XMNOD3S.js} +5 -7
- package/dist/{chunk-NFXSLTYG.js → chunk-6ONME5IG.js} +864 -62
- package/dist/{chunk-LFLTJQVR.js → chunk-7FBGKXPE.js} +4 -0
- package/dist/{chunk-MC4ZZE4Q.js → chunk-AYP4ERVZ.js} +1 -1
- package/dist/{chunk-GHGPTPBL.js → chunk-B7PUBQQM.js} +1 -1
- package/dist/chunk-CM5EZD5F.js +17 -0
- package/dist/chunk-CRRBJ3JP.js +1037 -0
- package/dist/{chunk-G3E7SCME.js → chunk-CZEX6KIQ.js} +23 -0
- package/dist/{chunk-TNUUATT7.js → chunk-E3E2XNCN.js} +2 -2
- package/dist/{chunk-LNCREA5Z.js → chunk-EKNJM5IG.js} +3 -127
- package/dist/{chunk-NAPITCZ6.js → chunk-GUE7HTNR.js} +251 -6
- package/dist/{chunk-BTH37NCU.js → chunk-GVOUCI2O.js} +1 -1
- package/dist/{chunk-YYBX2BD5.js → chunk-GY34VGP5.js} +1 -1
- package/dist/{chunk-JJUJ4CO2.js → chunk-HCXXB35T.js} +1489 -360
- package/dist/{chunk-YTNPU7I2.js → chunk-HDTO3A74.js} +2 -2
- package/dist/{chunk-YJ4OPVNA.js → chunk-HZNJLKKI.js} +1 -1
- package/dist/{chunk-HDNWZMUN.js → chunk-KDPCGVIT.js} +116 -51
- package/dist/chunk-N4RNJ32C.js +48 -0
- package/dist/{chunk-UUB3D2XI.js → chunk-NSCHU54X.js} +8 -10
- package/dist/{chunk-PFXC67GJ.js → chunk-RAIB6WSG.js} +6 -80
- package/dist/chunk-WAGQ377B.js +724 -0
- package/dist/{chunk-6H4PP63X.js → chunk-WCMQJE4F.js} +24 -14
- package/dist/{chunk-S6QKIGRM.js → chunk-WPOJ443W.js} +15 -25
- package/dist/{chunk-MAVOJ54A.js → chunk-XX4N4E6C.js} +25 -388
- package/dist/cli/chat.js +24 -23
- package/dist/cli/check.js +4 -4
- package/dist/cli/plugins.js +11 -12
- package/dist/cli/snapshot-warmup.js +7 -8
- package/dist/cli/upgrade.js +78 -17
- package/dist/db/schema/agent-steps.d.ts +134 -0
- package/dist/db/schema/conversation-messages.d.ts +153 -0
- package/dist/{chat/conversations/sql → db}/schema/conversations.d.ts +34 -0
- package/dist/{chat/conversations/sql → db}/schema.d.ts +319 -8
- package/dist/db-W55B74OP.js +24 -0
- package/dist/deployment.d.ts +2 -0
- package/dist/handlers/retention.d.ts +6 -0
- package/dist/instrumentation.js +16 -3
- package/dist/legacy-import-ZPLGLAFD.js +17 -0
- package/dist/nitro.js +14 -4
- package/dist/reporting/conversations/activity.d.ts +40 -0
- package/dist/reporting/conversations/context.d.ts +8 -0
- package/dist/reporting/conversations/details.d.ts +6 -0
- package/dist/reporting/conversations/index.d.ts +4 -0
- package/dist/reporting/conversations/shared.d.ts +9 -0
- package/dist/reporting/conversations/statistics.d.ts +4 -0
- package/dist/reporting/conversations/summaries.d.ts +17 -0
- package/dist/reporting/conversations/transcript.d.ts +28 -0
- package/dist/reporting/conversations/types.d.ts +178 -0
- package/dist/reporting/conversations.d.ts +1 -178
- package/dist/reporting.d.ts +4 -3
- package/dist/reporting.js +603 -827
- package/dist/{runner-XAZPJNAQ.js → runner-OOSBDYRK.js} +35 -41
- package/dist/{validation-KYAWETI4.js → validation-QCGRFRFZ.js} +4 -4
- package/migrations/README.md +32 -0
- package/migrations/meta/0000_snapshot.json +978 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +9 -6
- package/dist/chat/sql/schema.d.ts +0 -1049
- package/dist/chat/state/conversation-details.d.ts +0 -47
- package/dist/chunk-7STN2ZSK.js +0 -250
- package/dist/chunk-LE5ANBUZ.js +0 -1040
- package/dist/chunk-QL66APYJ.js +0 -1377
- package/dist/db-YDN6AFJH.js +0 -18
- /package/dist/{chat/sql → db}/db.d.ts +0 -0
- /package/dist/{chat/sql → db}/executor.d.ts +0 -0
- /package/dist/{chat/sql → db}/neon.d.ts +0 -0
- /package/dist/{chat/sql → db}/postgres.d.ts +0 -0
- /package/dist/{chat/conversations/sql → db}/schema/destinations.d.ts +0 -0
- /package/dist/{chat/conversations/sql → db}/schema/identities.d.ts +0 -0
- /package/dist/{chat/conversations/sql → db}/schema/migrations.d.ts +0 -0
- /package/dist/{chat/conversations/sql → db}/schema/timestamps.d.ts +0 -0
- /package/dist/{chat/conversations/sql → db}/schema/users.d.ts +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visible-transcript sync between the in-memory turn working set and SQL.
|
|
3
|
+
*
|
|
4
|
+
* The durable authority for the visible conversation transcript is the
|
|
5
|
+
* `ConversationMessageStore`; `ThreadConversationState.messages` is only the
|
|
6
|
+
* in-memory working set for the current turn. These helpers hydrate that
|
|
7
|
+
* working set from SQL at load boundaries and write new/updated messages back
|
|
8
|
+
* through the store, so no transcript data is persisted to `thread-state`.
|
|
9
|
+
*/
|
|
10
|
+
import type { NewConversationMessage } from "@/chat/conversations/messages";
|
|
11
|
+
import type { ConversationMessage, ThreadConversationState } from "@/chat/state/conversation";
|
|
12
|
+
/**
|
|
13
|
+
* Project the in-memory message onto the store insert shape. This is the single
|
|
14
|
+
* serialization point for visible messages, so both live turn persistence and
|
|
15
|
+
* the one-time legacy import produce identical rows: author display facts and
|
|
16
|
+
* bounded source meta ride in the `meta` JSON so the working set rehydrates with
|
|
17
|
+
* identical rendering, and `replied === true` is not stored in meta because
|
|
18
|
+
* `replied_at` is its authority.
|
|
19
|
+
*/
|
|
20
|
+
export declare function toStoredConversationMessage(message: ConversationMessage): NewConversationMessage;
|
|
21
|
+
/**
|
|
22
|
+
* Replace the in-memory working set with the durable transcript from SQL,
|
|
23
|
+
* excluding messages already folded into a thread-state compaction summary.
|
|
24
|
+
*
|
|
25
|
+
* Hydrate is a first-read boundary, so it must trigger the once-only Redis→SQL
|
|
26
|
+
* lazy import before reading SQL: consumers that hydrate before any step
|
|
27
|
+
* projection read (turn-dedupe, delivered-message redelivery guards,
|
|
28
|
+
* channel-context assembly) would otherwise make correctness decisions on an
|
|
29
|
+
* empty transcript for promotion-window stragglers whose history is still only
|
|
30
|
+
* in legacy Redis. The import is idempotent (skips when SQL step rows exist)
|
|
31
|
+
* and no-ops cheaply when there is nothing legacy to read.
|
|
32
|
+
*/
|
|
33
|
+
export declare function hydrateConversationMessages(args: {
|
|
34
|
+
conversation: ThreadConversationState;
|
|
35
|
+
conversationId: string | undefined;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Write the working set back to SQL: record every message idempotently and set
|
|
39
|
+
* the `replied_at` mark for messages the turn has answered. Content columns are
|
|
40
|
+
* insert-only and `meta` merges key-wise on conflict, so repeated calls across
|
|
41
|
+
* a turn's persist points are safe.
|
|
42
|
+
*/
|
|
43
|
+
export declare function persistConversationMessages(args: {
|
|
44
|
+
conversation: ThreadConversationState;
|
|
45
|
+
conversationId: string | undefined;
|
|
46
|
+
repliedAtMs?: number;
|
|
47
|
+
}): Promise<void>;
|
package/dist/chat/db.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { ConversationStore } from "@/chat/conversations/store";
|
|
2
|
-
import type {
|
|
2
|
+
import type { AgentStepStore } from "@/chat/conversations/history";
|
|
3
|
+
import type { ConversationMessageStore } from "@/chat/conversations/messages";
|
|
4
|
+
import type { JuniorDatabase, JuniorSqlExecutor } from "@/db/db";
|
|
5
|
+
/**
|
|
6
|
+
* Return the process SQL executor. Exposed for the one-time legacy import
|
|
7
|
+
* writer, which needs explicit-`seq`/epoch inserts the step-store port omits.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSqlExecutor(): JuniorSqlExecutor;
|
|
3
10
|
/** Return the process Drizzle database. */
|
|
4
11
|
export declare function getDb(): JuniorDatabase;
|
|
5
12
|
/** Return the SQL-backed conversation store. */
|
|
6
13
|
export declare function getConversationStore(): ConversationStore;
|
|
14
|
+
/** Return the SQL-backed durable agent step store. */
|
|
15
|
+
export declare function getAgentStepStore(): AgentStepStore;
|
|
16
|
+
/** Return the SQL-backed visible conversation message store. */
|
|
17
|
+
export declare function getConversationMessageStore(): ConversationMessageStore;
|
|
7
18
|
/** Close the process SQL database when it has been opened. */
|
|
8
19
|
export declare function closeDb(): Promise<void>;
|
|
@@ -15,7 +15,7 @@ export type CredentialedEgressHttpInterceptor = (input: {
|
|
|
15
15
|
}) => Promise<Response | undefined>;
|
|
16
16
|
/** Runtime dependencies for the credentialed provider forwarding step. */
|
|
17
17
|
export interface CredentialedEgressDeps {
|
|
18
|
-
clearCredentialLease?: (provider: string,
|
|
18
|
+
clearCredentialLease?: (provider: string, grant: SandboxEgressCredentialLease["grant"], credentialContext: SandboxEgressCredentialContext) => Promise<void>;
|
|
19
19
|
fetch?: typeof fetch;
|
|
20
20
|
issueCredentialLease?: (provider: string, selection: SandboxEgressGrantSelection, credentialContext: SandboxEgressCredentialContext) => Promise<SandboxEgressCredentialLease>;
|
|
21
21
|
interceptHttp?: CredentialedEgressHttpInterceptor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JuniorSqlDatabase } from "@/
|
|
1
|
+
import type { JuniorSqlDatabase } from "@/db/db";
|
|
2
2
|
import { type IdentityUpsert, type StoredIdentity } from "./identity";
|
|
3
3
|
/** Persist one provider identity observation and link verified emails to users. */
|
|
4
4
|
export declare function upsertIdentity(executor: JuniorSqlDatabase, identity: IdentityUpsert, nowMs?: number): Promise<StoredIdentity>;
|
package/dist/chat/logging.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare function setSentryTagsFromContext(context: LogContext): void;
|
|
|
62
62
|
export declare function setSentryUser(identity: SentryUserIdentity | undefined): void;
|
|
63
63
|
/** Attach scoped Sentry context for isolated exception capture. */
|
|
64
64
|
export declare function setSentryScopeContext(scope: Sentry.Scope, context: LogContext): void;
|
|
65
|
+
export type SetSpanAttributes = (attributes: Record<string, unknown>) => void;
|
|
65
66
|
/** Capture an error to Sentry and emit an error log record. */
|
|
66
67
|
export declare function captureException(error: unknown, context?: LogContext): void;
|
|
67
68
|
/** Log an info-level structured event. */
|
|
@@ -79,7 +80,7 @@ export declare function createRequestContext(request: Request, context?: Partial
|
|
|
79
80
|
/** Run a callback within a scoped log context. */
|
|
80
81
|
export declare function withContext<T>(context: LogContext, callback: () => Promise<T>): Promise<T>;
|
|
81
82
|
/** Run a callback within a Sentry span and scoped log context. */
|
|
82
|
-
export declare function withSpan<T>(name: string, op: string, context: LogContext, callback: () => Promise<T>, attributes?: Record<string, unknown>): Promise<T>;
|
|
83
|
+
export declare function withSpan<T>(name: string, op: string, context: LogContext, callback: (setSpanAttributes: SetSpanAttributes) => Promise<T>, attributes?: Record<string, unknown>): Promise<T>;
|
|
83
84
|
/** Return Sentry-standard trace propagation headers for the active span. */
|
|
84
85
|
export declare function getTracePropagationHeaders(): TracePropagationHeaders;
|
|
85
86
|
/** Set attributes on the currently active Sentry span. */
|
|
@@ -21,9 +21,9 @@ declare const subscriptionSchema: z.ZodObject<{
|
|
|
21
21
|
resourceRef: z.ZodString;
|
|
22
22
|
resourceType: z.ZodString;
|
|
23
23
|
status: z.ZodEnum<{
|
|
24
|
+
cancelled: "cancelled";
|
|
24
25
|
completed: "completed";
|
|
25
26
|
active: "active";
|
|
26
|
-
cancelled: "cancelled";
|
|
27
27
|
}>;
|
|
28
28
|
updatedAtMs: z.ZodNumber;
|
|
29
29
|
}, z.core.$strict>;
|
|
@@ -75,5 +75,6 @@ export declare function deliverResourceEventSubscription(input: {
|
|
|
75
75
|
state?: StateAdapter;
|
|
76
76
|
subscription: ResourceEventSubscription;
|
|
77
77
|
terminal?: boolean;
|
|
78
|
+
waitDeadlineMs?: number;
|
|
78
79
|
}): Promise<boolean>;
|
|
79
80
|
export {};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack reply execution boundary.
|
|
3
|
+
*
|
|
4
|
+
* This module bridges prepared Slack thread state into the agent runner
|
|
5
|
+
* and commits the resulting Slack-visible delivery/state updates. It is where
|
|
6
|
+
* queued messages, compaction, status updates, and Slack posting meet; agent
|
|
7
|
+
* internals stay behind the runner seam.
|
|
8
|
+
*/
|
|
1
9
|
import type { Message, Thread } from "chat";
|
|
2
10
|
import type { SlackAdapter } from "@chat-adapter/slack";
|
|
3
11
|
import { type Destination } from "@sentry/junior-plugin-api";
|
|
@@ -17,6 +17,8 @@ export declare function mergeArtifactsState(artifacts: ThreadArtifactsState, pat
|
|
|
17
17
|
export declare function getPersistedSandboxState(state: Record<string, unknown>): PersistedSandboxState;
|
|
18
18
|
/** Persist a thread-state patch through the Chat SDK thread interface. */
|
|
19
19
|
export declare function persistThreadState(thread: Thread, patch: ThreadStatePatch): Promise<void>;
|
|
20
|
+
/** Persist only the Redis-backed runtime scratch in a thread-state patch. */
|
|
21
|
+
export declare function persistThreadRuntimeState(thread: Thread, patch: ThreadStatePatch): Promise<void>;
|
|
20
22
|
/** Load the persisted state payload for a thread without requiring a Chat singleton. */
|
|
21
23
|
export declare function getPersistedThreadState(threadId: string): Promise<Record<string, unknown>>;
|
|
22
24
|
/** Load the persisted state payload for a channel without constructing a Chat channel. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const sandboxEgressGrantSchema: z.ZodObject<{
|
|
3
3
|
access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
4
|
+
leaseScope: z.ZodOptional<z.ZodString>;
|
|
4
5
|
name: z.ZodString;
|
|
5
6
|
reason: z.ZodOptional<z.ZodString>;
|
|
6
7
|
requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -45,6 +46,7 @@ export declare const sandboxEgressCredentialLeaseSchema: z.ZodObject<{
|
|
|
45
46
|
}, z.core.$strict>>;
|
|
46
47
|
grant: z.ZodObject<{
|
|
47
48
|
access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
49
|
+
leaseScope: z.ZodOptional<z.ZodString>;
|
|
48
50
|
name: z.ZodString;
|
|
49
51
|
reason: z.ZodOptional<z.ZodString>;
|
|
50
52
|
requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -64,6 +66,7 @@ export declare const sandboxEgressAuthRequiredSignalSchema: z.ZodObject<{
|
|
|
64
66
|
}, z.core.$strict>>;
|
|
65
67
|
grant: z.ZodObject<{
|
|
66
68
|
access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
69
|
+
leaseScope: z.ZodOptional<z.ZodString>;
|
|
67
70
|
name: z.ZodString;
|
|
68
71
|
reason: z.ZodOptional<z.ZodString>;
|
|
69
72
|
requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -85,6 +88,7 @@ export declare const sandboxEgressPermissionDeniedSignalSchema: z.ZodObject<{
|
|
|
85
88
|
acceptedPermissions: z.ZodOptional<z.ZodString>;
|
|
86
89
|
grant: z.ZodObject<{
|
|
87
90
|
access: z.ZodUnion<readonly [z.ZodLiteral<"read">, z.ZodLiteral<"write">]>;
|
|
91
|
+
leaseScope: z.ZodOptional<z.ZodString>;
|
|
88
92
|
name: z.ZodString;
|
|
89
93
|
reason: z.ZodOptional<z.ZodString>;
|
|
90
94
|
requirements: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -31,9 +31,9 @@ export declare function setSandboxEgressCredentialLease(context: SandboxEgressCr
|
|
|
31
31
|
/**
|
|
32
32
|
* Load cached credential header transforms for the exact actor/context/grant.
|
|
33
33
|
*/
|
|
34
|
-
export declare function getSandboxEgressCredentialLease(provider: string,
|
|
34
|
+
export declare function getSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], context: SandboxEgressCredentialContext): Promise<SandboxEgressCredentialLease | undefined>;
|
|
35
35
|
/** Clear a cached lease after the upstream provider rejects its auth headers. */
|
|
36
|
-
export declare function clearSandboxEgressCredentialLease(provider: string,
|
|
36
|
+
export declare function clearSandboxEgressCredentialLease(provider: string, grant: SandboxEgressCredentialLease["grant"], context: SandboxEgressCredentialContext): Promise<void>;
|
|
37
37
|
/**
|
|
38
38
|
* Record that credential issuance needs user authorization for this command.
|
|
39
39
|
*
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP authorization pause orchestration.
|
|
3
|
+
*
|
|
4
|
+
* This module turns an MCP client auth challenge into Junior's paused-run
|
|
5
|
+
* model: create provider auth state, deliver or reuse a private Slack link,
|
|
6
|
+
* record pending auth, and abort the agent so the OAuth callback can resume the
|
|
7
|
+
* same session.
|
|
8
|
+
*/
|
|
1
9
|
import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
10
|
import type { Destination, Source } from "@sentry/junior-plugin-api";
|
|
3
11
|
import { AuthorizationPauseError, type AuthorizationFlowMode } from "@/chat/services/auth-pause";
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin authorization pause orchestration.
|
|
3
|
+
*
|
|
4
|
+
* This module detects plugin credential failures from the sandbox egress layer
|
|
5
|
+
* and maps them onto the same paused-run contract used by MCP auth. It owns
|
|
6
|
+
* provider attribution, private-link delivery/reuse, session-log recording,
|
|
7
|
+
* and credential cleanup.
|
|
8
|
+
*
|
|
9
|
+
* Auth failures are detected exclusively through the structured `auth_required`
|
|
10
|
+
* signal emitted by the egress proxy — never inferred from bash command text,
|
|
11
|
+
* stdout patterns, or exit codes.
|
|
12
|
+
*/
|
|
1
13
|
import type { Destination, Source } from "@sentry/junior-plugin-api";
|
|
2
14
|
import type { ChannelConfigurationService } from "@/chat/configuration/types";
|
|
3
15
|
import type { UserTokenStore } from "@/chat/credentials/user-token-store";
|
|
@@ -38,7 +38,9 @@ export declare function persistRunningSessionRecord(args: {
|
|
|
38
38
|
trailingMessageProvenance?: PiMessageProvenance[];
|
|
39
39
|
loadedSkillNames?: string[];
|
|
40
40
|
logContext: SessionRecordLogContext;
|
|
41
|
+
modelId?: string;
|
|
41
42
|
actor?: Actor;
|
|
43
|
+
reasoningLevel?: string;
|
|
42
44
|
surface?: AgentTurnSurface;
|
|
43
45
|
turnStartMessageIndex?: number;
|
|
44
46
|
}): Promise<boolean>;
|
|
@@ -47,8 +49,9 @@ export declare function persistRunningSessionRecord(args: {
|
|
|
47
49
|
*
|
|
48
50
|
* Generation completing is not delivery: call this only after the destination
|
|
49
51
|
* accepted the visible final reply, so an undelivered assistant reply never
|
|
50
|
-
* becomes durable conversation history or a terminal completed state.
|
|
51
|
-
*
|
|
52
|
+
* becomes durable conversation history or a terminal completed state. The
|
|
53
|
+
* write is retried because the reply is already user-visible, then any remaining
|
|
54
|
+
* failure surfaces to the post-delivery boundary for one authoritative error.
|
|
52
55
|
*/
|
|
53
56
|
export declare function persistCompletedSessionRecord(args: {
|
|
54
57
|
channelName?: string;
|
|
@@ -65,7 +68,9 @@ export declare function persistCompletedSessionRecord(args: {
|
|
|
65
68
|
allMessages: PiMessage[];
|
|
66
69
|
loadedSkillNames?: string[];
|
|
67
70
|
logContext: SessionRecordLogContext;
|
|
71
|
+
modelId?: string;
|
|
68
72
|
actor?: Actor;
|
|
73
|
+
reasoningLevel?: string;
|
|
69
74
|
surface?: AgentTurnSurface;
|
|
70
75
|
turnStartMessageIndex?: number;
|
|
71
76
|
}): Promise<void>;
|
|
@@ -80,6 +85,7 @@ export declare function completeDeliveredTurn(args: {
|
|
|
80
85
|
logContext: SessionRecordLogContext;
|
|
81
86
|
messages: PiMessage[];
|
|
82
87
|
actor?: Actor;
|
|
88
|
+
reasoningLevel?: string;
|
|
83
89
|
sessionId: string;
|
|
84
90
|
sliceId: number;
|
|
85
91
|
source: Source;
|
|
@@ -102,9 +108,11 @@ export declare function persistAuthPauseSessionRecord(args: {
|
|
|
102
108
|
source?: Source;
|
|
103
109
|
messages: PiMessage[];
|
|
104
110
|
loadedSkillNames?: string[];
|
|
111
|
+
modelId?: string;
|
|
105
112
|
errorMessage: string;
|
|
106
113
|
logContext: SessionRecordLogContext;
|
|
107
114
|
actor?: Actor;
|
|
115
|
+
reasoningLevel?: string;
|
|
108
116
|
surface?: AgentTurnSurface;
|
|
109
117
|
}): Promise<AgentTurnSessionRecord | undefined>;
|
|
110
118
|
/**
|
|
@@ -122,9 +130,11 @@ export declare function persistTimeoutSessionRecord(args: {
|
|
|
122
130
|
source?: Source;
|
|
123
131
|
messages: PiMessage[];
|
|
124
132
|
loadedSkillNames?: string[];
|
|
133
|
+
modelId?: string;
|
|
125
134
|
errorMessage: string;
|
|
126
135
|
logContext: SessionRecordLogContext;
|
|
127
136
|
actor?: Actor;
|
|
137
|
+
reasoningLevel?: string;
|
|
128
138
|
surface?: AgentTurnSurface;
|
|
129
139
|
}): Promise<AgentTurnSessionRecord | undefined>;
|
|
130
140
|
/**
|
|
@@ -141,9 +151,11 @@ export declare function persistYieldSessionRecord(args: {
|
|
|
141
151
|
source?: Source;
|
|
142
152
|
messages: PiMessage[];
|
|
143
153
|
loadedSkillNames?: string[];
|
|
154
|
+
modelId?: string;
|
|
144
155
|
errorMessage: string;
|
|
145
156
|
logContext: SessionRecordLogContext;
|
|
146
157
|
actor?: Actor;
|
|
158
|
+
reasoningLevel?: string;
|
|
147
159
|
surface?: AgentTurnSurface;
|
|
148
160
|
}): Promise<AgentTurnSessionRecord | undefined>;
|
|
149
161
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PiMessage } from "@/chat/pi/messages";
|
|
2
1
|
import type { AuthorizationPauseKind } from "@/chat/services/auth-pause";
|
|
3
2
|
type ConversationRole = "assistant" | "system" | "user";
|
|
4
3
|
export interface ConversationAuthor {
|
|
@@ -66,7 +65,6 @@ export interface ThreadConversationState {
|
|
|
66
65
|
backfill: ConversationBackfillState;
|
|
67
66
|
compactions: ConversationCompaction[];
|
|
68
67
|
messages: ConversationMessage[];
|
|
69
|
-
piMessages: PiMessage[];
|
|
70
68
|
processing: ConversationProcessingState;
|
|
71
69
|
schemaVersion: 1;
|
|
72
70
|
stats: ConversationStats;
|
|
@@ -74,8 +72,13 @@ export interface ThreadConversationState {
|
|
|
74
72
|
}
|
|
75
73
|
/** Safely coerce an unknown persisted value into a ThreadConversationState. */
|
|
76
74
|
export declare function coerceThreadConversationState(value: unknown): ThreadConversationState;
|
|
77
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Wrap a conversation state into the storage envelope for persistence. The
|
|
77
|
+
* visible transcript (`messages`) is not written to `thread-state`; it lives
|
|
78
|
+
* in SQL (`ConversationMessageStore`), and Pi history lives in the SQL
|
|
79
|
+
* `AgentStepStore`. Only runtime scratch is persisted here.
|
|
80
|
+
*/
|
|
78
81
|
export declare function buildConversationStatePatch(conversation: ThreadConversationState): {
|
|
79
|
-
conversation: ThreadConversationState
|
|
82
|
+
conversation: Omit<ThreadConversationState, "compactions" | "messages">;
|
|
80
83
|
};
|
|
81
84
|
export {};
|
|
@@ -3,7 +3,8 @@ import { type Actor } from "@sentry/junior-plugin-api";
|
|
|
3
3
|
import { type PiMessage } from "@/chat/pi/messages";
|
|
4
4
|
import { type StoredSlackActor } from "@/chat/actor";
|
|
5
5
|
declare const piMessageAuthoritySchema: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
|
|
6
|
-
|
|
6
|
+
/** Per-message provenance payload reused by the SQL agent-step envelope. */
|
|
7
|
+
export declare const piMessageProvenanceSchema: z.ZodObject<{
|
|
7
8
|
authority: z.ZodUnion<readonly [z.ZodLiteral<"instruction">, z.ZodLiteral<"context">]>;
|
|
8
9
|
actor: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
9
10
|
platform: z.ZodLiteral<"slack">;
|
|
@@ -27,6 +28,13 @@ declare const piMessageProvenanceSchema: z.ZodObject<{
|
|
|
27
28
|
export type PiMessageAuthority = z.output<typeof piMessageAuthoritySchema>;
|
|
28
29
|
/** Per-message record of the actor a Pi message came from and its authority weight. */
|
|
29
30
|
export type PiMessageProvenance = z.output<typeof piMessageProvenanceSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Recover per-message provenance from a legacy v1 pi_message. A stored Slack
|
|
33
|
+
* actor on the entry meant that user message was the turn instruction, so it
|
|
34
|
+
* decodes to an authored instruction when the identity is intact; anything
|
|
35
|
+
* missing or malformed fails closed to unauthored context.
|
|
36
|
+
*/
|
|
37
|
+
export declare function legacyActorProvenance(actor: StoredSlackActor): PiMessageProvenance;
|
|
30
38
|
declare const authorizationKindSchema: z.ZodUnion<readonly [z.ZodLiteral<"plugin">, z.ZodLiteral<"mcp">]>;
|
|
31
39
|
declare const transcriptRefSchema: z.ZodObject<{
|
|
32
40
|
type: z.ZodLiteral<"advisor_session">;
|
|
@@ -168,6 +176,8 @@ declare const sessionLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
168
176
|
key: z.ZodString;
|
|
169
177
|
}, z.core.$strip>;
|
|
170
178
|
historyMode: z.ZodLiteral<"shared">;
|
|
179
|
+
modelId: z.ZodOptional<z.ZodString>;
|
|
180
|
+
reasoningLevel: z.ZodOptional<z.ZodString>;
|
|
171
181
|
createdAtMs: z.ZodNumber;
|
|
172
182
|
}, z.core.$strip>, z.ZodObject<{
|
|
173
183
|
schemaVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
@@ -218,6 +228,16 @@ export interface SessionProjection {
|
|
|
218
228
|
* distinctness is by identity ids only, never display fields.
|
|
219
229
|
*/
|
|
220
230
|
export declare function instructionActors(provenance: PiMessageProvenance[]): Actor[];
|
|
231
|
+
/**
|
|
232
|
+
* Read the raw decoded legacy session-log entries for one conversation.
|
|
233
|
+
*
|
|
234
|
+
* The single read source for the one-time Redis→SQL history import; it returns
|
|
235
|
+
* every entry in list order (no projection collapsing) so the importer can
|
|
236
|
+
* translate `sessionId` markers into context epochs.
|
|
237
|
+
*/
|
|
238
|
+
export declare function readSessionLogEntries(args: Scope & {
|
|
239
|
+
store?: SessionLogStore;
|
|
240
|
+
}): Promise<SessionLogEntry[]>;
|
|
221
241
|
/** Load chronological host-only runtime activity entries for reporting. */
|
|
222
242
|
export declare function loadActivityEntries(args: Scope & {
|
|
223
243
|
store?: SessionLogStore;
|
|
@@ -304,9 +324,11 @@ export declare function recordToolExecutionStarted(args: Scope & {
|
|
|
304
324
|
export declare function recordSubagentStarted(args: Scope & {
|
|
305
325
|
createdAtMs?: number;
|
|
306
326
|
historyMode: "shared";
|
|
327
|
+
modelId?: string;
|
|
307
328
|
parentConversationId: string;
|
|
308
329
|
parentSessionId?: string;
|
|
309
330
|
parentToolCallId?: string;
|
|
331
|
+
reasoningLevel?: string;
|
|
310
332
|
sessionId?: string;
|
|
311
333
|
store?: SessionLogStore;
|
|
312
334
|
subagentInvocationId: string;
|
|
@@ -19,6 +19,8 @@ export interface AgentTurnSessionRecord {
|
|
|
19
19
|
errorMessage?: string;
|
|
20
20
|
lastProgressAtMs: number;
|
|
21
21
|
loadedSkillNames?: string[];
|
|
22
|
+
modelId?: string;
|
|
23
|
+
reasoningLevel?: string;
|
|
22
24
|
piMessages: PiMessage[];
|
|
23
25
|
/** Per-message provenance aligned one-to-one with `piMessages`. */
|
|
24
26
|
piMessageProvenance: PiMessageProvenance[];
|
|
@@ -57,6 +59,7 @@ export declare function upsertAgentTurnSessionRecord(args: {
|
|
|
57
59
|
source?: Source;
|
|
58
60
|
lastProgressAtMs?: number;
|
|
59
61
|
loadedSkillNames?: string[];
|
|
62
|
+
modelId?: string;
|
|
60
63
|
conversationStore?: ConversationStore;
|
|
61
64
|
sessionId: string;
|
|
62
65
|
sliceId: number;
|
|
@@ -67,6 +70,7 @@ export declare function upsertAgentTurnSessionRecord(args: {
|
|
|
67
70
|
trailingMessageProvenance?: PiMessageProvenance[];
|
|
68
71
|
actor?: Actor;
|
|
69
72
|
resumeReason?: AgentTurnResumeReason;
|
|
73
|
+
reasoningLevel?: string;
|
|
70
74
|
errorMessage?: string;
|
|
71
75
|
resumedFromSliceId?: number;
|
|
72
76
|
traceId?: string;
|
|
@@ -89,9 +93,11 @@ export declare function recordAgentTurnSessionSummary(args: {
|
|
|
89
93
|
source?: Source;
|
|
90
94
|
lastProgressAtMs?: number;
|
|
91
95
|
loadedSkillNames?: string[];
|
|
96
|
+
modelId?: string;
|
|
92
97
|
conversationStore?: ConversationStore;
|
|
93
98
|
actor?: Actor;
|
|
94
99
|
resumeReason?: AgentTurnResumeReason;
|
|
100
|
+
reasoningLevel?: string;
|
|
95
101
|
sessionId: string;
|
|
96
102
|
sliceId: number;
|
|
97
103
|
startedAtMs?: number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Mark one tool result as an adapter-approved private trace projection. */
|
|
2
|
+
export declare function privateTraceResultAttributes(): Record<string, string>;
|
|
3
|
+
/** Consume and remove the adapter-owned private trace projection marker. */
|
|
4
|
+
export declare function consumePrivateTraceResultMarker(attributes: Record<string, unknown>): boolean;
|
|
@@ -13,6 +13,7 @@ export interface ContentOnlyToolResult {
|
|
|
13
13
|
}
|
|
14
14
|
type StructuredZodToolDefinition<TInputSchema extends ZodTypeAny, TOutputSchema extends ZodType<JuniorToolResult>> = ZodToolDefinitionBase<TInputSchema> & {
|
|
15
15
|
outputSchema: TOutputSchema;
|
|
16
|
+
privateTraceResult?(result: z.output<TOutputSchema>): unknown;
|
|
16
17
|
execute?: (input: z.output<TInputSchema>, options: ToolExecuteOptions) => Promise<StructuredToolExecuteResult<TOutputSchema>> | StructuredToolExecuteResult<TOutputSchema>;
|
|
17
18
|
};
|
|
18
19
|
type ContentZodToolDefinition<TInputSchema extends ZodTypeAny> = ZodToolDefinitionBase<TInputSchema> & {
|
|
@@ -2,7 +2,7 @@ import { type AgentTool, type StreamFn } from "@earendil-works/pi-agent-core";
|
|
|
2
2
|
import type { AdvisorConfig } from "@/chat/config";
|
|
3
3
|
import { type ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
4
4
|
import { type LogContext } from "@/chat/logging";
|
|
5
|
-
import {
|
|
5
|
+
import type { ConversationStore } from "@/chat/conversations/store";
|
|
6
6
|
import type { AnyToolDefinition } from "@/chat/tools/definition";
|
|
7
7
|
export type AdvisorErrorCode = "invalid_context" | "invalid_question" | "missing_conversation_id" | "session_unavailable" | "unavailable";
|
|
8
8
|
export type AdvisorToolResult = {
|
|
@@ -17,13 +17,18 @@ export interface AdvisorToolRuntimeContext {
|
|
|
17
17
|
conversationPrivacy?: ConversationPrivacy;
|
|
18
18
|
getTools: () => AgentTool[];
|
|
19
19
|
logContext?: LogContext;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
/** Metadata store used to link the advisor child conversation to its parent. */
|
|
21
|
+
conversationStore?: ConversationStore;
|
|
22
22
|
streamFn?: StreamFn;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Deterministic advisor child conversation id derived from the parent so
|
|
26
|
+
* repeated advisor calls in one parent conversation append to the same history.
|
|
27
|
+
*/
|
|
28
|
+
export declare function advisorChildConversationId(parentConversationId: string): string;
|
|
24
29
|
/** Build the advisor's read-only tool definition subset. */
|
|
25
30
|
export declare function createAdvisorToolDefinitions(definitions: Record<string, AnyToolDefinition>): Record<string, AnyToolDefinition>;
|
|
26
|
-
/** Create the advisor tool backed by conversation
|
|
31
|
+
/** Create the advisor tool backed by a child-conversation message history. */
|
|
27
32
|
export declare function createAdvisorTool(context: AdvisorToolRuntimeContext): Omit<AnyToolDefinition, "inputSchema" | "outputSchema" | "prepareArguments" | "execute"> & {
|
|
28
33
|
inputSchema: import("@/chat/tools/definition").JsonSchemaObject;
|
|
29
34
|
outputSchema: import("@/chat/tools/definition").JsonSchemaObject;
|
|
@@ -32,6 +32,7 @@ interface BaseToolDefinition<TInput, TInputSchema extends ToolInputSchema> {
|
|
|
32
32
|
exposure?: ToolExposure;
|
|
33
33
|
inputSchema: TInputSchema;
|
|
34
34
|
outputSchema?: ToolInputSchema;
|
|
35
|
+
privateTraceResult?(result: unknown): unknown;
|
|
35
36
|
annotations?: ToolAnnotations;
|
|
36
37
|
/**
|
|
37
38
|
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
@@ -70,6 +71,7 @@ export interface AnyToolDefinition {
|
|
|
70
71
|
exposure?: ToolExposure;
|
|
71
72
|
inputSchema: ToolInputSchema;
|
|
72
73
|
outputSchema?: ToolInputSchema;
|
|
74
|
+
privateTraceResult?(result: unknown): unknown;
|
|
73
75
|
annotations?: ToolAnnotations;
|
|
74
76
|
/**
|
|
75
77
|
* @deprecated Put tool-selection and usage guidance directly in `description`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LogContext } from "@/chat/logging";
|
|
1
|
+
import { type LogContext, type SetSpanAttributes } from "@/chat/logging";
|
|
2
2
|
import type { ConversationPrivacy } from "@/chat/conversation-privacy";
|
|
3
3
|
/** Handle tool execution errors: set span attributes, log, and rethrow. */
|
|
4
|
-
export declare function handleToolExecutionError(error: unknown, toolName: string, toolCallId: string | undefined, shouldTrace: boolean, traceContext: LogContext, conversationPrivacy?: ConversationPrivacy): never;
|
|
4
|
+
export declare function handleToolExecutionError(error: unknown, toolName: string, toolCallId: string | undefined, shouldTrace: boolean, traceContext: LogContext, conversationPrivacy?: ConversationPrivacy, setExecutionSpanAttributes?: SetSpanAttributes): never;
|
|
@@ -6,6 +6,10 @@ export declare function createSystemTimeTool(): Omit<import("./definition").AnyT
|
|
|
6
6
|
[x: string]: unknown;
|
|
7
7
|
ok: boolean;
|
|
8
8
|
status: "error" | "success";
|
|
9
|
+
unix_ms: number;
|
|
10
|
+
iso_utc: string;
|
|
11
|
+
iso_local: string;
|
|
12
|
+
timezone_offset_minutes: number;
|
|
9
13
|
target?: string | undefined;
|
|
10
14
|
data?: unknown;
|
|
11
15
|
truncated?: boolean | undefined;
|
|
@@ -22,6 +26,10 @@ export declare function createSystemTimeTool(): Omit<import("./definition").AnyT
|
|
|
22
26
|
[x: string]: unknown;
|
|
23
27
|
ok: boolean;
|
|
24
28
|
status: "error" | "success";
|
|
29
|
+
unix_ms: number;
|
|
30
|
+
iso_utc: string;
|
|
31
|
+
iso_local: string;
|
|
32
|
+
timezone_offset_minutes: number;
|
|
25
33
|
target?: string | undefined;
|
|
26
34
|
data?: unknown;
|
|
27
35
|
truncated?: boolean | undefined;
|
package/dist/chat/xml.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CRRBJ3JP.js";
|
|
4
4
|
import {
|
|
5
|
+
getChatConfig,
|
|
5
6
|
getDefaultRedisStateAdapterFor,
|
|
6
7
|
getStateAdapter
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
getChatConfig
|
|
10
|
-
} from "./chunk-NAPITCZ6.js";
|
|
8
|
+
} from "./chunk-GUE7HTNR.js";
|
|
11
9
|
import {
|
|
12
10
|
parseDestination,
|
|
13
11
|
sameDestination
|
|
14
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-B7PUBQQM.js";
|
|
15
13
|
import {
|
|
16
14
|
parseStoredSlackActor
|
|
17
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WPOJ443W.js";
|
|
18
16
|
import {
|
|
19
17
|
isRecord,
|
|
20
18
|
toOptionalNumber,
|