@morty-build/cli 0.1.1 → 0.3.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/NOTICE +1 -1
- package/dist/{chunk-6KNXEAOQ.js → chunk-HIGGFLQ3.js} +159 -186
- package/dist/{chunk-6KNXEAOQ.js.map → chunk-HIGGFLQ3.js.map} +4 -4
- package/dist/{chunk-B4H65VAU.js → chunk-SYR2NZQ5.js} +2 -2
- package/dist/{chunk-B4H65VAU.js.map → chunk-SYR2NZQ5.js.map} +1 -1
- package/dist/cli/handler/agents/index.js +2 -2
- package/dist/cli/handler/agents/index.js.map +1 -1
- package/dist/cli/handler/daemon/install.js +3 -3
- package/dist/cli/handler/daemon/install.js.map +1 -1
- package/dist/cli/handler/daemon/quit.js +2 -2
- package/dist/cli/handler/daemon/quit.js.map +1 -1
- package/dist/cli/handler/daemon/release.js +2 -2
- package/dist/cli/handler/daemon/release.js.map +1 -1
- package/dist/cli/handler/daemon/start.d.ts.map +1 -1
- package/dist/cli/handler/daemon/start.js +3 -3
- package/dist/cli/handler/daemon/start.js.map +1 -1
- package/dist/cli/handler/daemon/upgrade.js +2 -2
- package/dist/cli/handler/daemon/upgrade.js.map +1 -1
- package/dist/cli/handler/diagnose/worker.js +2 -2
- package/dist/cli/handler/diagnose/worker.js.map +1 -1
- package/dist/cli/handler/logs/index.js +1 -1
- package/dist/cli/handler/logs/index.js.map +1 -1
- package/dist/cli/handler/pair/list.js +2 -2
- package/dist/cli/handler/pair/list.js.map +1 -1
- package/dist/cli/handler/pair/pair.js +3 -3
- package/dist/cli/handler/pair/pair.js.map +1 -1
- package/dist/cli/handler/pair/remove.d.ts.map +1 -1
- package/dist/cli/handler/pair/remove.js +3 -3
- package/dist/cli/handler/pair/remove.js.map +1 -1
- package/dist/cli/handler/pair/stop.d.ts.map +1 -1
- package/dist/cli/handler/pair/stop.js +3 -3
- package/dist/cli/handler/pair/stop.js.map +1 -1
- package/dist/cli/handler/version/index.js +2 -2
- package/dist/cli/handler/version/index.js.map +1 -1
- package/dist/{cli-6OIRF2M7.js → cli-QFRCPBAC.js} +36 -36
- package/dist/{cli-6OIRF2M7.js.map → cli-QFRCPBAC.js.map} +2 -2
- package/dist/cli.js +2 -2
- package/dist/daemon/config.d.ts +1 -1
- package/dist/daemon/config.d.ts.map +1 -1
- package/dist/daemon/config.js +1 -1
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/lifecycle/daemon.js +5 -5
- package/dist/daemon/lifecycle/daemon.js.map +1 -1
- package/dist/daemon/pairing/pair-local-machine.d.ts +2 -2
- package/dist/daemon/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/daemon/pairing/pair-local-machine.js +7 -7
- package/dist/daemon/pairing/pair-local-machine.js.map +1 -1
- package/dist/engine/acp/adapter/agent-initialization.js +2 -2
- package/dist/engine/acp/adapter/agent-initialization.js.map +1 -1
- package/dist/engine/acp/adapter/codex/adapter.js +3 -3
- package/dist/engine/acp/adapter/codex/adapter.js.map +1 -1
- package/dist/engine/acp/adapter/session-events.d.ts +2 -2
- package/dist/engine/acp/adapter/session-events.d.ts.map +1 -1
- package/dist/engine/acp/adapter/session-events.js +5 -5
- package/dist/engine/acp/adapter/session-events.js.map +1 -1
- package/dist/engine/acp/agent/in-process-endpoint.d.ts +2 -2
- package/dist/engine/acp/agent/in-process-endpoint.d.ts.map +1 -1
- package/dist/engine/acp/client/prompt-content.js +1 -1
- package/dist/engine/acp/client/prompt-content.js.map +1 -1
- package/dist/engine/acp/connection/create-client.js +1 -1
- package/dist/engine/acp/connection/create-client.js.map +1 -1
- package/dist/engine/acp/content/content-externalizer.js +1 -1
- package/dist/engine/acp/content/content-externalizer.js.map +1 -1
- package/dist/engine/acp/harness/codex/agent.d.ts +2 -2
- package/dist/engine/acp/harness/codex/agent.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/agent.js +8 -8
- package/dist/engine/acp/harness/codex/agent.js.map +1 -1
- package/dist/engine/acp/harness/codex/app-server-client.d.ts +1 -1
- package/dist/engine/acp/harness/codex/app-server-client.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/app-server-client.js +2 -2
- package/dist/engine/acp/harness/codex/app-server-client.js.map +1 -1
- package/dist/engine/acp/harness/codex/app-server-protocol.js +6 -6
- package/dist/engine/acp/harness/codex/app-server-protocol.js.map +1 -1
- package/dist/engine/acp/harness/codex/items.d.ts +1 -1
- package/dist/engine/acp/harness/codex/items.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/items.js +3 -3
- package/dist/engine/acp/harness/codex/items.js.map +1 -1
- package/dist/engine/acp/harness/codex/owned-agent.js +8 -8
- package/dist/engine/acp/harness/codex/owned-agent.js.map +1 -1
- package/dist/engine/acp/harness/codex/settings.d.ts +1 -1
- package/dist/engine/acp/harness/codex/settings.d.ts.map +1 -1
- package/dist/engine/acp/harness/codex/settings.js +1 -1
- package/dist/engine/acp/harness/codex/settings.js.map +1 -1
- package/dist/engine/acp/harness/pi/endpoint.js +1 -1
- package/dist/engine/acp/harness/pi/endpoint.js.map +1 -1
- package/dist/engine/acp/protocol/elicitation.js +1 -1
- package/dist/engine/acp/protocol/elicitation.js.map +1 -1
- package/dist/engine/acp/protocol/session-config-protocol.js +1 -1
- package/dist/engine/acp/protocol/session-config-protocol.js.map +1 -1
- package/dist/engine/agent/discovery/acp-readiness-probe.js +1 -1
- package/dist/engine/agent/discovery/acp-readiness-probe.js.map +1 -1
- package/dist/engine/agent/discovery/agent-discovery-context.d.ts +1 -1
- package/dist/engine/agent/discovery/agent-discovery-context.d.ts.map +1 -1
- package/dist/engine/agent/specification/agent-specification.d.ts +2 -2
- package/dist/engine/agent/specification/agent-specification.js +2 -2
- package/dist/engine/agent/specification/vendors/codex-agent.js +1 -1
- package/dist/engine/agent/specification/vendors/codex-agent.js.map +1 -1
- package/dist/engine/agent/specification/vendors/pi-agent.js +2 -2
- package/dist/engine/agent/specification/vendors/pi-agent.js.map +1 -1
- package/dist/engine/runtime/catalog/discover-agent-catalog.js +1 -1
- package/dist/engine/runtime/catalog/discover-agent-catalog.js.map +1 -1
- package/dist/engine/runtime/command/native-session-requests.d.ts.map +1 -1
- package/dist/engine/runtime/command/native-session-requests.js +2 -4
- package/dist/engine/runtime/command/native-session-requests.js.map +1 -1
- package/dist/engine/runtime/command/registry/history.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/history.js +1 -0
- package/dist/engine/runtime/command/registry/history.js.map +1 -1
- package/dist/engine/runtime/command/registry/interactions.js +3 -3
- package/dist/engine/runtime/command/registry/interactions.js.map +1 -1
- package/dist/engine/runtime/command/registry/prompt.js +1 -1
- package/dist/engine/runtime/command/registry/prompt.js.map +1 -1
- package/dist/engine/runtime/connection/runtime-installation-store.d.ts.map +1 -1
- package/dist/engine/runtime/connection/runtime-installation-store.js +5 -13
- package/dist/engine/runtime/connection/runtime-installation-store.js.map +1 -1
- package/dist/engine/runtime/engine.d.ts +9 -9
- package/dist/engine/runtime/engine.d.ts.map +1 -1
- package/dist/engine/runtime/engine.js +1 -1
- package/dist/engine/runtime/engine.js.map +1 -1
- package/dist/engine/runtime/pairing.d.ts +2 -2
- package/dist/engine/runtime/pairing.d.ts.map +1 -1
- package/dist/engine/runtime/pairing.js +8 -13
- package/dist/engine/runtime/pairing.js.map +1 -1
- package/dist/engine/runtime/runtime-loop.d.ts +2 -2
- package/dist/engine/runtime/runtime-loop.d.ts.map +1 -1
- package/dist/engine/runtime/runtime-loop.js.map +1 -1
- package/dist/engine/session/api/session-layer.js +1 -1
- package/dist/engine/session/api/session-layer.js.map +1 -1
- package/dist/engine/session/content/external-content-store.js +3 -3
- package/dist/engine/session/content/external-content-store.js.map +1 -1
- package/dist/engine/session/interaction/session-interactions.js +1 -1
- package/dist/engine/session/interaction/session-interactions.js.map +1 -1
- package/dist/engine/session/live/agent-session.js +22 -22
- package/dist/engine/session/live/agent-session.js.map +1 -1
- package/dist/engine/session/manager/session-manager.d.ts +1 -1
- package/dist/engine/session/manager/session-manager.js +1 -1
- package/dist/engine/session/native/native-session-browser.js +1 -1
- package/dist/engine/session/native/native-session-browser.js.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js +6 -3
- package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
- package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
- package/dist/engine/session/turn/active-turn.js +4 -3
- package/dist/engine/session/turn/active-turn.js.map +1 -1
- package/dist/engine/session/turn/execution-receipts.d.ts +3 -1
- package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/engine/session/turn/execution-receipts.js +2 -12
- package/dist/engine/session/turn/execution-receipts.js.map +1 -1
- package/dist/engine/session/turn/session-turns.d.ts +3 -3
- package/dist/engine/storage/session/command-cancellation-table.d.ts +1 -1
- package/dist/engine/storage/session/command-cancellation-table.d.ts.map +1 -1
- package/dist/engine/storage/session/command-cancellation-table.js +1 -1
- package/dist/engine/storage/session/command-cancellation-table.js.map +1 -1
- package/dist/engine/storage/session/session-event-cache-table.js +3 -3
- package/dist/engine/storage/session/session-event-cache-table.js.map +1 -1
- package/dist/engine/storage/session/temporary-session-event-cache.js +1 -1
- package/dist/engine/storage/session/temporary-session-event-cache.js.map +1 -1
- package/dist/engine/storage/sqlite/local-databases.d.ts +1 -1
- package/dist/engine/storage/sqlite/local-databases.d.ts.map +1 -1
- package/dist/engine/storage/sqlite/local-databases.js +1 -26
- package/dist/engine/storage/sqlite/local-databases.js.map +1 -1
- package/dist/engine/storage/sqlite/local-sqlite-database.js +1 -1
- package/dist/engine/storage/sqlite/local-sqlite-database.js.map +1 -1
- package/dist/engine/util/platform/posix.d.ts.map +1 -1
- package/dist/engine/util/platform/posix.js +8 -1
- package/dist/engine/util/platform/posix.js.map +1 -1
- package/dist/engine.js +4 -4
- package/dist/exports/engine.d.ts +2 -2
- package/dist/exports/engine.d.ts.map +1 -1
- package/dist/exports/engine.js +1 -1
- package/dist/exports/engine.js.map +1 -1
- package/dist/storage/state-directory.d.ts +1 -1
- package/dist/storage/state-root-layout.d.ts +1 -1
- package/dist/storage/state-root-layout.d.ts.map +1 -1
- package/dist/storage/state-root-layout.js +1 -1
- package/dist/storage/state-root-layout.js.map +1 -1
- package/dist/storage/state-root.d.ts +1 -1
- package/dist/storage/state-root.d.ts.map +1 -1
- package/dist/storage/state-root.js +1 -1
- package/dist/storage/state-root.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__export,
|
|
4
4
|
__using,
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SYR2NZQ5.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -85,27 +85,27 @@ var ConnectionManager = class {
|
|
|
85
85
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
86
86
|
import { resolve } from "node:path";
|
|
87
87
|
|
|
88
|
-
// ../client/src/protocol/platform/
|
|
89
|
-
var MORTY_API_PREFIX = "/
|
|
88
|
+
// ../client/src/protocol/platform/morty-api.ts
|
|
89
|
+
var MORTY_API_PREFIX = "/morty/api";
|
|
90
90
|
var API_PREFIX_PATTERN = /^\/[a-zA-Z0-9._~-]+(?:\/[a-zA-Z0-9._~-]+)*$/;
|
|
91
|
-
var
|
|
91
|
+
var MortyApiConfigurationError = class extends Error {
|
|
92
92
|
code = "invalid_api_prefix";
|
|
93
93
|
constructor() {
|
|
94
|
-
super("The
|
|
95
|
-
this.name = "
|
|
94
|
+
super("The Morty API prefix must be an absolute path without parameters");
|
|
95
|
+
this.name = "MortyApiConfigurationError";
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
function
|
|
98
|
+
function parseMortyApiPrefix(value) {
|
|
99
99
|
if (typeof value !== "string" || !API_PREFIX_PATTERN.test(value)) {
|
|
100
|
-
throw new
|
|
100
|
+
throw new MortyApiConfigurationError();
|
|
101
101
|
}
|
|
102
102
|
return value;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return `${
|
|
104
|
+
function mortyApiPath(resourcePath, apiPrefix = MORTY_API_PREFIX) {
|
|
105
|
+
return `${parseMortyApiPrefix(apiPrefix)}${resourcePath}`;
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
return new URL(
|
|
107
|
+
function mortyApiUrl(origin, resourcePath, apiPrefix = MORTY_API_PREFIX) {
|
|
108
|
+
return new URL(mortyApiPath(resourcePath, apiPrefix), origin);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
|
|
@@ -20087,16 +20087,16 @@ var sessionStatusSchema = external_exports.discriminatedUnion("kind", [
|
|
|
20087
20087
|
/**
|
|
20088
20088
|
* Present when the Session's most recent started command failed, while the Runtime retains its receipt, so
|
|
20089
20089
|
* a client that did not watch it can still show the Session failed until another command starts. It
|
|
20090
|
-
* carries what the execution's `lastTurn` reports for that failure.
|
|
20090
|
+
* carries what the execution's `lastTurn` reports for that failure.
|
|
20091
20091
|
*/
|
|
20092
|
-
failedTurn: external_exports.object({ code: identifierStringSchema, commandId: identifierStringSchema, message: external_exports.string().min(1).max(500) }).readonly().optional()
|
|
20092
|
+
failedTurn: external_exports.object({ code: identifierStringSchema, commandId: identifierStringSchema, message: external_exports.string().min(1).max(500) }).readonly().optional()
|
|
20093
20093
|
}).readonly(),
|
|
20094
20094
|
external_exports.object({
|
|
20095
20095
|
commandId: identifierStringSchema,
|
|
20096
20096
|
kind: external_exports.literal("working")
|
|
20097
20097
|
}).readonly()
|
|
20098
20098
|
]);
|
|
20099
|
-
var sessionCapabilitiesSchema = external_exports.
|
|
20099
|
+
var sessionCapabilitiesSchema = external_exports.strictObject({
|
|
20100
20100
|
additionalDirectories: external_exports.boolean(),
|
|
20101
20101
|
audioPrompt: external_exports.boolean(),
|
|
20102
20102
|
closeSession: external_exports.boolean(),
|
|
@@ -20105,11 +20105,11 @@ var sessionCapabilitiesSchema = external_exports.object({
|
|
|
20105
20105
|
imagePrompt: external_exports.boolean(),
|
|
20106
20106
|
listSessions: external_exports.boolean(),
|
|
20107
20107
|
loadSession: external_exports.boolean(),
|
|
20108
|
-
promptQueueing: external_exports.boolean()
|
|
20109
|
-
renameSession: external_exports.boolean()
|
|
20108
|
+
promptQueueing: external_exports.boolean(),
|
|
20109
|
+
renameSession: external_exports.boolean(),
|
|
20110
20110
|
resumeSession: external_exports.boolean(),
|
|
20111
|
-
steering: external_exports.boolean()
|
|
20112
|
-
unstableForkSession: external_exports.boolean()
|
|
20111
|
+
steering: external_exports.boolean(),
|
|
20112
|
+
unstableForkSession: external_exports.boolean()
|
|
20113
20113
|
}).readonly();
|
|
20114
20114
|
var sessionCommandSchema = external_exports.object({
|
|
20115
20115
|
description: SHORT_TEXT,
|
|
@@ -20162,13 +20162,12 @@ var agentModelEffortSchema = external_exports.object({
|
|
|
20162
20162
|
effortSettingId: external_exports.string().max(128),
|
|
20163
20163
|
modelSettingId: external_exports.string().max(128),
|
|
20164
20164
|
resolution: agentModelEffortResolutionSchema,
|
|
20165
|
-
unsupportedModelIds: external_exports.array(external_exports.string().min(1).max(500)).max(500).readonly()
|
|
20165
|
+
unsupportedModelIds: external_exports.array(external_exports.string().min(1).max(500)).max(500).readonly(),
|
|
20166
20166
|
valuesByModel: external_exports.record(external_exports.string().min(1).max(500), external_exports.array(configValueSchema).max(500).readonly()).readonly()
|
|
20167
20167
|
}).readonly();
|
|
20168
20168
|
var agentSettingsDiscoverCommandSchema = external_exports.object({
|
|
20169
20169
|
agentId: identifierStringSchema,
|
|
20170
|
-
// The directory
|
|
20171
|
-
// default directory. A Runtime that predates this field ignores it; see the discovered event's `directoryId`.
|
|
20170
|
+
// The directory whose project settings the Agent reads. Omitted means the default directory.
|
|
20172
20171
|
directoryId: DIRECTORY_IDENTIFIER.optional(),
|
|
20173
20172
|
kind: external_exports.literal(AGENT_SETTINGS_DISCOVER_KIND),
|
|
20174
20173
|
model: external_exports.string().min(1).max(500).optional(),
|
|
@@ -20178,9 +20177,8 @@ var agentSettingsDiscoveredEventSchema = external_exports.object({
|
|
|
20178
20177
|
agentId: identifierStringSchema,
|
|
20179
20178
|
agentName: external_exports.string().max(255),
|
|
20180
20179
|
agentVersion: external_exports.string().max(128),
|
|
20181
|
-
// The directory
|
|
20182
|
-
|
|
20183
|
-
directoryId: DIRECTORY_IDENTIFIER.optional(),
|
|
20180
|
+
// The directory actually inspected.
|
|
20181
|
+
directoryId: DIRECTORY_IDENTIFIER,
|
|
20184
20182
|
kind: external_exports.literal(AGENT_SETTINGS_DISCOVERED_KIND),
|
|
20185
20183
|
modelEffort: agentModelEffortSchema,
|
|
20186
20184
|
requestId: identifierStringSchema,
|
|
@@ -20435,12 +20433,11 @@ var elicitationFieldSchema = external_exports.object({
|
|
|
20435
20433
|
}).readonly();
|
|
20436
20434
|
var sessionPermissionRequestedEventSchema = external_exports.object({
|
|
20437
20435
|
commandId: identifierStringSchema,
|
|
20438
|
-
// Absent only for events from older runtimes and saved history.
|
|
20439
20436
|
details: external_exports.object({
|
|
20440
20437
|
cwd: external_exports.string().min(1).max(4096),
|
|
20441
20438
|
rawInput: boundedJsonSchema.optional(),
|
|
20442
20439
|
locations: external_exports.array(toolCallLocationSchema).max(1e3).readonly()
|
|
20443
|
-
}).readonly()
|
|
20440
|
+
}).readonly(),
|
|
20444
20441
|
interactionId: identifierStringSchema,
|
|
20445
20442
|
kind: external_exports.literal(SESSION_PERMISSION_REQUESTED_KIND),
|
|
20446
20443
|
options: external_exports.array(permissionOptionSchema).min(1).max(20).readonly(),
|
|
@@ -20832,14 +20829,14 @@ var sessionEventPayloadSchema = external_exports.discriminatedUnion("type", [
|
|
|
20832
20829
|
external_exports.object({ payload: lifecycleMetadataSchema, type: external_exports.literal("lifecycle-metadata") }).readonly()
|
|
20833
20830
|
]);
|
|
20834
20831
|
var positionSchema = external_exports.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
20835
|
-
var
|
|
20832
|
+
var mortyMetadataFields = {
|
|
20836
20833
|
omitted: external_exports.literal(true).optional(),
|
|
20837
20834
|
recordedOutcome: external_exports.literal(true).optional(),
|
|
20838
20835
|
restated: external_exports.literal(true).optional()
|
|
20839
20836
|
};
|
|
20840
20837
|
var sharedSessionEventFields = {
|
|
20841
20838
|
eventId: identifierStringSchema,
|
|
20842
|
-
|
|
20839
|
+
mortyMetadata: external_exports.object(mortyMetadataFields).readonly().optional(),
|
|
20843
20840
|
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
20844
20841
|
sessionGenerationId: identifierStringSchema,
|
|
20845
20842
|
sessionId: identifierStringSchema
|
|
@@ -20862,7 +20859,7 @@ var wireLifecyclePayloadSchema = external_exports.object({
|
|
|
20862
20859
|
}).passthrough().readonly();
|
|
20863
20860
|
var wireEventFields = {
|
|
20864
20861
|
...sessionLiveEventFields,
|
|
20865
|
-
|
|
20862
|
+
mortyMetadata: external_exports.object(mortyMetadataFields).passthrough().readonly().optional()
|
|
20866
20863
|
};
|
|
20867
20864
|
var sessionWireEventSchema = external_exports.union([
|
|
20868
20865
|
external_exports.object({
|
|
@@ -20898,9 +20895,8 @@ var promptMessageOutcomeSchema = external_exports.object({
|
|
|
20898
20895
|
var sessionEventLogPageSchema = external_exports.object({
|
|
20899
20896
|
events: external_exports.array(sessionEventSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
20900
20897
|
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
20901
|
-
//
|
|
20902
|
-
|
|
20903
|
-
promptOutcomes: external_exports.array(promptMessageOutcomeSchema).max(MAX_EVENT_COUNT).readonly().optional(),
|
|
20898
|
+
// Retained settled prompts whose user message is on this page; empty outside Session history.
|
|
20899
|
+
promptOutcomes: external_exports.array(promptMessageOutcomeSchema).max(MAX_EVENT_COUNT).readonly(),
|
|
20904
20900
|
sessionGenerationId: identifierStringSchema,
|
|
20905
20901
|
tailCursor: external_exports.string().max(512),
|
|
20906
20902
|
// The generation-scoped live position covered by this snapshot, including
|
|
@@ -21156,7 +21152,7 @@ var sessionMetadataSchema = external_exports.object({
|
|
|
21156
21152
|
directoryLabel: external_exports.string().min(1).max(MAX_WORKSPACE_PATH_LENGTH),
|
|
21157
21153
|
prompted: external_exports.boolean(),
|
|
21158
21154
|
sessionId: identifierStringSchema,
|
|
21159
|
-
status: sessionStatusSchema
|
|
21155
|
+
status: sessionStatusSchema,
|
|
21160
21156
|
title: external_exports.string().max(500),
|
|
21161
21157
|
updatedAt: external_exports.iso.datetime({ offset: true })
|
|
21162
21158
|
}).readonly();
|
|
@@ -21345,7 +21341,7 @@ var promptAttachmentSchema = external_exports.object({
|
|
|
21345
21341
|
var decodePromptAttachmentsValue = (value) => decodeZodValue(value, external_exports.array(promptAttachmentSchema).max(16).readonly());
|
|
21346
21342
|
function readPromptDisposition(value) {
|
|
21347
21343
|
const field = value["disposition"];
|
|
21348
|
-
if (field ===
|
|
21344
|
+
if (field === SessionPromptDisposition.Reject) {
|
|
21349
21345
|
return SessionPromptDisposition.Reject;
|
|
21350
21346
|
}
|
|
21351
21347
|
if (field === SessionPromptDisposition.Queue) {
|
|
@@ -21370,8 +21366,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21370
21366
|
throw new ProtocolMessageError("Prompt must contain content");
|
|
21371
21367
|
}
|
|
21372
21368
|
const disposition = readPromptDisposition(value);
|
|
21373
|
-
const
|
|
21374
|
-
const targetCommandId = rawTargetCommandId === void 0 ? "" : readText(value, "targetCommandId", 128);
|
|
21369
|
+
const targetCommandId = readText(value, "targetCommandId", 128);
|
|
21375
21370
|
if (disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0 || disposition !== SessionPromptDisposition.Reject && !isIdentifier(targetCommandId)) {
|
|
21376
21371
|
throw new ProtocolMessageError("Prompt disposition has an invalid target command");
|
|
21377
21372
|
}
|
|
@@ -21387,9 +21382,7 @@ function decodeSessionPromptCommand(encoded) {
|
|
|
21387
21382
|
directoryId: readDirectoryIdentifier(value, "directoryId"),
|
|
21388
21383
|
disposition,
|
|
21389
21384
|
attachments,
|
|
21390
|
-
|
|
21391
|
-
historyPolicy: readHistoryPolicy(value)
|
|
21392
|
-
},
|
|
21385
|
+
historyPolicy: readHistoryPolicy(value),
|
|
21393
21386
|
kind: SESSION_PROMPT_KIND,
|
|
21394
21387
|
prompt,
|
|
21395
21388
|
...hasSessionConfigurations ? { sessionConfigurations } : {},
|
|
@@ -21459,8 +21452,8 @@ var activeTurnSnapshotSchema = external_exports.object({
|
|
|
21459
21452
|
epoch: identifierStringSchema,
|
|
21460
21453
|
interaction: external_exports.discriminatedUnion("kind", [sessionPermissionRequestedEventSchema, sessionElicitationRequestedEventSchema]).nullable(),
|
|
21461
21454
|
sequence: external_exports.number().int().nonnegative(),
|
|
21462
|
-
// When the
|
|
21463
|
-
startedAt: external_exports.iso.datetime({ offset: true })
|
|
21455
|
+
// When the Runtime recorded the start of this running turn.
|
|
21456
|
+
startedAt: external_exports.iso.datetime({ offset: true }),
|
|
21464
21457
|
state: external_exports.literal("running")
|
|
21465
21458
|
}).readonly();
|
|
21466
21459
|
var commandDeliverySchema = external_exports.discriminatedUnion("state", [
|
|
@@ -21536,7 +21529,7 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
|
|
|
21536
21529
|
]);
|
|
21537
21530
|
var nativeSessionEntrySchema = external_exports.object({
|
|
21538
21531
|
entryId: identifierStringSchema,
|
|
21539
|
-
|
|
21532
|
+
mortySessionIds: external_exports.array(identifierStringSchema).max(500).readonly(),
|
|
21540
21533
|
nativeSessionId: identifierStringSchema,
|
|
21541
21534
|
title: external_exports.string().max(500),
|
|
21542
21535
|
directoryId: DIRECTORY_IDENTIFIER,
|
|
@@ -21561,13 +21554,12 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
|
|
|
21561
21554
|
}).readonly()
|
|
21562
21555
|
).readonly(),
|
|
21563
21556
|
turn: activeTurnSnapshotSchema.nullable(),
|
|
21564
|
-
//
|
|
21565
|
-
interactionState: sessionInteractionSnapshotSchema.
|
|
21566
|
-
// Present only when the request named a command
|
|
21567
|
-
|
|
21568
|
-
command
|
|
21569
|
-
|
|
21570
|
-
lastTurn: lastTurnOutcomeSchema.optional().catch(void 0),
|
|
21557
|
+
// Null when this Runtime has no retained Session for the requested identity.
|
|
21558
|
+
interactionState: sessionInteractionSnapshotSchema.nullable(),
|
|
21559
|
+
// Present only when the request named a command.
|
|
21560
|
+
command: commandDeliverySchema.optional(),
|
|
21561
|
+
// Absent while the last started command is running or none has started.
|
|
21562
|
+
lastTurn: lastTurnOutcomeSchema.optional(),
|
|
21571
21563
|
// The Runtime withdraws a queued command only before it starts.
|
|
21572
21564
|
queuedCancellation: external_exports.literal("before-start")
|
|
21573
21565
|
}).readonly(),
|
|
@@ -22240,7 +22232,12 @@ async function removeControlSocket(path7) {
|
|
|
22240
22232
|
}
|
|
22241
22233
|
}
|
|
22242
22234
|
var posixOperations = {
|
|
22243
|
-
controlSocketPath: (installationHash) =>
|
|
22235
|
+
controlSocketPath: (installationHash) => {
|
|
22236
|
+
const directory = `morty-${process.getuid?.()}`;
|
|
22237
|
+
const filename = `${installationHash}.sock`;
|
|
22238
|
+
const preferred = join2(tmpdir(), directory, filename);
|
|
22239
|
+
return Buffer.byteLength(preferred) < 104 ? preferred : join2("/tmp", directory, filename);
|
|
22240
|
+
},
|
|
22244
22241
|
prepareControlSocket: async (path7) => {
|
|
22245
22242
|
const directory = dirname2(path7);
|
|
22246
22243
|
await mkdir3(directory, { mode: 448, recursive: true });
|
|
@@ -22659,15 +22656,11 @@ function decodeInstallationPointer(value) {
|
|
|
22659
22656
|
}
|
|
22660
22657
|
return { installationId: validateInstallationId(storedInstallationId) };
|
|
22661
22658
|
}
|
|
22662
|
-
function
|
|
22663
|
-
|
|
22664
|
-
}
|
|
22665
|
-
function decodeChannelIndex(input2) {
|
|
22666
|
-
if (!isRecord3(input2)) {
|
|
22659
|
+
function decodeChannelIndex(value) {
|
|
22660
|
+
if (!isRecord3(value)) {
|
|
22667
22661
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
22668
22662
|
}
|
|
22669
|
-
|
|
22670
|
-
if (!hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1 && value["version"] !== 2) {
|
|
22663
|
+
if (!hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 2) {
|
|
22671
22664
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
22672
22665
|
}
|
|
22673
22666
|
const channelId = value["channelId"];
|
|
@@ -22683,7 +22676,7 @@ function decodeChannelIndex(input2) {
|
|
|
22683
22676
|
};
|
|
22684
22677
|
}
|
|
22685
22678
|
function decodeVerifiedConnection(value) {
|
|
22686
|
-
if (!hasExactKeys(value, VERIFIED_CONNECTION_KEYS) || value["version"] !==
|
|
22679
|
+
if (!hasExactKeys(value, VERIFIED_CONNECTION_KEYS) || value["version"] !== 6 || value["kind"] !== "verified") {
|
|
22687
22680
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
22688
22681
|
}
|
|
22689
22682
|
const activation = value["activation"];
|
|
@@ -22716,7 +22709,7 @@ function decodeConnection(value) {
|
|
|
22716
22709
|
if (!isRecord3(value)) {
|
|
22717
22710
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
22718
22711
|
}
|
|
22719
|
-
return decodeVerifiedConnection(value
|
|
22712
|
+
return decodeVerifiedConnection(value);
|
|
22720
22713
|
}
|
|
22721
22714
|
async function readJsonFile(path7, signal, missingCode) {
|
|
22722
22715
|
signal.throwIfAborted();
|
|
@@ -26723,7 +26716,7 @@ async function raceAgentOperation(operation, termination, exitMessage, signal) {
|
|
|
26723
26716
|
}
|
|
26724
26717
|
|
|
26725
26718
|
// src/engine/acp/connection/create-client.ts
|
|
26726
|
-
var createAcpClient = (handler) => client({ name: "
|
|
26719
|
+
var createAcpClient = (handler) => client({ name: "morty" }).onRequest(
|
|
26727
26720
|
methods.client.session.requestPermission,
|
|
26728
26721
|
async (context) => await handler.onPermission(context.params, context.signal)
|
|
26729
26722
|
).onRequest(
|
|
@@ -63273,7 +63266,7 @@ function backgroundTaskUpdate(task, linked) {
|
|
|
63273
63266
|
const status = task.status === "completed" ? "completed" : task.status === "running" ? "in_progress" : task.status === "unknown" ? void 0 : "failed";
|
|
63274
63267
|
const fields = {
|
|
63275
63268
|
toolCallId: task.toolUseId ?? `claude-task-${task.id}`,
|
|
63276
|
-
_meta: { "
|
|
63269
|
+
_meta: { "morty.backgroundTask": { id: task.id, status: task.status } },
|
|
63277
63270
|
...status === void 0 ? {} : { status },
|
|
63278
63271
|
content: [{ type: "content", content: { type: "text", text: task.summary } }]
|
|
63279
63272
|
};
|
|
@@ -70884,7 +70877,7 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, client2, log
|
|
|
70884
70877
|
},
|
|
70885
70878
|
...launchedTaskId === void 0 && toolMeta?.terminal_exit ? { terminal_exit: toolMeta.terminal_exit } : {},
|
|
70886
70879
|
...launchedTaskId === void 0 ? {} : {
|
|
70887
|
-
"
|
|
70880
|
+
"morty.backgroundTask": {
|
|
70888
70881
|
id: launchedTaskId,
|
|
70889
70882
|
status: options?.historical ? "unknown" : "running"
|
|
70890
70883
|
}
|
|
@@ -72464,7 +72457,7 @@ var CodexAppServerClient = class {
|
|
|
72464
72457
|
this.#fail(
|
|
72465
72458
|
error62 instanceof CodexAppServerError ? error62 : new CodexAppServerError(
|
|
72466
72459
|
"codex_app_server_client_error",
|
|
72467
|
-
"
|
|
72460
|
+
"Morty could not process a Codex app-server message",
|
|
72468
72461
|
{ cause: error62 }
|
|
72469
72462
|
)
|
|
72470
72463
|
);
|
|
@@ -72549,7 +72542,7 @@ var CodexAppServerClient = class {
|
|
|
72549
72542
|
"initialize",
|
|
72550
72543
|
{
|
|
72551
72544
|
capabilities: { experimentalApi: true },
|
|
72552
|
-
clientInfo: { name: "
|
|
72545
|
+
clientInfo: { name: "morty", version: "1.0.0" }
|
|
72553
72546
|
},
|
|
72554
72547
|
AbortSignal.any([signal, AbortSignal.timeout(INITIALIZE_TIMEOUT_MILLISECONDS)])
|
|
72555
72548
|
);
|
|
@@ -72964,7 +72957,7 @@ function agentMessageUpdate(messageId, text2, questions = []) {
|
|
|
72964
72957
|
content: { text: text2, type: "text" },
|
|
72965
72958
|
messageId,
|
|
72966
72959
|
sessionUpdate: "agent_message_chunk",
|
|
72967
|
-
...questions.length === 0 ? {} : { _meta: { "
|
|
72960
|
+
...questions.length === 0 ? {} : { _meta: { "morty.questions": questions } }
|
|
72968
72961
|
};
|
|
72969
72962
|
}
|
|
72970
72963
|
function userInputSchema(questions) {
|
|
@@ -73181,7 +73174,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
73181
73174
|
await this.#context.emit({
|
|
73182
73175
|
sessionUpdate: "tool_call_update",
|
|
73183
73176
|
toolCallId: id,
|
|
73184
|
-
_meta: { "
|
|
73177
|
+
_meta: { "morty.backgroundTask": { id, status: "running" } }
|
|
73185
73178
|
});
|
|
73186
73179
|
}
|
|
73187
73180
|
});
|
|
@@ -73357,7 +73350,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
73357
73350
|
...this.#runningCommands.get(item.id) === "background" ? {
|
|
73358
73351
|
_meta: {
|
|
73359
73352
|
...update._meta,
|
|
73360
|
-
"
|
|
73353
|
+
"morty.backgroundTask": {
|
|
73361
73354
|
id: item.id,
|
|
73362
73355
|
status: update.status === "completed" ? "completed" : "failed"
|
|
73363
73356
|
}
|
|
@@ -73385,7 +73378,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
73385
73378
|
await this.#requestMcpElicitation(request);
|
|
73386
73379
|
return;
|
|
73387
73380
|
}
|
|
73388
|
-
this.#appServer.respondWithError(request.id, -32601, `
|
|
73381
|
+
this.#appServer.respondWithError(request.id, -32601, `Morty does not support ${request.method}`);
|
|
73389
73382
|
};
|
|
73390
73383
|
#askPermission = async (title2, toolCallId, signal) => {
|
|
73391
73384
|
const connection = this.#context.connection();
|
|
@@ -73406,7 +73399,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
73406
73399
|
#requestApproval = async (request) => {
|
|
73407
73400
|
const decoded = request.method === "item/commandExecution/requestApproval" ? commandApprovalParamsSchema.safeParse(request.params) : fileChangeApprovalParamsSchema.safeParse(request.params);
|
|
73408
73401
|
if (!decoded.success) {
|
|
73409
|
-
this.#appServer.respondWithError(request.id, -32602, "
|
|
73402
|
+
this.#appServer.respondWithError(request.id, -32602, "Morty could not read the approval request");
|
|
73410
73403
|
return;
|
|
73411
73404
|
}
|
|
73412
73405
|
const params = decoded.data;
|
|
@@ -73452,7 +73445,7 @@ var CodexOwnedAcpAgent = class {
|
|
|
73452
73445
|
const decoded = mcpElicitationParamsSchema.safeParse(request.params);
|
|
73453
73446
|
const connection = this.#context.connection();
|
|
73454
73447
|
if (!decoded.success || connection === null) {
|
|
73455
|
-
this.#appServer.respondWithError(request.id, -32602, "
|
|
73448
|
+
this.#appServer.respondWithError(request.id, -32602, "Morty could not read the elicitation request");
|
|
73456
73449
|
return;
|
|
73457
73450
|
}
|
|
73458
73451
|
const params = decoded.data;
|
|
@@ -74585,7 +74578,7 @@ var CodexSettings = class {
|
|
|
74585
74578
|
this.#collaborationModeSupported = false;
|
|
74586
74579
|
}
|
|
74587
74580
|
};
|
|
74588
|
-
/** The ACP settings
|
|
74581
|
+
/** The ACP settings Morty discovers and renders in Run settings. */
|
|
74589
74582
|
configOptions = () => {
|
|
74590
74583
|
const options = [];
|
|
74591
74584
|
const model = modelSetting(this.#models, this.#selection.model);
|
|
@@ -74807,7 +74800,7 @@ var CodexAcpAgent = class {
|
|
|
74807
74800
|
});
|
|
74808
74801
|
}
|
|
74809
74802
|
});
|
|
74810
|
-
this.#app = agent({ name: "
|
|
74803
|
+
this.#app = agent({ name: "morty-codex" }).onConnect((connection) => {
|
|
74811
74804
|
this.#connection = connection;
|
|
74812
74805
|
}).onRequest(methods.agent.initialize, async () => ({
|
|
74813
74806
|
_meta: { steering: { supported: true } },
|
|
@@ -74918,7 +74911,7 @@ var CodexAcpAgent = class {
|
|
|
74918
74911
|
});
|
|
74919
74912
|
}
|
|
74920
74913
|
agentSettingsModelEffort = () => this.#settings.agentModelEffort();
|
|
74921
|
-
/** The ACP agent app
|
|
74914
|
+
/** The ACP agent app Morty connects its own ACP client to, in-process. */
|
|
74922
74915
|
app = () => this.#app;
|
|
74923
74916
|
nativeTurnId = () => this.#sessionAgent.nativeTurnId();
|
|
74924
74917
|
/** Starts the app-server, performs its handshake, and reads the model catalog Codex offers. */
|
|
@@ -74999,7 +74992,7 @@ var CodexAcpAgent = class {
|
|
|
74999
74992
|
this.#settings.selectRestoredThread(resumed);
|
|
75000
74993
|
await this.#settings.probeCollaborationMode(this.#nativeSessionId, signal);
|
|
75001
74994
|
};
|
|
75002
|
-
/** What the session response tells
|
|
74995
|
+
/** What the session response tells Morty about the session behavior selected while opening it. */
|
|
75003
74996
|
#sessionMeta = () => ({
|
|
75004
74997
|
steering: { supported: this.#sessionAgent.steeringSupported },
|
|
75005
74998
|
codex: { runsTurns: this.#sessionAgent.runsTurns }
|
|
@@ -76113,7 +76106,7 @@ function questionField(question) {
|
|
|
76113
76106
|
title: title2,
|
|
76114
76107
|
default: question.prefill,
|
|
76115
76108
|
maxLength: 1e4,
|
|
76116
|
-
_meta: { "io.
|
|
76109
|
+
_meta: { "io.morty/multiline": true }
|
|
76117
76110
|
};
|
|
76118
76111
|
}
|
|
76119
76112
|
}
|
|
@@ -76954,7 +76947,7 @@ var PiAcpSession = class {
|
|
|
76954
76947
|
} else if (retryFailure !== null && !this.cancelRequested) {
|
|
76955
76948
|
this.pendingTurn?.reject(
|
|
76956
76949
|
// The message rides in `data.details` so clients that unwrap the
|
|
76957
|
-
// JSON-RPC internal-error envelope (like
|
|
76950
|
+
// JSON-RPC internal-error envelope (like Morty) surface the real
|
|
76958
76951
|
// model error; `code` keeps the failure machine-readable.
|
|
76959
76952
|
RequestError.internalError({
|
|
76960
76953
|
code: "pi_retries_exhausted",
|
|
@@ -79000,7 +78993,7 @@ var PiAcpEndpoint = class {
|
|
|
79000
78993
|
PI_ACP_PI_COMMAND: options.command
|
|
79001
78994
|
});
|
|
79002
78995
|
let piAgent = null;
|
|
79003
|
-
this.#app = agent({ name: "
|
|
78996
|
+
this.#app = agent({ name: "morty-pi" }).onConnect((connection) => {
|
|
79004
78997
|
this.#connection = connection;
|
|
79005
78998
|
piAgent = new PiAcpAgent(
|
|
79006
78999
|
createPiAcpClient(connection, options.onSessionUpdate, options.onUserMessageStart),
|
|
@@ -79141,7 +79134,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
79141
79134
|
acpProbeTimeoutMilliseconds = ACP_PROBE_TIMEOUT_MILLISECONDS2;
|
|
79142
79135
|
agentExecutable = "pi";
|
|
79143
79136
|
createConnection = (options) => new PiAgentConnection(options);
|
|
79144
|
-
// The Pi ACP fork inlines embedded prompt resources into the turn message, so
|
|
79137
|
+
// The Pi ACP fork inlines embedded prompt resources into the turn message, so Morty
|
|
79145
79138
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
79146
79139
|
createLaunchEnvironment = async (_agent, context) => {
|
|
79147
79140
|
const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
@@ -79478,7 +79471,7 @@ async function probeAcpReadiness(specification, agent2, environment, defaultWork
|
|
|
79478
79471
|
methods.agent.initialize,
|
|
79479
79472
|
{
|
|
79480
79473
|
clientCapabilities: {},
|
|
79481
|
-
clientInfo: { name: "
|
|
79474
|
+
clientInfo: { name: "morty", version: "0.0.3" },
|
|
79482
79475
|
protocolVersion: PROTOCOL_VERSION
|
|
79483
79476
|
},
|
|
79484
79477
|
{ cancellationSignal: controller.signal }
|
|
@@ -79930,7 +79923,7 @@ function buildPromptContent(options, capabilities) {
|
|
|
79930
79923
|
}
|
|
79931
79924
|
for (const image of options.images) {
|
|
79932
79925
|
prompt.push({
|
|
79933
|
-
_meta: {
|
|
79926
|
+
_meta: { morty: { name: image.name } },
|
|
79934
79927
|
data: image.data,
|
|
79935
79928
|
mimeType: image.mimeType,
|
|
79936
79929
|
type: "image"
|
|
@@ -80037,7 +80030,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
80037
80030
|
const id = truncate3(readString3(option["id"]), 128);
|
|
80038
80031
|
const name2 = truncate3(readString3(option["name"], id), 255);
|
|
80039
80032
|
const category = truncate3(readString3(option["category"]), 128);
|
|
80040
|
-
if (id.length === 0 || name2.length === 0 || category === "
|
|
80033
|
+
if (id.length === 0 || name2.length === 0 || category === "_morty_permission") {
|
|
80041
80034
|
continue;
|
|
80042
80035
|
}
|
|
80043
80036
|
if (option["type"] === "boolean") {
|
|
@@ -80282,7 +80275,7 @@ async function validateAgentRuntime(agent2, signal) {
|
|
|
80282
80275
|
signal.throwIfAborted();
|
|
80283
80276
|
if (unchanged.some((result) => !result)) {
|
|
80284
80277
|
throw new AcpExecutionError(
|
|
80285
|
-
"The local Agent runtime changed; restart
|
|
80278
|
+
"The local Agent runtime changed; restart Morty before starting a new conversation",
|
|
80286
80279
|
{},
|
|
80287
80280
|
"agent_runtime_changed"
|
|
80288
80281
|
);
|
|
@@ -80302,7 +80295,7 @@ async function initializeAgentConnection(connection, agentId, verifiedVersion, s
|
|
|
80302
80295
|
plan: {},
|
|
80303
80296
|
session: { compaction: {}, configOptions: { boolean: {} } }
|
|
80304
80297
|
},
|
|
80305
|
-
clientInfo: { name: "
|
|
80298
|
+
clientInfo: { name: "morty", version: "0.0.3" },
|
|
80306
80299
|
protocolVersion: PROTOCOL_VERSION
|
|
80307
80300
|
},
|
|
80308
80301
|
{ cancellationSignal: signal }
|
|
@@ -80364,18 +80357,18 @@ function applyConfigurationChanges(base, changes) {
|
|
|
80364
80357
|
}
|
|
80365
80358
|
|
|
80366
80359
|
// src/engine/acp/adapter/session-events.ts
|
|
80367
|
-
function
|
|
80360
|
+
function withMortyFields(update, eventUpdate) {
|
|
80368
80361
|
if (typeof eventUpdate !== "object" || eventUpdate === null) {
|
|
80369
80362
|
return eventUpdate;
|
|
80370
80363
|
}
|
|
80371
80364
|
switch (update.sessionUpdate) {
|
|
80372
80365
|
case "tool_call":
|
|
80373
80366
|
case "tool_call_update": {
|
|
80374
|
-
const backgroundTask = update._meta?.["
|
|
80367
|
+
const backgroundTask = update._meta?.["morty.backgroundTask"];
|
|
80375
80368
|
return backgroundTask === void 0 ? eventUpdate : { ...eventUpdate, backgroundTask };
|
|
80376
80369
|
}
|
|
80377
80370
|
case "agent_message_chunk": {
|
|
80378
|
-
const questions = update._meta?.["
|
|
80371
|
+
const questions = update._meta?.["morty.questions"];
|
|
80379
80372
|
return questions === void 0 ? eventUpdate : { ...eventUpdate, questions };
|
|
80380
80373
|
}
|
|
80381
80374
|
default:
|
|
@@ -80412,7 +80405,7 @@ var AdapterSessionConnection = class {
|
|
|
80412
80405
|
const update = externalized.agent;
|
|
80413
80406
|
for (const eventUpdate of externalized.events) {
|
|
80414
80407
|
const payload = decodeAcpSessionUpdate(
|
|
80415
|
-
JSON.stringify(normalizeEvent(
|
|
80408
|
+
JSON.stringify(normalizeEvent(withMortyFields(update, eventUpdate)))
|
|
80416
80409
|
);
|
|
80417
80410
|
let event;
|
|
80418
80411
|
switch (update.sessionUpdate) {
|
|
@@ -82102,9 +82095,7 @@ import { join as join24 } from "node:path";
|
|
|
82102
82095
|
|
|
82103
82096
|
// src/engine/storage/sqlite/local-databases.ts
|
|
82104
82097
|
import { createHash as createHash4 } from "node:crypto";
|
|
82105
|
-
import { existsSync as existsSync9 } from "node:fs";
|
|
82106
82098
|
import { join as join23 } from "node:path";
|
|
82107
|
-
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
82108
82099
|
|
|
82109
82100
|
// src/engine/generated/acp-session-store-migrations.ts
|
|
82110
82101
|
var acpSessionStoreMigrations = [
|
|
@@ -87067,7 +87058,7 @@ var LocalSqliteDatabase = class {
|
|
|
87067
87058
|
#migrate = (label, migrations) => {
|
|
87068
87059
|
const version3 = external_exports.object({ user_version: external_exports.number().int().nonnegative() }).parse(this.#sqlite.prepare("PRAGMA user_version").get()).user_version;
|
|
87069
87060
|
if (version3 > migrations.length) {
|
|
87070
|
-
throw new Error(`The ${label} was created by a newer
|
|
87061
|
+
throw new Error(`The ${label} was created by a newer Morty version`);
|
|
87071
87062
|
}
|
|
87072
87063
|
for (let index2 = version3; index2 < migrations.length; index2 += 1) {
|
|
87073
87064
|
const migration = migrations[index2];
|
|
@@ -87110,23 +87101,7 @@ function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
|
87110
87101
|
sessions: join23(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
87111
87102
|
};
|
|
87112
87103
|
}
|
|
87113
|
-
function recordAppliedAdmissionOrder(path7) {
|
|
87114
|
-
if (!existsSync9(path7)) {
|
|
87115
|
-
return;
|
|
87116
|
-
}
|
|
87117
|
-
const database = new DatabaseSync3(path7);
|
|
87118
|
-
try {
|
|
87119
|
-
const version3 = database.prepare("PRAGMA user_version").get()?.["user_version"];
|
|
87120
|
-
const column = database.prepare("SELECT name FROM pragma_table_info('execution_receipt') WHERE name = 'admission_order'").get();
|
|
87121
|
-
if (version3 === 9 && column !== void 0) {
|
|
87122
|
-
database.exec("PRAGMA user_version = 10");
|
|
87123
|
-
}
|
|
87124
|
-
} finally {
|
|
87125
|
-
database.close();
|
|
87126
|
-
}
|
|
87127
|
-
}
|
|
87128
87104
|
var openAcpSessionDatabase = (path7) => {
|
|
87129
|
-
recordAppliedAdmissionOrder(path7);
|
|
87130
87105
|
return new LocalSqliteDatabase(path7, "ACP Session database", acpSessionStoreMigrations);
|
|
87131
87106
|
};
|
|
87132
87107
|
var openCommandCancellationDatabase = (path7) => new LocalSqliteDatabase(path7, "Command cancellation database", commandCancellationMigrations);
|
|
@@ -87279,7 +87254,7 @@ var SessionEventCacheTable = class {
|
|
|
87279
87254
|
} catch (cause) {
|
|
87280
87255
|
this.#isAvailable = false;
|
|
87281
87256
|
this.#ignoredPersistedSessions.add(sessionId);
|
|
87282
|
-
console.warn("
|
|
87257
|
+
console.warn("Morty V2 Session event cache writes are unavailable; retaining events in memory", cause);
|
|
87283
87258
|
}
|
|
87284
87259
|
};
|
|
87285
87260
|
close = () => {
|
|
@@ -87287,7 +87262,7 @@ var SessionEventCacheTable = class {
|
|
|
87287
87262
|
try {
|
|
87288
87263
|
this.#checkpoint();
|
|
87289
87264
|
} catch (cause) {
|
|
87290
|
-
console.warn("
|
|
87265
|
+
console.warn("Morty V2 Session event cache checkpoint on close failed", cause);
|
|
87291
87266
|
}
|
|
87292
87267
|
}
|
|
87293
87268
|
this.#localDatabase.close();
|
|
@@ -87298,13 +87273,13 @@ var SessionEventCacheTable = class {
|
|
|
87298
87273
|
};
|
|
87299
87274
|
#disableWrites = (cause) => {
|
|
87300
87275
|
this.#isAvailable = false;
|
|
87301
|
-
console.warn("
|
|
87276
|
+
console.warn("Morty V2 Session event cache writes are unavailable; retaining events in memory", cause);
|
|
87302
87277
|
};
|
|
87303
87278
|
};
|
|
87304
87279
|
|
|
87305
87280
|
// src/engine/storage/session/temporary-session-event-cache.ts
|
|
87306
87281
|
function openTemporarySessionEventCache() {
|
|
87307
|
-
const directory = mkdtempSync(join24(tmpdir2(), "
|
|
87282
|
+
const directory = mkdtempSync(join24(tmpdir2(), "morty-preview-events-"));
|
|
87308
87283
|
const removeFiles = () => rmSync2(directory, { recursive: true, force: true });
|
|
87309
87284
|
try {
|
|
87310
87285
|
return {
|
|
@@ -87569,7 +87544,7 @@ var CodexAdapter = class {
|
|
|
87569
87544
|
}
|
|
87570
87545
|
if (!await revalidateExecutable(agent2.agentIdentity)) {
|
|
87571
87546
|
throw new AcpExecutionError(
|
|
87572
|
-
"The local Codex executable changed. Restart
|
|
87547
|
+
"The local Codex executable changed. Restart Morty to discover it again.",
|
|
87573
87548
|
{},
|
|
87574
87549
|
"agent_executable_changed"
|
|
87575
87550
|
);
|
|
@@ -87613,7 +87588,7 @@ var CodexAdapter = class {
|
|
|
87613
87588
|
events.push({
|
|
87614
87589
|
type: "acp",
|
|
87615
87590
|
payload: decodeAcpSessionUpdate(
|
|
87616
|
-
JSON.stringify(fitCodexToolEvent(
|
|
87591
|
+
JSON.stringify(fitCodexToolEvent(withMortyFields(update, event)))
|
|
87617
87592
|
)
|
|
87618
87593
|
});
|
|
87619
87594
|
}
|
|
@@ -87835,7 +87810,7 @@ var AcpContentExternalizer = class {
|
|
|
87835
87810
|
signal
|
|
87836
87811
|
);
|
|
87837
87812
|
return {
|
|
87838
|
-
agent: { ...content, data: "", uri: `
|
|
87813
|
+
agent: { ...content, data: "", uri: `morty-content:image:${stored.key}` },
|
|
87839
87814
|
event: {
|
|
87840
87815
|
_meta: content._meta,
|
|
87841
87816
|
annotations: content.annotations,
|
|
@@ -88329,7 +88304,7 @@ async function discoverRuntimeAgentInventory(options, channelId) {
|
|
|
88329
88304
|
const log = new RuntimeDiagnosticLog(options.dataDirectory);
|
|
88330
88305
|
const record2 = (details) => {
|
|
88331
88306
|
log.record(
|
|
88332
|
-
`
|
|
88307
|
+
`Morty agent discovery diagnostic ${JSON.stringify({
|
|
88333
88308
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
88334
88309
|
channelId,
|
|
88335
88310
|
...details
|
|
@@ -88643,7 +88618,6 @@ async function unchangedIdentity(agent2, signal) {
|
|
|
88643
88618
|
var PAIRING_TIMEOUT_MILLISECONDS = 2e4;
|
|
88644
88619
|
var PAIRING_CODE_PATTERN = /^[A-HJ-NP-Z2-9]{4}(?:-[A-HJ-NP-Z2-9]{4}){4}$/;
|
|
88645
88620
|
var TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
88646
|
-
var CLAIM_RESPONSE_KEYS = ["appId", "channelId", "daemonToken", "runtimeId"];
|
|
88647
88621
|
var REDEEM_RESPONSE_KEYS = ["appId", "channelId", "runtimeCredential", "runtimeId"];
|
|
88648
88622
|
var PairingClientError = class extends Error {
|
|
88649
88623
|
code;
|
|
@@ -88736,13 +88710,13 @@ function readRelayError(value) {
|
|
|
88736
88710
|
}
|
|
88737
88711
|
return new PairingClientError("pairing_failed", "The relay could not pair this machine");
|
|
88738
88712
|
}
|
|
88739
|
-
function decodePairingResponse(value
|
|
88740
|
-
if (!isRecord5(value) || !hasExactKeys2(value,
|
|
88713
|
+
function decodePairingResponse(value) {
|
|
88714
|
+
if (!isRecord5(value) || !hasExactKeys2(value, REDEEM_RESPONSE_KEYS)) {
|
|
88741
88715
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
88742
88716
|
}
|
|
88743
88717
|
const appId = value["appId"];
|
|
88744
88718
|
const channelId = value["channelId"];
|
|
88745
|
-
const runtimeCredential2 = value[
|
|
88719
|
+
const runtimeCredential2 = value["runtimeCredential"];
|
|
88746
88720
|
const runtimeId = value["runtimeId"];
|
|
88747
88721
|
if (typeof appId !== "string" || !isIdentifier(appId) || typeof channelId !== "string" || !isIdentifier(channelId) || typeof runtimeCredential2 !== "string" || !TOKEN_PATTERN.test(runtimeCredential2) || typeof runtimeId !== "string" || !isIdentifier(runtimeId)) {
|
|
88748
88722
|
throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
|
|
@@ -88757,7 +88731,10 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
|
|
|
88757
88731
|
id: agent2.id,
|
|
88758
88732
|
label: agent2.label
|
|
88759
88733
|
}));
|
|
88760
|
-
const endpoint =
|
|
88734
|
+
const endpoint = mortyApiUrl(
|
|
88735
|
+
options.relayOrigin,
|
|
88736
|
+
`/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`
|
|
88737
|
+
);
|
|
88761
88738
|
let response;
|
|
88762
88739
|
try {
|
|
88763
88740
|
response = await fetch3(endpoint, {
|
|
@@ -88780,10 +88757,10 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
|
|
|
88780
88757
|
if (!response.ok) {
|
|
88781
88758
|
throw readRelayError(value);
|
|
88782
88759
|
}
|
|
88783
|
-
return
|
|
88760
|
+
return decodePairingResponse(value);
|
|
88784
88761
|
}
|
|
88785
88762
|
function buildSavedRuntimeConfig(connection, defaultWorkspace, inventory, localContext) {
|
|
88786
|
-
const relayUrl =
|
|
88763
|
+
const relayUrl = mortyApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
|
|
88787
88764
|
relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
88788
88765
|
relayUrl.searchParams.set("token", connection.runtimeCredential);
|
|
88789
88766
|
const config2 = createRuntimeConfig(
|
|
@@ -88849,7 +88826,7 @@ async function pairRuntimeConnection(installation, options, signal, environment)
|
|
|
88849
88826
|
installation,
|
|
88850
88827
|
{
|
|
88851
88828
|
code: parsePairingCode(options.pairingCode),
|
|
88852
|
-
pairingId:
|
|
88829
|
+
pairingId: validatePairingId(options.pairingId),
|
|
88853
88830
|
relayOrigin: parseRelayOrigin2(options.relayOrigin),
|
|
88854
88831
|
workspace: options.defaultWorkspace
|
|
88855
88832
|
},
|
|
@@ -89305,7 +89282,7 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
89305
89282
|
maximumLength: numericString(property["maxLength"] ?? property["maxItems"]),
|
|
89306
89283
|
minimum: numericString(property["minimum"]),
|
|
89307
89284
|
minimumLength: numericString(property["minLength"] ?? property["minItems"]),
|
|
89308
|
-
...normalizedType === "string" && isRecord5(metadata) && metadata["io.
|
|
89285
|
+
...normalizedType === "string" && isRecord5(metadata) && metadata["io.morty/multiline"] === true ? { multiline: true } : {},
|
|
89309
89286
|
name: truncate(name2, 128),
|
|
89310
89287
|
options,
|
|
89311
89288
|
pattern: truncate(readString2(property["pattern"]), 500),
|
|
@@ -89684,7 +89661,7 @@ var SessionInteractions = class {
|
|
|
89684
89661
|
const sessionId = Reflect.get(request, "sessionId");
|
|
89685
89662
|
if (typeof sessionId !== "string") {
|
|
89686
89663
|
throw new AcpExecutionError(
|
|
89687
|
-
"
|
|
89664
|
+
"Morty only accepts session-scoped ACP elicitations",
|
|
89688
89665
|
{},
|
|
89689
89666
|
"unsupported_elicitation_scope"
|
|
89690
89667
|
);
|
|
@@ -90172,7 +90149,7 @@ var AgentSession = class _AgentSession {
|
|
|
90172
90149
|
return this.#restored;
|
|
90173
90150
|
}
|
|
90174
90151
|
get sessionId() {
|
|
90175
|
-
return this.#
|
|
90152
|
+
return this.#mortySessionId;
|
|
90176
90153
|
}
|
|
90177
90154
|
get store() {
|
|
90178
90155
|
return this.#store;
|
|
@@ -90198,7 +90175,7 @@ var AgentSession = class _AgentSession {
|
|
|
90198
90175
|
#getObserver;
|
|
90199
90176
|
#agentCommand;
|
|
90200
90177
|
#interactions;
|
|
90201
|
-
#
|
|
90178
|
+
#mortySessionId;
|
|
90202
90179
|
#metrics;
|
|
90203
90180
|
#store;
|
|
90204
90181
|
#agentName = "";
|
|
@@ -90216,22 +90193,22 @@ var AgentSession = class _AgentSession {
|
|
|
90216
90193
|
#restored = false;
|
|
90217
90194
|
#sessionTitle = null;
|
|
90218
90195
|
#sessionUpdatedAt = "";
|
|
90219
|
-
constructor(agent2, cwd, additionalDirectories,
|
|
90220
|
-
this.#agentCommand = () => agentCommand(this.#
|
|
90196
|
+
constructor(agent2, cwd, additionalDirectories, mortySessionId, getObserver, agentCommand, store, metrics, adapter, externalize) {
|
|
90197
|
+
this.#agentCommand = () => agentCommand(this.#mortySessionId);
|
|
90221
90198
|
this.#additionalDirectories = [...additionalDirectories];
|
|
90222
90199
|
this.#adapter = adapter;
|
|
90223
90200
|
this.#agentId = agent2.id;
|
|
90224
90201
|
this.#commands = [];
|
|
90225
90202
|
this.#cwd = cwd;
|
|
90226
90203
|
this.#environment = agent2.environment;
|
|
90227
|
-
this.#
|
|
90204
|
+
this.#mortySessionId = mortySessionId;
|
|
90228
90205
|
this.#metrics = metrics;
|
|
90229
90206
|
this.#store = store;
|
|
90230
90207
|
this.#getObserver = getObserver;
|
|
90231
90208
|
this.#interactions = new SessionInteractions({
|
|
90232
90209
|
cwd: () => this.#cwd,
|
|
90233
|
-
getToolCall: (toolCallId) => this.#store.events.getToolCall(this.#
|
|
90234
|
-
sessionId: () => this.#
|
|
90210
|
+
getToolCall: (toolCallId) => this.#store.events.getToolCall(this.#mortySessionId, toolCallId),
|
|
90211
|
+
sessionId: () => this.#mortySessionId,
|
|
90235
90212
|
commandId: () => this.#agentCommand() ?? SESSION_CONTROL_COMMAND_ID,
|
|
90236
90213
|
assertNativeSession: this.assertNativeSession,
|
|
90237
90214
|
observer: getObserver,
|
|
@@ -90241,7 +90218,7 @@ var AgentSession = class _AgentSession {
|
|
|
90241
90218
|
agent: agent2,
|
|
90242
90219
|
cwd,
|
|
90243
90220
|
additionalDirectories: this.#additionalDirectories,
|
|
90244
|
-
...externalize === void 0 ? {} : { externalizeUpdate: (update, signal) => externalize(this.#
|
|
90221
|
+
...externalize === void 0 ? {} : { externalizeUpdate: (update, signal) => externalize(this.#mortySessionId, update, signal) }
|
|
90245
90222
|
};
|
|
90246
90223
|
this.#subscriber = {
|
|
90247
90224
|
onSessionEvent: async (nativeSessionId, event) => {
|
|
@@ -90334,7 +90311,7 @@ var AgentSession = class _AgentSession {
|
|
|
90334
90311
|
writeStoredSession = (updatedAt) => {
|
|
90335
90312
|
this.#store.write(
|
|
90336
90313
|
new StoredSession(
|
|
90337
|
-
this.#
|
|
90314
|
+
this.#mortySessionId,
|
|
90338
90315
|
this.#agentId,
|
|
90339
90316
|
this.#nativeSessionId,
|
|
90340
90317
|
this.#cwd,
|
|
@@ -90437,7 +90414,7 @@ var AgentSession = class _AgentSession {
|
|
|
90437
90414
|
return;
|
|
90438
90415
|
}
|
|
90439
90416
|
this.#sessionLoad = {
|
|
90440
|
-
history: new HistoryReplayCapture(this.#store.events, this.#
|
|
90417
|
+
history: new HistoryReplayCapture(this.#store.events, this.#mortySessionId),
|
|
90441
90418
|
kind: "execution-only"
|
|
90442
90419
|
};
|
|
90443
90420
|
};
|
|
@@ -90455,9 +90432,9 @@ var AgentSession = class _AgentSession {
|
|
|
90455
90432
|
async #completedHistory(signal) {
|
|
90456
90433
|
if (!this.#prompted && this.#nativeHistoryOwnership.kind === "fresh-session") {
|
|
90457
90434
|
if (this.#sessionLoad.kind === "not-requested") {
|
|
90458
|
-
this.#store.events.reset(this.#
|
|
90435
|
+
this.#store.events.reset(this.#mortySessionId);
|
|
90459
90436
|
this.#sessionLoad = {
|
|
90460
|
-
history: new HistoryReplayCapture(this.#store.events, this.#
|
|
90437
|
+
history: new HistoryReplayCapture(this.#store.events, this.#mortySessionId),
|
|
90461
90438
|
kind: "loaded",
|
|
90462
90439
|
opened: {
|
|
90463
90440
|
nativeSessionId: this.nativeSessionId(),
|
|
@@ -90482,8 +90459,8 @@ var AgentSession = class _AgentSession {
|
|
|
90482
90459
|
if (this.#sessionLoad.kind === "capturing") {
|
|
90483
90460
|
return await waitForSharedOperation(this.#sessionLoad.completion, signal);
|
|
90484
90461
|
}
|
|
90485
|
-
this.#store.events.reset(this.#
|
|
90486
|
-
const history = new HistoryReplayCapture(this.#store.events, this.#
|
|
90462
|
+
this.#store.events.reset(this.#mortySessionId);
|
|
90463
|
+
const history = new HistoryReplayCapture(this.#store.events, this.#mortySessionId);
|
|
90487
90464
|
const completion = Promise.resolve().then(async () => {
|
|
90488
90465
|
try {
|
|
90489
90466
|
const opened = await this.#writeNativeHistory(
|
|
@@ -90586,7 +90563,7 @@ var AgentSession = class _AgentSession {
|
|
|
90586
90563
|
if (this.#prompted || this.#nativeSessionId !== sessionId) {
|
|
90587
90564
|
throw new AcpExecutionError("The new native Session cannot be adopted", {}, "session_identity_mismatch");
|
|
90588
90565
|
}
|
|
90589
|
-
const previousSessionId = this.#
|
|
90566
|
+
const previousSessionId = this.#mortySessionId;
|
|
90590
90567
|
this.#store.write(
|
|
90591
90568
|
new StoredSession(
|
|
90592
90569
|
sessionId,
|
|
@@ -90601,7 +90578,7 @@ var AgentSession = class _AgentSession {
|
|
|
90601
90578
|
)
|
|
90602
90579
|
);
|
|
90603
90580
|
this.#store.remove(previousSessionId);
|
|
90604
|
-
this.#
|
|
90581
|
+
this.#mortySessionId = sessionId;
|
|
90605
90582
|
};
|
|
90606
90583
|
#applyConfiguration = async (selection, signal) => {
|
|
90607
90584
|
const before = this.#configOptions;
|
|
@@ -90644,7 +90621,7 @@ var AgentSession = class _AgentSession {
|
|
|
90644
90621
|
};
|
|
90645
90622
|
};
|
|
90646
90623
|
#publishConfiguration = async () => {
|
|
90647
|
-
const event = this.#store.events.append(this.#
|
|
90624
|
+
const event = this.#store.events.append(this.#mortySessionId, {
|
|
90648
90625
|
type: "acp",
|
|
90649
90626
|
payload: {
|
|
90650
90627
|
sessionUpdate: "config_option_update",
|
|
@@ -90670,7 +90647,7 @@ var AgentSession = class _AgentSession {
|
|
|
90670
90647
|
if (!this.#capabilities.loadSession && this.#sessionLoad.kind === "not-requested") {
|
|
90671
90648
|
this.#sessionLoad = {
|
|
90672
90649
|
kind: "loaded",
|
|
90673
|
-
history: new HistoryReplayCapture(this.#store.events, this.#
|
|
90650
|
+
history: new HistoryReplayCapture(this.#store.events, this.#mortySessionId),
|
|
90674
90651
|
opened: {
|
|
90675
90652
|
nativeSessionId: this.nativeSessionId(),
|
|
90676
90653
|
capabilities: this.#capabilities,
|
|
@@ -90849,7 +90826,7 @@ var AgentSession = class _AgentSession {
|
|
|
90849
90826
|
return "retained";
|
|
90850
90827
|
};
|
|
90851
90828
|
interactionSnapshot = () => {
|
|
90852
|
-
const { sessionGenerationId, throughPosition } = this.#store.events.livePosition(this.#
|
|
90829
|
+
const { sessionGenerationId, throughPosition } = this.#store.events.livePosition(this.#mortySessionId);
|
|
90853
90830
|
return { sessionGenerationId, throughPosition, interactions: this.#interactions.snapshot() };
|
|
90854
90831
|
};
|
|
90855
90832
|
respondPermission = async (options) => {
|
|
@@ -90906,7 +90883,7 @@ var AgentSession = class _AgentSession {
|
|
|
90906
90883
|
await this.#getObserver().onCommands({
|
|
90907
90884
|
commands: this.#commands,
|
|
90908
90885
|
kind: SESSION_COMMANDS_UPDATED_KIND,
|
|
90909
|
-
sessionId: this.#
|
|
90886
|
+
sessionId: this.#mortySessionId
|
|
90910
90887
|
});
|
|
90911
90888
|
return;
|
|
90912
90889
|
case "configuration":
|
|
@@ -90929,7 +90906,7 @@ var AgentSession = class _AgentSession {
|
|
|
90929
90906
|
}
|
|
90930
90907
|
await this.#getObserver().onInfo({
|
|
90931
90908
|
kind: SESSION_INFO_UPDATED_KIND,
|
|
90932
|
-
sessionId: this.#
|
|
90909
|
+
sessionId: this.#mortySessionId,
|
|
90933
90910
|
title: this.#sessionTitle,
|
|
90934
90911
|
updatedAt: this.#sessionUpdatedAt
|
|
90935
90912
|
});
|
|
@@ -90994,7 +90971,7 @@ var AgentSession = class _AgentSession {
|
|
|
90994
90971
|
configurationRevision: configurationRevision(this.#configOptions),
|
|
90995
90972
|
kind: SESSION_CONFIG_UPDATED_KIND,
|
|
90996
90973
|
requestId: `agent-update-${crypto.randomUUID()}`,
|
|
90997
|
-
sessionId: this.#
|
|
90974
|
+
sessionId: this.#mortySessionId
|
|
90998
90975
|
});
|
|
90999
90976
|
};
|
|
91000
90977
|
};
|
|
@@ -91421,7 +91398,7 @@ var SessionManager2 = class {
|
|
|
91421
91398
|
/**
|
|
91422
91399
|
* Opens a short-lived native ACP session only to read the local Agent's
|
|
91423
91400
|
* authoritative settings. Its identity and store are private to this
|
|
91424
|
-
* operation and never become a
|
|
91401
|
+
* operation and never become a Morty Session.
|
|
91425
91402
|
*/
|
|
91426
91403
|
inspectAgentSettings = async (options) => this.#operations.run(options, async (options2) => {
|
|
91427
91404
|
return await this.#processes.runTransient(
|
|
@@ -92088,7 +92065,7 @@ var NativeSessionService = class {
|
|
|
92088
92065
|
});
|
|
92089
92066
|
return {
|
|
92090
92067
|
entryId,
|
|
92091
|
-
|
|
92068
|
+
mortySessionIds: this.#sessions.findLinkedSessions(command.agentId, info.sessionId).filter((session) => session.prompted && session.cwd === authorized.cwd).map((session) => decodeIdentifier(session.sessionId)),
|
|
92092
92069
|
nativeSessionId: decodeIdentifier(info.sessionId),
|
|
92093
92070
|
title: info.title ?? "Untitled session",
|
|
92094
92071
|
directoryId: authorized.directoryId,
|
|
@@ -92333,6 +92310,14 @@ var NativeSessionService = class {
|
|
|
92333
92310
|
};
|
|
92334
92311
|
};
|
|
92335
92312
|
|
|
92313
|
+
// src/engine/session/api/session-error.ts
|
|
92314
|
+
var SessionError = class extends OperationError {
|
|
92315
|
+
constructor(code, message, options = {}) {
|
|
92316
|
+
super(code, message, options);
|
|
92317
|
+
this.name = "SessionError";
|
|
92318
|
+
}
|
|
92319
|
+
};
|
|
92320
|
+
|
|
92336
92321
|
// src/engine/session/prompt/prompt-artifacts.ts
|
|
92337
92322
|
import { createHash as createHash7 } from "node:crypto";
|
|
92338
92323
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -92515,7 +92500,7 @@ var PromptLifecycle = class {
|
|
|
92515
92500
|
/**
|
|
92516
92501
|
* Publishes again an outcome a receipt already holds, for clients that missed it. The restatement is marked, so
|
|
92517
92502
|
* status notifications do not take it for a new outcome, and it does not settle the receipt again. It keeps the
|
|
92518
|
-
* time the outcome was recorded
|
|
92503
|
+
* time the outcome was recorded; only an outcome
|
|
92519
92504
|
* a receipt recorded is marked as such, so Recording can settle a Turn it missed from it and never from an
|
|
92520
92505
|
* acknowledgement composed now.
|
|
92521
92506
|
*/
|
|
@@ -92526,8 +92511,8 @@ var PromptLifecycle = class {
|
|
|
92526
92511
|
const restated = this.#append(sessionId, event, recordedAt);
|
|
92527
92512
|
this.#publishInOrder({
|
|
92528
92513
|
...restated,
|
|
92529
|
-
|
|
92530
|
-
...restated.
|
|
92514
|
+
mortyMetadata: {
|
|
92515
|
+
...restated.mortyMetadata,
|
|
92531
92516
|
...recordedAt === void 0 ? {} : { recordedOutcome: true },
|
|
92532
92517
|
restated: true
|
|
92533
92518
|
}
|
|
@@ -92601,6 +92586,11 @@ async function settleAbandonedTurn(projection, operations, cancellation) {
|
|
|
92601
92586
|
case "restated":
|
|
92602
92587
|
projection.restateOutcome(cancellation.sessionId, cancelled.outcome);
|
|
92603
92588
|
return;
|
|
92589
|
+
case "expired":
|
|
92590
|
+
throw new SessionError(
|
|
92591
|
+
"command_result_expired",
|
|
92592
|
+
"The command executed but its result is no longer retained"
|
|
92593
|
+
);
|
|
92604
92594
|
case "unavailable":
|
|
92605
92595
|
break;
|
|
92606
92596
|
}
|
|
@@ -92910,16 +92900,7 @@ var ExecutionReceipts = class {
|
|
|
92910
92900
|
return outcome2 === void 0 ? { kind: "unavailable" } : { kind: "restated", outcome: outcome2 };
|
|
92911
92901
|
}
|
|
92912
92902
|
case "expired":
|
|
92913
|
-
return {
|
|
92914
|
-
kind: "restated",
|
|
92915
|
-
outcome: {
|
|
92916
|
-
event: {
|
|
92917
|
-
type: "lifecycle-metadata",
|
|
92918
|
-
payload: { kind: "prompt.completed", commandId, stopReason: "cancelled" }
|
|
92919
|
-
},
|
|
92920
|
-
recordedAt: void 0
|
|
92921
|
-
}
|
|
92922
|
-
};
|
|
92903
|
+
return { kind: "expired" };
|
|
92923
92904
|
case "cancelled":
|
|
92924
92905
|
return {
|
|
92925
92906
|
kind: "restated",
|
|
@@ -93259,16 +93240,16 @@ var ActiveRuntimeTurn = class {
|
|
|
93259
93240
|
return event;
|
|
93260
93241
|
};
|
|
93261
93242
|
snapshot = () => {
|
|
93262
|
-
|
|
93243
|
+
const startedAt = this.#startedAt();
|
|
93244
|
+
if (startedAt === void 0) {
|
|
93263
93245
|
return null;
|
|
93264
93246
|
}
|
|
93265
|
-
const startedAt = this.#startedAt();
|
|
93266
93247
|
return {
|
|
93267
93248
|
commandId: decodeIdentifier(this.command.commandId),
|
|
93268
93249
|
epoch: this.epoch,
|
|
93269
93250
|
interaction: this.#interaction,
|
|
93270
93251
|
sequence: this.#sequence,
|
|
93271
|
-
|
|
93252
|
+
startedAt,
|
|
93272
93253
|
state: "running"
|
|
93273
93254
|
};
|
|
93274
93255
|
};
|
|
@@ -93774,7 +93755,7 @@ function buildSessionLayer(options) {
|
|
|
93774
93755
|
});
|
|
93775
93756
|
return {
|
|
93776
93757
|
...snapshot,
|
|
93777
|
-
|
|
93758
|
+
interactionState: interactionState ?? null,
|
|
93778
93759
|
...request.deliveryCommandId === void 0 ? {} : { command: operations.delivery(request.deliveryCommandId, request.targetSessionId) },
|
|
93779
93760
|
...lastTurn === void 0 ? {} : { lastTurn }
|
|
93780
93761
|
};
|
|
@@ -93884,7 +93865,7 @@ var ScratchDirectory = class {
|
|
|
93884
93865
|
};
|
|
93885
93866
|
|
|
93886
93867
|
// src/engine/session/content/external-content-store.ts
|
|
93887
|
-
var contentRequest = /^
|
|
93868
|
+
var contentRequest = /^morty-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
93888
93869
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
93889
93870
|
var metadataSchema = external_exports.strictObject({
|
|
93890
93871
|
kind: external_exports.enum(["image", "audio", "resource"]),
|
|
@@ -93938,7 +93919,7 @@ var LocalExternalContentStore = class {
|
|
|
93938
93919
|
active.throwIfAborted();
|
|
93939
93920
|
const metadata = metadataSchema.parse({ kind, mediaType, name: name2 });
|
|
93940
93921
|
const key = createHash9("sha256").update(bytes).digest("hex");
|
|
93941
|
-
const request = `
|
|
93922
|
+
const request = `morty-content:${kind}:${key}`;
|
|
93942
93923
|
const existing = this.#entries.get(request);
|
|
93943
93924
|
if (existing !== void 0 && existing.expiresAt > Date.now()) {
|
|
93944
93925
|
this.#entries.set(request, {
|
|
@@ -94003,7 +93984,7 @@ var LocalExternalContentStore = class {
|
|
|
94003
93984
|
}
|
|
94004
93985
|
const resources = [];
|
|
94005
93986
|
for (const [request, entry] of this.#entries) {
|
|
94006
|
-
if (!request.startsWith("
|
|
93987
|
+
if (!request.startsWith("morty-content:resource:") || entry.expiresAt <= Date.now()) {
|
|
94007
93988
|
continue;
|
|
94008
93989
|
}
|
|
94009
93990
|
const uri = pathToFileURL3(entry.path).href;
|
|
@@ -94648,14 +94629,6 @@ function createAgentCatalogCommands(context) {
|
|
|
94648
94629
|
// src/engine/runtime/command/agent-settings-discovery.ts
|
|
94649
94630
|
import { WebSocket as WebSocket4 } from "undici";
|
|
94650
94631
|
|
|
94651
|
-
// src/engine/session/api/session-error.ts
|
|
94652
|
-
var SessionError = class extends OperationError {
|
|
94653
|
-
constructor(code, message, options = {}) {
|
|
94654
|
-
super(code, message, options);
|
|
94655
|
-
this.name = "SessionError";
|
|
94656
|
-
}
|
|
94657
|
-
};
|
|
94658
|
-
|
|
94659
94632
|
// src/engine/session/settings/discover-agent-settings.ts
|
|
94660
94633
|
import { createHash as createHash10 } from "node:crypto";
|
|
94661
94634
|
|
|
@@ -95452,6 +95425,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, queuedPromp
|
|
|
95452
95425
|
return {
|
|
95453
95426
|
events: {
|
|
95454
95427
|
events: orderedEvents.map(({ event }) => event),
|
|
95428
|
+
promptOutcomes: [],
|
|
95455
95429
|
nextCursor,
|
|
95456
95430
|
sessionGenerationId,
|
|
95457
95431
|
tailCursor: orderedEvents.at(-1)?.event.eventId ?? "",
|
|
@@ -95610,14 +95584,14 @@ var previewHistoryPageLoadCommand = {
|
|
|
95610
95584
|
// src/engine/runtime/command/registry/interactions.ts
|
|
95611
95585
|
var sessionCancelCommand = {
|
|
95612
95586
|
kind: SESSION_CANCEL_KIND,
|
|
95613
|
-
handle: ({ eventProjection, operations, sessions, sessionTurns, signal }, message) => {
|
|
95587
|
+
handle: ({ eventProjection, operations, sessions, sessionTurns, signal, socket }, message) => {
|
|
95614
95588
|
if (message.kind !== SESSION_CANCEL_KIND) {
|
|
95615
95589
|
throw new Error("Command kind mismatch");
|
|
95616
95590
|
}
|
|
95617
95591
|
const turn = sessionTurns.get(message.commandId, message.sessionId);
|
|
95618
95592
|
if (turn === void 0) {
|
|
95619
95593
|
void settleAbandonedTurn(eventProjection, operations, message).catch((error62) => {
|
|
95620
|
-
|
|
95594
|
+
reportOperationFailure(socket, message.commandId, message.sessionId, error62);
|
|
95621
95595
|
});
|
|
95622
95596
|
return;
|
|
95623
95597
|
}
|
|
@@ -95648,7 +95622,7 @@ var sessionCancelBeforeStartCommand = {
|
|
|
95648
95622
|
const turn = sessionTurns.get(message.commandId, message.sessionId);
|
|
95649
95623
|
if (turn === void 0) {
|
|
95650
95624
|
const cancelled = operations.recordCancellationBeforeAdmission(message.commandId, message.sessionId);
|
|
95651
|
-
const outcome = cancelled.kind === "unavailable" ? void 0 : cancelled.kind === "restated" ? cancelled.outcome.event : cancelled.outcome;
|
|
95625
|
+
const outcome = cancelled.kind === "unavailable" || cancelled.kind === "expired" ? void 0 : cancelled.kind === "restated" ? cancelled.outcome.event : cancelled.outcome;
|
|
95652
95626
|
if (outcome?.type === "lifecycle-metadata" && outcome.payload.kind === "prompt.completed" && promptCompletion(outcome.payload).kind === "cancelled") {
|
|
95653
95627
|
if (cancelled.kind === "restated") {
|
|
95654
95628
|
eventProjection.restateOutcome(message.sessionId, cancelled.outcome);
|
|
@@ -95742,8 +95716,7 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
95742
95716
|
};
|
|
95743
95717
|
const handle = (command) => {
|
|
95744
95718
|
const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
|
|
95745
|
-
|
|
95746
|
-
if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
|
|
95719
|
+
if (pending.has(command.requestId) || pending.size >= 4) {
|
|
95747
95720
|
reportOperationFailure(
|
|
95748
95721
|
socket,
|
|
95749
95722
|
command.requestId,
|
|
@@ -96253,7 +96226,7 @@ var sessionPromptCommand = {
|
|
|
96253
96226
|
readArtifact: async (attachment, signal) => {
|
|
96254
96227
|
const artifact = await context.externalContent.read(
|
|
96255
96228
|
message.sessionId,
|
|
96256
|
-
`
|
|
96229
|
+
`morty-content:${attachment.kind}:${attachment.contentKey}`,
|
|
96257
96230
|
signal
|
|
96258
96231
|
);
|
|
96259
96232
|
if (artifact === null) {
|
|
@@ -97819,7 +97792,7 @@ var RuntimeLoop = class {
|
|
|
97819
97792
|
};
|
|
97820
97793
|
|
|
97821
97794
|
// src/engine/runtime/engine.ts
|
|
97822
|
-
var
|
|
97795
|
+
var MortyRuntimeEngine = class {
|
|
97823
97796
|
#engineDataDir;
|
|
97824
97797
|
#agentLaunchEnvironment;
|
|
97825
97798
|
#maxAcpProcesses;
|
|
@@ -97939,7 +97912,7 @@ export {
|
|
|
97939
97912
|
refreshAgentCatalog,
|
|
97940
97913
|
RuntimeRelayRevokedError,
|
|
97941
97914
|
RuntimeLoop,
|
|
97942
|
-
|
|
97915
|
+
MortyRuntimeEngine
|
|
97943
97916
|
};
|
|
97944
97917
|
/*! Bundled license information:
|
|
97945
97918
|
|
|
@@ -97951,4 +97924,4 @@ export {
|
|
|
97951
97924
|
* MIT Licensed
|
|
97952
97925
|
*)
|
|
97953
97926
|
*/
|
|
97954
|
-
//# sourceMappingURL=chunk-
|
|
97927
|
+
//# sourceMappingURL=chunk-HIGGFLQ3.js.map
|