@work-shape/catalyst-cli 0.8.0-rc.31 → 0.8.0-rc.33
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/README.md +2 -2
- package/dist/index.d.ts +553 -15
- package/dist/index.js +647 -129
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { realpathSync } from "fs";
|
|
4
|
+
import { realpathSync as realpathSync2 } from "fs";
|
|
5
5
|
import { pathToFileURL } from "url";
|
|
6
6
|
|
|
7
7
|
// ../asset-schemas/src/asset-types.ts
|
|
@@ -89,7 +89,10 @@ var CONNECTION_ACTIONS = [
|
|
|
89
89
|
"connection.use",
|
|
90
90
|
"connection.write",
|
|
91
91
|
"connection.delete",
|
|
92
|
-
"connection.approve"
|
|
92
|
+
"connection.approve",
|
|
93
|
+
// Adding one's own MCP server, a Connection only its owner uses (PMCP). The role `user`
|
|
94
|
+
// holds it by default; it names no Connection.
|
|
95
|
+
"connection.add_own"
|
|
93
96
|
];
|
|
94
97
|
|
|
95
98
|
// ../asset-schemas/src/contract-values/app.ts
|
|
@@ -319,6 +322,7 @@ var PROVIDER_CHECK_ERROR_CLASSES = [
|
|
|
319
322
|
var CONNECTION_NAME_PATTERN = /^[a-z][a-z0-9]*([_-][a-z0-9]+)*$/u;
|
|
320
323
|
var CONNECTION_NAME_MAX_LENGTH = 64;
|
|
321
324
|
var CONNECTION_EXPOSURES = ["agent", "bridge", "workflow", "outside"];
|
|
325
|
+
var CONNECTOR_FORM_FIELD_VALUES = ["text", "number", "list"];
|
|
322
326
|
var CONNECTION_HEALTH_STATES = [
|
|
323
327
|
"unknown",
|
|
324
328
|
"ok",
|
|
@@ -333,6 +337,7 @@ var ASSET_MOVE_EDITORS = ["workspace_builders", "instance_builders"];
|
|
|
333
337
|
var ASSET_MOVE_USERS = ["workspace_members", "everyone_where_offered"];
|
|
334
338
|
var GRANT_HOLDER_KINDS = ["user", "service_principal", "role", "group"];
|
|
335
339
|
var GRANT_SCOPE_KINDS = ["instance", "workspace", "asset"];
|
|
340
|
+
var ASSET_RIGHT_VERBS = ["read", "use", "write", "delete"];
|
|
336
341
|
var ROLE_GRANT_SCOPE_KINDS = [
|
|
337
342
|
"instance",
|
|
338
343
|
"workspace",
|
|
@@ -439,7 +444,7 @@ var ASSET_LIFECYCLES = ["active", "draft_published"];
|
|
|
439
444
|
var ASSET_REPRESENTATIONS = ["config", "files"];
|
|
440
445
|
var CONFIG_ASSET_KINDS = ["agent", "skill"];
|
|
441
446
|
var CONFIG_ASSET_CHANGE_OPERATIONS = ["create", "update", "delete", "revert"];
|
|
442
|
-
var AGENT_AVAILABILITY_MODES = ["all", "selected"];
|
|
447
|
+
var AGENT_AVAILABILITY_MODES = ["all", "selected", "all_except"];
|
|
443
448
|
var AGENT_USE_SETTINGS = ["everyone", "granted"];
|
|
444
449
|
var AGENT_EDITABLE_FIELDS = [
|
|
445
450
|
"displayName",
|
|
@@ -591,7 +596,12 @@ var CONNECTOR_TEST_STATUSES = [
|
|
|
591
596
|
"network_denied",
|
|
592
597
|
"unavailable",
|
|
593
598
|
/** The server asks for an OAuth sign-in, or the Connection signs in and nobody has. */
|
|
594
|
-
"oauth_required"
|
|
599
|
+
"oauth_required",
|
|
600
|
+
/**
|
|
601
|
+
* A person's own server refuses a request without a credential and describes no sign-in:
|
|
602
|
+
* it takes a token (PMCP).
|
|
603
|
+
*/
|
|
604
|
+
"token_required"
|
|
595
605
|
];
|
|
596
606
|
var CONNECTION_CREDENTIAL_MODES = ["shared", "user"];
|
|
597
607
|
var CONNECTION_BINDING_STATES = ["connected", "needs_reconnect", "revoked"];
|
|
@@ -1031,6 +1041,11 @@ var agentConfigSchema = z.object({
|
|
|
1031
1041
|
modelReasoningEfforts: z.record(z.string().min(1), z.enum(REASONING_EFFORTS)).optional(),
|
|
1032
1042
|
maxSteps: z.number().int().positive().optional(),
|
|
1033
1043
|
toolNames: z.array(z.string().min(1)).default([]),
|
|
1044
|
+
/**
|
|
1045
|
+
* Whether a run its person starts in their own private chat is offered the tools of the MCP
|
|
1046
|
+
* servers that person added for themselves (PMCP-4). Unset is on.
|
|
1047
|
+
*/
|
|
1048
|
+
ownServers: z.boolean().optional(),
|
|
1034
1049
|
/**
|
|
1035
1050
|
* The agents this agent may start as subagents through `run_agent`, beside itself. Only an
|
|
1036
1051
|
* agent whose `toolNames` lists `run_agent` starts any.
|
|
@@ -1625,6 +1640,19 @@ var sourceStatusSchema = z4.strictObject({
|
|
|
1625
1640
|
last: knowledgeSyncResultSchema.optional(),
|
|
1626
1641
|
/** "Wartet auf Bestätigung": the running first pass stopped at 10,000 items. */
|
|
1627
1642
|
confirmation: knowledgeFirstPassConfirmationSchema.optional(),
|
|
1643
|
+
/**
|
|
1644
|
+
* When a connector source syncs by itself (SRC-SYNC), as it applies: its `changes` poll in
|
|
1645
|
+
* minutes or `off`, its full pass as a cron expression in the instance's time zone or `off`,
|
|
1646
|
+
* and what its connector type gives a source that sets none: the poll, the full pass, and the
|
|
1647
|
+
* shortest poll the type allows, where it has one.
|
|
1648
|
+
*/
|
|
1649
|
+
schedule: z4.strictObject({
|
|
1650
|
+
changes: z4.union([z4.literal("off"), z4.number().int().min(1)]),
|
|
1651
|
+
full: z4.string(),
|
|
1652
|
+
defaultChanges: z4.number().int().min(1),
|
|
1653
|
+
defaultFull: z4.string(),
|
|
1654
|
+
minChanges: z4.number().int().min(1).optional()
|
|
1655
|
+
}).optional(),
|
|
1628
1656
|
/** "Letzte Änderung verarbeitet". */
|
|
1629
1657
|
lastChangeAt: z4.string().optional(),
|
|
1630
1658
|
/** "Älteste offene Änderung". */
|
|
@@ -2807,7 +2835,7 @@ import { z as z68 } from "zod";
|
|
|
2807
2835
|
// ../api-contract/package.json
|
|
2808
2836
|
var package_default = {
|
|
2809
2837
|
name: "@work-shape/catalyst-api-contract",
|
|
2810
|
-
version: "0.8.0-rc.
|
|
2838
|
+
version: "0.8.0-rc.33",
|
|
2811
2839
|
license: "MIT",
|
|
2812
2840
|
repository: {
|
|
2813
2841
|
type: "git",
|
|
@@ -3121,7 +3149,7 @@ var accessOriginRoleSchema = z22.object({
|
|
|
3121
3149
|
});
|
|
3122
3150
|
var REFUSAL_REASONS = ["denied", "no_grant", "holder_inactive"];
|
|
3123
3151
|
var refusalReasonSchema = z22.enum(REFUSAL_REASONS);
|
|
3124
|
-
var ASSET_CHECK_VERBS =
|
|
3152
|
+
var ASSET_CHECK_VERBS = ASSET_RIGHT_VERBS;
|
|
3125
3153
|
var assetCheckVerbSchema = z22.enum(ASSET_CHECK_VERBS);
|
|
3126
3154
|
var holderRightsSchema = z22.object({
|
|
3127
3155
|
holderActive: z22.boolean(),
|
|
@@ -4767,6 +4795,13 @@ var listAssetsQuerySchema = z30.object({
|
|
|
4767
4795
|
/** Only assets whose name or title contains this text, whatever the case. */
|
|
4768
4796
|
text: nameText(z30.string().min(1).max(200)).optional(),
|
|
4769
4797
|
workspaceId: workspaceIdSchema,
|
|
4798
|
+
/**
|
|
4799
|
+
* One page across several owners, in place of `workspaceId`: `instance` and workspace ids,
|
|
4800
|
+
* separated by commas. Each asset is listed by the same right as in its owner's own list.
|
|
4801
|
+
*/
|
|
4802
|
+
owners: nameText(
|
|
4803
|
+
z30.string().min(1).max(1e4).regex(/^[^,]+(?:,[^,]+)*$/u, "owners separated by commas")
|
|
4804
|
+
).optional(),
|
|
4770
4805
|
/**
|
|
4771
4806
|
* The language of the titles and descriptions, where a kind holds them in several. A
|
|
4772
4807
|
* language the instance does not offer, or none, answers its default.
|
|
@@ -5597,6 +5632,16 @@ var conversationSubjectSchema = z33.object({
|
|
|
5597
5632
|
name: z33.string().min(1).max(200)
|
|
5598
5633
|
});
|
|
5599
5634
|
var conversationCreationTargetSchema = z33.literal("instance");
|
|
5635
|
+
var conversationPersonSchema = z33.object({
|
|
5636
|
+
userId: z33.string(),
|
|
5637
|
+
displayLabel: z33.string(),
|
|
5638
|
+
addedAt: timestampSchema,
|
|
5639
|
+
/**
|
|
5640
|
+
* Deactivated, or their deletion was requested: they read nothing while they cannot sign in,
|
|
5641
|
+
* and the panel shows them so, with Remove (CHAT-SHARE-6b).
|
|
5642
|
+
*/
|
|
5643
|
+
deactivated: z33.literal(true).optional()
|
|
5644
|
+
});
|
|
5600
5645
|
var conversationSchema = z33.object({
|
|
5601
5646
|
id: z33.string(),
|
|
5602
5647
|
clientInstanceId: z33.string(),
|
|
@@ -5615,7 +5660,52 @@ var conversationSchema = z33.object({
|
|
|
5615
5660
|
/** `instance`: its first saves create agents, skills and guardrails for the instance. */
|
|
5616
5661
|
creationTarget: conversationCreationTargetSchema.optional(),
|
|
5617
5662
|
/** The project of its workspace it is in; its readers are the project's audience. */
|
|
5618
|
-
projectId: z33.string().optional()
|
|
5663
|
+
projectId: z33.string().optional(),
|
|
5664
|
+
/**
|
|
5665
|
+
* The members of its workspace its creator named, who read and write in this private chat
|
|
5666
|
+
* while members (CHAT-SHARE). Empty on every other conversation; a run thread carries its
|
|
5667
|
+
* root's.
|
|
5668
|
+
*/
|
|
5669
|
+
people: z33.array(conversationPersonSchema),
|
|
5670
|
+
/**
|
|
5671
|
+
* The creator's name, on a chat that names people: its other readers see who started it and
|
|
5672
|
+
* who wrote each turn. Missing on every other conversation.
|
|
5673
|
+
*/
|
|
5674
|
+
createdByDisplayLabel: z33.string().optional()
|
|
5675
|
+
});
|
|
5676
|
+
var addConversationPersonRequestSchema = z33.object({ userId: z33.string().min(1) }).strict();
|
|
5677
|
+
var conversationPersonRemovedSchema = z33.object({
|
|
5678
|
+
conversationId: z33.string(),
|
|
5679
|
+
userId: z33.string(),
|
|
5680
|
+
removed: z33.boolean()
|
|
5681
|
+
});
|
|
5682
|
+
var SHARE_CANDIDATES_QUERY_MAX_CHARS = 200;
|
|
5683
|
+
var SHARE_CANDIDATES_LIMIT_MAX = 50;
|
|
5684
|
+
var shareCandidatesQuerySchema = z33.object({
|
|
5685
|
+
/**
|
|
5686
|
+
* A prefix of a name or of a word of it, or an email. Among the people offered, a prefix of
|
|
5687
|
+
* an email matches too. From two letters a name prefix also finds active people of the
|
|
5688
|
+
* instance, and an email the person whose whole address it is (CHAT-SHARE-6).
|
|
5689
|
+
*/
|
|
5690
|
+
query: z33.string().trim().min(1).max(SHARE_CANDIDATES_QUERY_MAX_CHARS).optional(),
|
|
5691
|
+
limit: z33.coerce.number().int().min(1).max(SHARE_CANDIDATES_LIMIT_MAX).default(5)
|
|
5692
|
+
});
|
|
5693
|
+
var conversationShareCandidateSchema = z33.object({
|
|
5694
|
+
userId: z33.string(),
|
|
5695
|
+
displayLabel: z33.string(),
|
|
5696
|
+
email: z33.string().optional(),
|
|
5697
|
+
hasAccess: z33.boolean(),
|
|
5698
|
+
member: z33.boolean()
|
|
5699
|
+
});
|
|
5700
|
+
var conversationReaderOfferSchema = z33.object({
|
|
5701
|
+
workspace: z33.object({ id: z33.string(), name: z33.string() }),
|
|
5702
|
+
outside: z33.boolean(),
|
|
5703
|
+
defaultAgentName: z33.string().optional(),
|
|
5704
|
+
/** As `workspaces.agents.list` lists them: those the caller's own turns here may run. */
|
|
5705
|
+
agents: safeConfigSchema.shape.agents
|
|
5706
|
+
});
|
|
5707
|
+
var conversationShareCandidatesSchema = z33.object({
|
|
5708
|
+
candidates: z33.array(conversationShareCandidateSchema)
|
|
5619
5709
|
});
|
|
5620
5710
|
var moveConversationRequestSchema = z33.object({
|
|
5621
5711
|
collaborationWorkspaceId: z33.string().min(1),
|
|
@@ -5665,7 +5755,11 @@ var knowledgeCitationSourceSchema = z33.object({
|
|
|
5665
5755
|
fileName: z33.string().min(1),
|
|
5666
5756
|
page: z33.number().int().positive().optional(),
|
|
5667
5757
|
sheet: z33.string().min(1).optional(),
|
|
5668
|
-
originLink: z33.string().optional()
|
|
5758
|
+
originLink: z33.string().optional(),
|
|
5759
|
+
/** The date the cited synced document states of its version, shown on its chip. ISO. */
|
|
5760
|
+
statedAt: z33.string().optional(),
|
|
5761
|
+
/** When the platform fetched it, shown on the chip where no date is stated. ISO. */
|
|
5762
|
+
retrievedAt: z33.string().optional()
|
|
5669
5763
|
});
|
|
5670
5764
|
var messageCitationSchema = z33.object({
|
|
5671
5765
|
sourceId: z33.string(),
|
|
@@ -6423,6 +6517,9 @@ var conversationListItemSchema = conversationSchema.extend({
|
|
|
6423
6517
|
unread: z33.boolean().optional(),
|
|
6424
6518
|
lastViewedAt: timestampSchema.optional()
|
|
6425
6519
|
});
|
|
6520
|
+
var sharedFromOutsideListItemSchema = conversationListItemSchema.extend({
|
|
6521
|
+
workspaceName: z33.string()
|
|
6522
|
+
});
|
|
6426
6523
|
var conversationUserStateSchema = z33.object({
|
|
6427
6524
|
clientInstanceId: z33.string(),
|
|
6428
6525
|
conversationId: z33.string(),
|
|
@@ -6450,7 +6547,22 @@ var conversationThreadSnapshotSchema = z33.object({
|
|
|
6450
6547
|
* The agent of each run the conversation held, oldest first, by the message that started the
|
|
6451
6548
|
* run: where another agent answers from that message on, the history says so (T30).
|
|
6452
6549
|
*/
|
|
6453
|
-
runAgents: z33.array(
|
|
6550
|
+
runAgents: z33.array(
|
|
6551
|
+
z33.object({
|
|
6552
|
+
inputMessageId: z33.string(),
|
|
6553
|
+
agentName: z33.string(),
|
|
6554
|
+
/**
|
|
6555
|
+
* The person the run acts for, on a chat that names people or that more than one person
|
|
6556
|
+
* wrote in (CHAT-SHARE-2).
|
|
6557
|
+
*/
|
|
6558
|
+
ownerUserId: z33.string().optional(),
|
|
6559
|
+
/**
|
|
6560
|
+
* That person's name, on the same chats: their turns stay attributed after they leave
|
|
6561
|
+
* it or are removed. Missing where the account is gone.
|
|
6562
|
+
*/
|
|
6563
|
+
ownerDisplayLabel: z33.string().optional()
|
|
6564
|
+
})
|
|
6565
|
+
).optional(),
|
|
6454
6566
|
/**
|
|
6455
6567
|
* What the conversation's latest run was asked to use. Absent before the first run; a run that
|
|
6456
6568
|
* followed the configured defaults leaves both fields out.
|
|
@@ -7461,6 +7573,11 @@ var approvalRequestSchema = z38.object({
|
|
|
7461
7573
|
* Absent on a request the holders of a right decide.
|
|
7462
7574
|
*/
|
|
7463
7575
|
addresseeUserId: z38.string().optional(),
|
|
7576
|
+
/**
|
|
7577
|
+
* The requester held the right that decides it when filing. Pending, it is listed in To
|
|
7578
|
+
* decide for them alone; the other holders of the right find it with `scope=others_own`.
|
|
7579
|
+
*/
|
|
7580
|
+
requesterDecides: z38.literal(true).optional(),
|
|
7464
7581
|
status: approvalRequestStatusSchema,
|
|
7465
7582
|
decision: z38.object({
|
|
7466
7583
|
approved: z38.boolean(),
|
|
@@ -7482,10 +7599,15 @@ var approvalRequestViewSchema = approvalRequestSchema.extend({
|
|
|
7482
7599
|
canWithdraw: z38.boolean(),
|
|
7483
7600
|
canRevert: z38.boolean()
|
|
7484
7601
|
});
|
|
7602
|
+
var APPROVAL_REQUEST_LIST_SCOPES = ["decided", "others_own"];
|
|
7485
7603
|
var listApprovalRequestsQuerySchema = z38.object({
|
|
7486
7604
|
status: approvalRequestStatusSchema.optional(),
|
|
7487
|
-
/**
|
|
7488
|
-
|
|
7605
|
+
/**
|
|
7606
|
+
* `decided`: the requests that are no longer pending and changed in the last 30 days.
|
|
7607
|
+
* `others_own`: the pending requests other people filed who may decide them themselves,
|
|
7608
|
+
* which the plain list leaves out.
|
|
7609
|
+
*/
|
|
7610
|
+
scope: z38.enum(APPROVAL_REQUEST_LIST_SCOPES).optional()
|
|
7489
7611
|
});
|
|
7490
7612
|
var pendingApprovalRequestCountSchema = z38.object({
|
|
7491
7613
|
/** The pending requests the caller can decide. */
|
|
@@ -7493,6 +7615,11 @@ var pendingApprovalRequestCountSchema = z38.object({
|
|
|
7493
7615
|
canReview: z38.boolean(),
|
|
7494
7616
|
/** How many requests the list with `scope=decided` holds for the caller. */
|
|
7495
7617
|
decided: z38.number().int().nonnegative(),
|
|
7618
|
+
/**
|
|
7619
|
+
* How many pending requests the list with `scope=others_own` holds: not in `count`, since
|
|
7620
|
+
* their requesters decide them themselves.
|
|
7621
|
+
*/
|
|
7622
|
+
othersOwn: z38.number().int().nonnegative(),
|
|
7496
7623
|
/** The requests the caller made: those still pending, and all of them. */
|
|
7497
7624
|
mine: z38.object({
|
|
7498
7625
|
pending: z38.number().int().nonnegative(),
|
|
@@ -9034,9 +9161,27 @@ var connectorTypeOffersSchema = z44.object({
|
|
|
9034
9161
|
help: localizedTextSchema.optional(),
|
|
9035
9162
|
optional: z44.boolean(),
|
|
9036
9163
|
setting: z44.string().optional(),
|
|
9037
|
-
secret: z44.boolean()
|
|
9164
|
+
secret: z44.boolean(),
|
|
9165
|
+
/** What a setting holds: a whole number or a list of names. Text where left out. */
|
|
9166
|
+
value: z44.enum(CONNECTOR_FORM_FIELD_VALUES).optional(),
|
|
9167
|
+
/** What the field starts with. Never for the secret. */
|
|
9168
|
+
default: z44.string().optional(),
|
|
9169
|
+
/** The field folds away under "Technical details". */
|
|
9170
|
+
advanced: z44.literal(true).optional()
|
|
9038
9171
|
})
|
|
9039
|
-
)
|
|
9172
|
+
),
|
|
9173
|
+
/** Whose account everyone reads, before the secret and where the setup asks who may use it. */
|
|
9174
|
+
sharedAccountNote: localizedTextSchema.optional(),
|
|
9175
|
+
/** The type's own operations, approved after Verbinden. Empty for a type without a catalog. */
|
|
9176
|
+
operations: z44.array(
|
|
9177
|
+
z44.object({
|
|
9178
|
+
name: z44.string(),
|
|
9179
|
+
description: z44.string(),
|
|
9180
|
+
effect: connectionOperationEffectSchema
|
|
9181
|
+
})
|
|
9182
|
+
),
|
|
9183
|
+
/** Where an approved operation may be used: only by agents for a type whose results are private. */
|
|
9184
|
+
exposures: z44.array(z44.enum(CONNECTION_EXPOSURES))
|
|
9040
9185
|
})
|
|
9041
9186
|
),
|
|
9042
9187
|
/**
|
|
@@ -9184,9 +9329,24 @@ var personalConnectionsSchema = z44.object({
|
|
|
9184
9329
|
name: z44.string(),
|
|
9185
9330
|
title: z44.string(),
|
|
9186
9331
|
service: z44.string().optional(),
|
|
9187
|
-
catalogue: z44.object({ entry: z44.string(), part: z44.enum(CATALOGUE_PARTS), version: z44.number().int() }).optional()
|
|
9332
|
+
catalogue: z44.object({ entry: z44.string(), part: z44.enum(CATALOGUE_PARTS), version: z44.number().int() }).optional(),
|
|
9333
|
+
/**
|
|
9334
|
+
* Only on an MCP server the caller added for themselves (PMCP), which is listed to its
|
|
9335
|
+
* owner alone, also while it is switched off: its host, whether it is on, and how many
|
|
9336
|
+
* tools its owner accepted.
|
|
9337
|
+
*/
|
|
9338
|
+
ownServer: z44.object({
|
|
9339
|
+
host: z44.string(),
|
|
9340
|
+
enabled: z44.boolean(),
|
|
9341
|
+
tools: z44.number().int().nonnegative()
|
|
9342
|
+
}).optional()
|
|
9188
9343
|
})
|
|
9189
|
-
)
|
|
9344
|
+
),
|
|
9345
|
+
/**
|
|
9346
|
+
* Whether the caller may add an MCP server for themselves: the operator's switch is on, they
|
|
9347
|
+
* hold `connection.add_own`, and they are signed in to the instance in a first-party session.
|
|
9348
|
+
*/
|
|
9349
|
+
ownServers: z44.object({ mayAdd: z44.boolean() }).optional()
|
|
9190
9350
|
});
|
|
9191
9351
|
var connectionPeopleSchema = z44.object({
|
|
9192
9352
|
people: z44.array(
|
|
@@ -10211,6 +10371,24 @@ var conversationOperations = {
|
|
|
10211
10371
|
errors: ["NOT_FOUND"],
|
|
10212
10372
|
rateClass: "read"
|
|
10213
10373
|
}),
|
|
10374
|
+
"conversations.shared_from_outside.list": defineOperation({
|
|
10375
|
+
id: "conversations.shared_from_outside.list",
|
|
10376
|
+
method: "GET",
|
|
10377
|
+
path: "/api/v1/conversations/shared-from-outside",
|
|
10378
|
+
summary: "List the chats shared with the caller from workspaces they are no member of",
|
|
10379
|
+
tag: "Conversations",
|
|
10380
|
+
auth: "user",
|
|
10381
|
+
scope: "conversation:read",
|
|
10382
|
+
requires: [],
|
|
10383
|
+
effect: "reading",
|
|
10384
|
+
query: listQuerySchema.extend({
|
|
10385
|
+
/** Keeps the chats whose title contains this text, without regard to case. */
|
|
10386
|
+
query: z47.string().trim().min(1).max(CONVERSATION_TITLE_QUERY_MAX_CHARS).optional()
|
|
10387
|
+
}),
|
|
10388
|
+
response: page(sharedFromOutsideListItemSchema, ["updatedAt", "id"], true),
|
|
10389
|
+
errors: [],
|
|
10390
|
+
rateClass: "read"
|
|
10391
|
+
}),
|
|
10214
10392
|
"conversations.create": defineOperation({
|
|
10215
10393
|
id: "conversations.create",
|
|
10216
10394
|
method: "POST",
|
|
@@ -10286,6 +10464,68 @@ var conversationOperations = {
|
|
|
10286
10464
|
errors: ["NOT_FOUND", "CONFLICT"],
|
|
10287
10465
|
rateClass: "write"
|
|
10288
10466
|
}),
|
|
10467
|
+
// Who reads a private chat beside its creator (CHAT-SHARE). Only the person in their own
|
|
10468
|
+
// session changes it: never an agent tool, and a key or a delegated actor is refused by the
|
|
10469
|
+
// service whatever its scopes.
|
|
10470
|
+
"conversations.add_person": defineOperation({
|
|
10471
|
+
id: "conversations.add_person",
|
|
10472
|
+
method: "POST",
|
|
10473
|
+
path: "/api/v1/conversations/:conversationId/people",
|
|
10474
|
+
summary: "Name a member of the chat's workspace to read and write in the creator's private chat",
|
|
10475
|
+
tag: "Conversations",
|
|
10476
|
+
auth: "user",
|
|
10477
|
+
scope: "conversation:write",
|
|
10478
|
+
requires: [],
|
|
10479
|
+
effect: "changing",
|
|
10480
|
+
body: addConversationPersonRequestSchema,
|
|
10481
|
+
response: json(conversationSchema),
|
|
10482
|
+
errors: ["NOT_FOUND", "FORBIDDEN", "CONFLICT", "VALIDATION_FAILED"],
|
|
10483
|
+
rateClass: "write"
|
|
10484
|
+
}),
|
|
10485
|
+
"conversations.remove_person": defineOperation({
|
|
10486
|
+
id: "conversations.remove_person",
|
|
10487
|
+
method: "DELETE",
|
|
10488
|
+
path: "/api/v1/conversations/:conversationId/people/:userId",
|
|
10489
|
+
summary: "Take a named person off a private chat: its creator removes anyone, a named person leaves",
|
|
10490
|
+
tag: "Conversations",
|
|
10491
|
+
auth: "user",
|
|
10492
|
+
scope: "conversation:write",
|
|
10493
|
+
requires: [],
|
|
10494
|
+
effect: "changing",
|
|
10495
|
+
response: json(conversationPersonRemovedSchema),
|
|
10496
|
+
errors: ["NOT_FOUND", "FORBIDDEN", "CONFLICT"],
|
|
10497
|
+
rateClass: "write"
|
|
10498
|
+
}),
|
|
10499
|
+
"conversations.share_candidates": defineOperation({
|
|
10500
|
+
id: "conversations.share_candidates",
|
|
10501
|
+
method: "GET",
|
|
10502
|
+
path: "/api/v1/conversations/:conversationId/share-candidates",
|
|
10503
|
+
summary: "The people of the instance the chat's creator may name, preselected or searched",
|
|
10504
|
+
tag: "Conversations",
|
|
10505
|
+
auth: "user",
|
|
10506
|
+
scope: "conversation:read",
|
|
10507
|
+
requires: [],
|
|
10508
|
+
effect: "reading",
|
|
10509
|
+
query: shareCandidatesQuerySchema,
|
|
10510
|
+
response: json(conversationShareCandidatesSchema),
|
|
10511
|
+
errors: ["NOT_FOUND", "FORBIDDEN", "RATE_LIMITED"],
|
|
10512
|
+
rateClass: "read"
|
|
10513
|
+
}),
|
|
10514
|
+
"conversations.reader_offer.get": defineOperation({
|
|
10515
|
+
id: "conversations.reader_offer.get",
|
|
10516
|
+
method: "GET",
|
|
10517
|
+
path: "/api/v1/conversations/:conversationId/reader-offer",
|
|
10518
|
+
summary: "What the caller is offered in a chat they read: its workspace, and their agents",
|
|
10519
|
+
tag: "Conversations",
|
|
10520
|
+
auth: "user",
|
|
10521
|
+
scope: "conversation:read",
|
|
10522
|
+
requires: [],
|
|
10523
|
+
effect: "reading",
|
|
10524
|
+
query: z47.object({ locale: z47.string().optional() }),
|
|
10525
|
+
response: json(conversationReaderOfferSchema),
|
|
10526
|
+
errors: ["NOT_FOUND"],
|
|
10527
|
+
rateClass: "read"
|
|
10528
|
+
}),
|
|
10289
10529
|
"conversations.thread.get": defineOperation({
|
|
10290
10530
|
id: "conversations.thread.get",
|
|
10291
10531
|
method: "GET",
|
|
@@ -11763,7 +12003,14 @@ var knowledgeSearchResponseSchema = z57.object({
|
|
|
11763
12003
|
text: z57.string(),
|
|
11764
12004
|
/** Reciprocal rank fusion of the lists in `signals`: compare it only within one Knowledge Base. */
|
|
11765
12005
|
score: z57.number(),
|
|
11766
|
-
originLink: z57.string().optional()
|
|
12006
|
+
originLink: z57.string().optional(),
|
|
12007
|
+
/**
|
|
12008
|
+
* The date a synced document states of its own version, such as the "Stand" of a web
|
|
12009
|
+
* page. An ISO date-time in UTC; none where the document states no date.
|
|
12010
|
+
*/
|
|
12011
|
+
statedAt: z57.string().optional(),
|
|
12012
|
+
/** When the platform fetched the synced version. An ISO date-time in UTC. */
|
|
12013
|
+
retrievedAt: z57.string().optional()
|
|
11767
12014
|
})
|
|
11768
12015
|
),
|
|
11769
12016
|
/** The ranked lists fused: `semantic`, `keyword` and `title`. */
|
|
@@ -14641,10 +14888,14 @@ function cliCompatibilityError(cliVersion, serverVersion) {
|
|
|
14641
14888
|
}
|
|
14642
14889
|
return cliVersion.split("+")[0] === serverVersion.split("+")[0] ? void 0 : new CliVersionError(cliVersion, serverVersion);
|
|
14643
14890
|
}
|
|
14891
|
+
function releaseVersionOf(serverVersion) {
|
|
14892
|
+
const release = serverVersion.split("+")[0] ?? "";
|
|
14893
|
+
return release.length <= 64 && versionParts(release) ? release : void 0;
|
|
14894
|
+
}
|
|
14644
14895
|
var CliVersionError = class extends Error {
|
|
14645
|
-
constructor(cliVersion, serverVersion) {
|
|
14896
|
+
constructor(cliVersion, serverVersion, instead) {
|
|
14646
14897
|
super(
|
|
14647
|
-
`Catalyst CLI ${cliVersion} does not match server ${serverVersion}; run: npm install --global @work-shape/catalyst-cli@${serverVersion.split("+")[0]}`
|
|
14898
|
+
`Catalyst CLI ${cliVersion} does not match server ${serverVersion}; ${instead ?? `run: npm install --global @work-shape/catalyst-cli@${serverVersion.split("+")[0]}`}`
|
|
14648
14899
|
);
|
|
14649
14900
|
this.cliVersion = cliVersion;
|
|
14650
14901
|
this.serverVersion = serverVersion;
|
|
@@ -14654,6 +14905,195 @@ var CliVersionError = class extends Error {
|
|
|
14654
14905
|
serverVersion;
|
|
14655
14906
|
};
|
|
14656
14907
|
|
|
14908
|
+
// src/self-update.ts
|
|
14909
|
+
import { spawnSync } from "child_process";
|
|
14910
|
+
import { existsSync, lstatSync, readFileSync, realpathSync } from "fs";
|
|
14911
|
+
import { posix, win32 } from "path";
|
|
14912
|
+
import { fileURLToPath } from "url";
|
|
14913
|
+
import { z as z70 } from "zod";
|
|
14914
|
+
|
|
14915
|
+
// src/env.ts
|
|
14916
|
+
function readConfigCliEnv(env) {
|
|
14917
|
+
return env ?? process.env;
|
|
14918
|
+
}
|
|
14919
|
+
function environmentUpdatedFrom(version) {
|
|
14920
|
+
return { ...process.env, CATALYST_CLI_UPDATED_FROM: version };
|
|
14921
|
+
}
|
|
14922
|
+
|
|
14923
|
+
// src/self-update.ts
|
|
14924
|
+
var PACKAGE = "@work-shape/catalyst-cli";
|
|
14925
|
+
var INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
14926
|
+
function isSet(value) {
|
|
14927
|
+
return value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
14928
|
+
}
|
|
14929
|
+
function mayUpdateItself(env, interactive) {
|
|
14930
|
+
return interactive && !isSet(env.CATALYST_NO_AUTO_UPDATE) && !isSet(env.CI) && env.CATALYST_CLI_UPDATED_FROM === void 0;
|
|
14931
|
+
}
|
|
14932
|
+
function projectInstallation(host, version) {
|
|
14933
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14934
|
+
const parts = host.packageRoot.split(path.sep);
|
|
14935
|
+
const first = parts.indexOf("node_modules");
|
|
14936
|
+
if (first <= 0 || parts.includes("_npx") || parts.includes("dlx")) return { kind: "elsewhere" };
|
|
14937
|
+
const spec = `${PACKAGE}@${version}`;
|
|
14938
|
+
if (parts[first - 2] === "global" && /^[0-9]+$/u.test(parts[first - 1] ?? "")) {
|
|
14939
|
+
return { kind: "pnpm-global", command: `pnpm add --global ${spec}` };
|
|
14940
|
+
}
|
|
14941
|
+
const folder = parts.slice(0, first).join(path.sep) || path.sep;
|
|
14942
|
+
if (!host.exists(path.join(folder, "package.json"))) return { kind: "elsewhere" };
|
|
14943
|
+
const command = host.exists(path.join(folder, "pnpm-lock.yaml")) ? `pnpm add --save-exact ${spec}` : host.exists(path.join(folder, "yarn.lock")) ? `yarn add --exact ${spec}` : `npm install --save-exact ${spec}`;
|
|
14944
|
+
return { kind: "project", folder, command };
|
|
14945
|
+
}
|
|
14946
|
+
function npmCommand(host) {
|
|
14947
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14948
|
+
const bin = path.dirname(host.execPath);
|
|
14949
|
+
const script = [
|
|
14950
|
+
path.join(bin, "node_modules", "npm", "bin", "npm-cli.js"),
|
|
14951
|
+
path.join(bin, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
|
|
14952
|
+
].find((candidate) => host.exists(candidate));
|
|
14953
|
+
if (script) return { file: host.execPath, args: [script] };
|
|
14954
|
+
return host.platform === "win32" ? void 0 : { file: "npm", args: [] };
|
|
14955
|
+
}
|
|
14956
|
+
function lastErrorLine(output) {
|
|
14957
|
+
const lines = output.split(/\r?\n/u).map((line2) => line2.trim()).filter(Boolean);
|
|
14958
|
+
const line = lines.find((entry) => /^npm (?:error|ERR!)/u.test(entry) && !/complete log/u.test(entry)) ?? lines.at(-1);
|
|
14959
|
+
return line === void 0 ? "npm gave no reason" : line.slice(0, 200);
|
|
14960
|
+
}
|
|
14961
|
+
var manifestSchema = z70.object({
|
|
14962
|
+
version: z70.string().optional(),
|
|
14963
|
+
bin: z70.object({ catalyst: z70.string().optional() }).optional()
|
|
14964
|
+
});
|
|
14965
|
+
function installedVersion(host) {
|
|
14966
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14967
|
+
let parsed;
|
|
14968
|
+
try {
|
|
14969
|
+
parsed = JSON.parse(host.readText(path.join(host.packageRoot, "package.json")) ?? "{}");
|
|
14970
|
+
} catch {
|
|
14971
|
+
return {};
|
|
14972
|
+
}
|
|
14973
|
+
const manifest = manifestSchema.safeParse(parsed);
|
|
14974
|
+
if (!manifest.success) return {};
|
|
14975
|
+
return {
|
|
14976
|
+
...manifest.data.version === void 0 ? {} : { version: manifest.data.version },
|
|
14977
|
+
...manifest.data.bin?.catalyst === void 0 ? {} : { bin: manifest.data.bin.catalyst }
|
|
14978
|
+
};
|
|
14979
|
+
}
|
|
14980
|
+
function updateToServerVersion(mismatch, host) {
|
|
14981
|
+
const version = releaseVersionOf(mismatch.serverVersion);
|
|
14982
|
+
if (version === void 0) return mismatch;
|
|
14983
|
+
const project = projectInstallation(host, version);
|
|
14984
|
+
if (project.kind !== "elsewhere") {
|
|
14985
|
+
return new CliVersionError(
|
|
14986
|
+
mismatch.cliVersion,
|
|
14987
|
+
mismatch.serverVersion,
|
|
14988
|
+
project.kind === "project" ? `in ${project.folder} run: ${project.command}` : `run: ${project.command}`
|
|
14989
|
+
);
|
|
14990
|
+
}
|
|
14991
|
+
if (!older(mismatch.cliVersion, version)) return mismatch;
|
|
14992
|
+
if (!mayUpdateItself(host.env, host.interactive)) return mismatch;
|
|
14993
|
+
const npm = npmCommand(host);
|
|
14994
|
+
if (npm === void 0) return mismatch;
|
|
14995
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14996
|
+
const root = host.run(npm.file, [...npm.args, "root", "--global"], {});
|
|
14997
|
+
const globalRoot = root.status === 0 ? root.stdout.trim() : "";
|
|
14998
|
+
const globalPackage = path.join(globalRoot, ...PACKAGE.split("/"));
|
|
14999
|
+
let ours;
|
|
15000
|
+
try {
|
|
15001
|
+
ours = globalRoot !== "" && !host.isLink(globalPackage) && host.realpath(globalPackage) === host.realpath(host.packageRoot);
|
|
15002
|
+
} catch {
|
|
15003
|
+
ours = false;
|
|
15004
|
+
}
|
|
15005
|
+
if (!ours) return mismatch;
|
|
15006
|
+
host.stderr(
|
|
15007
|
+
`The instance runs ${version}; installing ${PACKAGE}@${version} in place of ${mismatch.cliVersion} and running the command again.
|
|
15008
|
+
`
|
|
15009
|
+
);
|
|
15010
|
+
const install = host.run(
|
|
15011
|
+
npm.file,
|
|
15012
|
+
[
|
|
15013
|
+
...npm.args,
|
|
15014
|
+
"install",
|
|
15015
|
+
"--global",
|
|
15016
|
+
"--no-fund",
|
|
15017
|
+
"--no-audit",
|
|
15018
|
+
"--loglevel=error",
|
|
15019
|
+
`${PACKAGE}@${version}`
|
|
15020
|
+
],
|
|
15021
|
+
{}
|
|
15022
|
+
);
|
|
15023
|
+
const installed = installedVersion(host);
|
|
15024
|
+
if (install.status !== 0 || installed.version !== version) {
|
|
15025
|
+
host.stderr(
|
|
15026
|
+
`Could not install ${PACKAGE}@${version}: ${lastErrorLine(`${install.stdout}
|
|
15027
|
+
${install.stderr}`)}
|
|
15028
|
+
`
|
|
15029
|
+
);
|
|
15030
|
+
return mismatch;
|
|
15031
|
+
}
|
|
15032
|
+
const entry = path.resolve(host.packageRoot, installed.bin ?? "dist/index.js");
|
|
15033
|
+
if (!entry.startsWith(host.packageRoot + path.sep)) return mismatch;
|
|
15034
|
+
const again = host.run(host.execPath, [entry, ...host.argv], {
|
|
15035
|
+
againFrom: mismatch.cliVersion
|
|
15036
|
+
});
|
|
15037
|
+
return host.exit(again.status ?? 1);
|
|
15038
|
+
}
|
|
15039
|
+
var state;
|
|
15040
|
+
function onInstanceAnswer() {
|
|
15041
|
+
if (state) state.answered = true;
|
|
15042
|
+
}
|
|
15043
|
+
function onCliVersionMismatch(mismatch) {
|
|
15044
|
+
const active = state;
|
|
15045
|
+
if (active === void 0 || active.answered) return Promise.resolve(mismatch);
|
|
15046
|
+
active.attempt ??= Promise.resolve().then(() => updateToServerVersion(mismatch, active.host));
|
|
15047
|
+
return active.attempt;
|
|
15048
|
+
}
|
|
15049
|
+
function enableSelfUpdate(argv, host = processHost(argv)) {
|
|
15050
|
+
const enabled = { host, answered: false };
|
|
15051
|
+
state = enabled;
|
|
15052
|
+
return () => {
|
|
15053
|
+
if (state === enabled) state = void 0;
|
|
15054
|
+
};
|
|
15055
|
+
}
|
|
15056
|
+
function processHost(argv) {
|
|
15057
|
+
return {
|
|
15058
|
+
argv,
|
|
15059
|
+
env: readConfigCliEnv(),
|
|
15060
|
+
interactive: process.stdin.isTTY === true && process.stderr.isTTY === true,
|
|
15061
|
+
platform: process.platform,
|
|
15062
|
+
execPath: process.execPath,
|
|
15063
|
+
packageRoot: realpathSync(fileURLToPath(new URL("..", import.meta.url))).replace(/[\\/]$/u, ""),
|
|
15064
|
+
exists: existsSync,
|
|
15065
|
+
readText: (path) => {
|
|
15066
|
+
try {
|
|
15067
|
+
return readFileSync(path, "utf8");
|
|
15068
|
+
} catch {
|
|
15069
|
+
return void 0;
|
|
15070
|
+
}
|
|
15071
|
+
},
|
|
15072
|
+
realpath: realpathSync,
|
|
15073
|
+
isLink: (path) => {
|
|
15074
|
+
try {
|
|
15075
|
+
return lstatSync(path).isSymbolicLink();
|
|
15076
|
+
} catch {
|
|
15077
|
+
return false;
|
|
15078
|
+
}
|
|
15079
|
+
},
|
|
15080
|
+
run: (file, args, options) => {
|
|
15081
|
+
const result = spawnSync(file, args, {
|
|
15082
|
+
shell: false,
|
|
15083
|
+
windowsHide: true,
|
|
15084
|
+
...options.againFrom !== void 0 ? { stdio: "inherit", env: environmentUpdatedFrom(options.againFrom) } : { encoding: "utf8", timeout: INSTALL_TIMEOUT_MS, maxBuffer: 16 * 1024 * 1024 }
|
|
15085
|
+
});
|
|
15086
|
+
return {
|
|
15087
|
+
status: result.status,
|
|
15088
|
+
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
15089
|
+
stderr: typeof result.stderr === "string" ? result.stderr : ""
|
|
15090
|
+
};
|
|
15091
|
+
},
|
|
15092
|
+
stderr: (text2) => process.stderr.write(text2),
|
|
15093
|
+
exit: (code) => process.exit(code)
|
|
15094
|
+
};
|
|
15095
|
+
}
|
|
15096
|
+
|
|
14657
15097
|
// src/api.ts
|
|
14658
15098
|
var ConfigApiError = class extends Error {
|
|
14659
15099
|
status;
|
|
@@ -14848,9 +15288,10 @@ function instanceFetch(fetchImpl, diagnostics = {}) {
|
|
|
14848
15288
|
const mismatch = cliCompatibilityError(RELEASE_VERSION, serverVersion);
|
|
14849
15289
|
if (diagnostics.checkVersion !== false && mismatch) {
|
|
14850
15290
|
await response.body?.cancel();
|
|
14851
|
-
throw mismatch;
|
|
15291
|
+
throw mismatch instanceof CliVersionError ? await onCliVersionMismatch(mismatch) : mismatch;
|
|
14852
15292
|
}
|
|
14853
15293
|
}
|
|
15294
|
+
onInstanceAnswer();
|
|
14854
15295
|
return response;
|
|
14855
15296
|
};
|
|
14856
15297
|
}
|
|
@@ -14964,9 +15405,9 @@ async function readFolderState(directory, filename, kind) {
|
|
|
14964
15405
|
name: name2
|
|
14965
15406
|
};
|
|
14966
15407
|
}
|
|
14967
|
-
async function writeFolderState(directory, filename,
|
|
15408
|
+
async function writeFolderState(directory, filename, state2) {
|
|
14968
15409
|
const path = join(directory, filename);
|
|
14969
|
-
await writeFile(`${path}.tmp`, `${JSON.stringify(
|
|
15410
|
+
await writeFile(`${path}.tmp`, `${JSON.stringify(state2, null, 2)}
|
|
14970
15411
|
`, { mode: 420 });
|
|
14971
15412
|
await rename(`${path}.tmp`, path);
|
|
14972
15413
|
}
|
|
@@ -14984,13 +15425,13 @@ async function refuseLinks(directory, recursive = true) {
|
|
|
14984
15425
|
for (const entry of await readdir(directory)) await refuseLinks(join(directory, entry));
|
|
14985
15426
|
}
|
|
14986
15427
|
}
|
|
14987
|
-
async function localChanges(directory,
|
|
15428
|
+
async function localChanges(directory, state2, filename, ignoreUntracked = false) {
|
|
14988
15429
|
const now = {};
|
|
14989
15430
|
const walk2 = async (folder, prefix) => {
|
|
14990
15431
|
for (const entry of await readdir(folder, { withFileTypes: true })) {
|
|
14991
15432
|
const path = `${prefix}${entry.name}`;
|
|
14992
15433
|
if (path === filename || entry.name === ".DS_Store" && entry.isFile()) continue;
|
|
14993
|
-
const tracked = Object.hasOwn(
|
|
15434
|
+
const tracked = Object.hasOwn(state2.files, path) || Object.keys(state2.files).some((file) => file.startsWith(`${path}/`));
|
|
14994
15435
|
if (ignoreUntracked && !tracked && (entry.name.startsWith(".") || entry.isDirectory() && entry.name === "node_modules"))
|
|
14995
15436
|
continue;
|
|
14996
15437
|
if (entry.isDirectory()) await walk2(join(folder, entry.name), `${path}/`);
|
|
@@ -15004,10 +15445,10 @@ async function localChanges(directory, state, filename, ignoreUntracked = false)
|
|
|
15004
15445
|
await walk2(directory, "");
|
|
15005
15446
|
return {
|
|
15006
15447
|
changed: Object.keys(now).filter(
|
|
15007
|
-
(path) => Object.hasOwn(
|
|
15448
|
+
(path) => Object.hasOwn(state2.files, path) && now[path] !== state2.files[path]
|
|
15008
15449
|
),
|
|
15009
|
-
added: Object.keys(now).filter((path) => !Object.hasOwn(
|
|
15010
|
-
removed: Object.keys(
|
|
15450
|
+
added: Object.keys(now).filter((path) => !Object.hasOwn(state2.files, path)),
|
|
15451
|
+
removed: Object.keys(state2.files).filter(
|
|
15011
15452
|
(path) => basename(path) !== ".DS_Store" && !Object.hasOwn(now, path)
|
|
15012
15453
|
)
|
|
15013
15454
|
};
|
|
@@ -15032,7 +15473,7 @@ async function writeFolderFiles(directory, files, previous) {
|
|
|
15032
15473
|
}
|
|
15033
15474
|
return hashes;
|
|
15034
15475
|
}
|
|
15035
|
-
async function replaceFolder(directory, files, filename,
|
|
15476
|
+
async function replaceFolder(directory, files, filename, state2, beforeReplace) {
|
|
15036
15477
|
const createdParent = await mkdir(dirname(directory), { recursive: true });
|
|
15037
15478
|
let temporary;
|
|
15038
15479
|
let installed = false;
|
|
@@ -15045,7 +15486,7 @@ async function replaceFolder(directory, files, filename, state, beforeReplace) {
|
|
|
15045
15486
|
if (files.some((file) => file.path === filename))
|
|
15046
15487
|
throw new Error(`The instance named the reserved state file '${filename}'.`);
|
|
15047
15488
|
const hashes = await writeFolderFiles(staged, files);
|
|
15048
|
-
await writeFolderState(staged, filename, { ...
|
|
15489
|
+
await writeFolderState(staged, filename, { ...state2, files: hashes });
|
|
15049
15490
|
await beforeReplace();
|
|
15050
15491
|
try {
|
|
15051
15492
|
await rename(directory, backup);
|
|
@@ -15271,11 +15712,6 @@ function isCredentialFile(value) {
|
|
|
15271
15712
|
);
|
|
15272
15713
|
}
|
|
15273
15714
|
|
|
15274
|
-
// src/env.ts
|
|
15275
|
-
function readConfigCliEnv(env) {
|
|
15276
|
-
return env ?? process.env;
|
|
15277
|
-
}
|
|
15278
|
-
|
|
15279
15715
|
// src/guardrail-files.ts
|
|
15280
15716
|
import { readFile as readFile4, stat as stat2 } from "fs/promises";
|
|
15281
15717
|
import { join as join4 } from "path";
|
|
@@ -15592,10 +16028,10 @@ function readBaselineHashes(input) {
|
|
|
15592
16028
|
})
|
|
15593
16029
|
);
|
|
15594
16030
|
}
|
|
15595
|
-
async function writeStateFile(path,
|
|
16031
|
+
async function writeStateFile(path, state2) {
|
|
15596
16032
|
await mkdir3(dirname3(path), { recursive: true });
|
|
15597
16033
|
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
15598
|
-
await writeFile3(temporaryPath, `${JSON.stringify(
|
|
16034
|
+
await writeFile3(temporaryPath, `${JSON.stringify(state2, null, 2)}
|
|
15599
16035
|
`, "utf8");
|
|
15600
16036
|
await rename3(temporaryPath, path);
|
|
15601
16037
|
}
|
|
@@ -16283,8 +16719,8 @@ async function openInstance(options) {
|
|
|
16283
16719
|
}
|
|
16284
16720
|
async function recordBaseline(workingDir, instanceKey, version, bundle, revisions, fullPull, defaultAgentName, tombstones = {}) {
|
|
16285
16721
|
const path = resolve4(workingDir, STATE_FILENAME);
|
|
16286
|
-
const
|
|
16287
|
-
const previous =
|
|
16722
|
+
const state2 = await readStateFile(path);
|
|
16723
|
+
const previous = state2.instances[instanceKey];
|
|
16288
16724
|
const baseline = {
|
|
16289
16725
|
...previous,
|
|
16290
16726
|
lastPulledVersion: fullPull ? version : previous?.lastPulledVersion ?? version
|
|
@@ -16321,7 +16757,7 @@ async function recordBaseline(workingDir, instanceKey, version, bundle, revision
|
|
|
16321
16757
|
if (defaultAgentName !== void 0) {
|
|
16322
16758
|
baseline.defaultAgentName = defaultAgentName;
|
|
16323
16759
|
}
|
|
16324
|
-
await writeStateFile(path, { instances: { ...
|
|
16760
|
+
await writeStateFile(path, { instances: { ...state2.instances, [instanceKey]: baseline } });
|
|
16325
16761
|
}
|
|
16326
16762
|
function resolveWorkingDir(options) {
|
|
16327
16763
|
return resolve4(options.cwd, options.dir ?? ".");
|
|
@@ -16738,18 +17174,18 @@ var REPOSITORY_KINDS = {
|
|
|
16738
17174
|
}
|
|
16739
17175
|
};
|
|
16740
17176
|
async function readRepositoryState(directory, kind) {
|
|
16741
|
-
const
|
|
16742
|
-
if (
|
|
16743
|
-
return
|
|
17177
|
+
const state2 = await readFolderState(directory, APP_STATE_FILE, kind.kind);
|
|
17178
|
+
if (state2 === void 0) return void 0;
|
|
17179
|
+
return state2;
|
|
16744
17180
|
}
|
|
16745
|
-
async function writeRepositoryState(directory,
|
|
17181
|
+
async function writeRepositoryState(directory, state2, kind) {
|
|
16746
17182
|
await writeFolderState(directory, APP_STATE_FILE, {
|
|
16747
|
-
instance:
|
|
16748
|
-
workspaceId:
|
|
16749
|
-
[kind.kind]:
|
|
16750
|
-
assetId:
|
|
16751
|
-
revision:
|
|
16752
|
-
files:
|
|
17183
|
+
instance: state2.instance,
|
|
17184
|
+
workspaceId: state2.workspaceId,
|
|
17185
|
+
[kind.kind]: state2.name,
|
|
17186
|
+
assetId: state2.assetId,
|
|
17187
|
+
revision: state2.revision,
|
|
17188
|
+
files: state2.files
|
|
16753
17189
|
});
|
|
16754
17190
|
}
|
|
16755
17191
|
async function readRepositoryFolder(directory, limits, tracked, kind) {
|
|
@@ -16823,8 +17259,8 @@ async function walk(root, directory, tracked, found, leftOut) {
|
|
|
16823
17259
|
}
|
|
16824
17260
|
}
|
|
16825
17261
|
}
|
|
16826
|
-
async function localChanges2(directory,
|
|
16827
|
-
return localChanges(directory,
|
|
17262
|
+
async function localChanges2(directory, state2) {
|
|
17263
|
+
return localChanges(directory, state2, APP_STATE_FILE, true);
|
|
16828
17264
|
}
|
|
16829
17265
|
function utf8Text2(bytes) {
|
|
16830
17266
|
try {
|
|
@@ -16904,6 +17340,19 @@ function formatAssetList(kind, assets) {
|
|
|
16904
17340
|
])
|
|
16905
17341
|
);
|
|
16906
17342
|
}
|
|
17343
|
+
function availabilityPhrase(availability) {
|
|
17344
|
+
const personal = availability.personalWorkspaces ? ["personal workspaces"] : [];
|
|
17345
|
+
switch (availability.mode) {
|
|
17346
|
+
case "all":
|
|
17347
|
+
return "every workspace";
|
|
17348
|
+
case "all_except":
|
|
17349
|
+
return `every ${availability.personalWorkspaces ? "" : "shared "}workspace except ${list(
|
|
17350
|
+
availability.collaborationWorkspaceIds
|
|
17351
|
+
)}`;
|
|
17352
|
+
case "selected":
|
|
17353
|
+
return list([...personal, ...availability.collaborationWorkspaceIds]);
|
|
17354
|
+
}
|
|
17355
|
+
}
|
|
16907
17356
|
function formatAsset(asset) {
|
|
16908
17357
|
const facts = [
|
|
16909
17358
|
["kind", asset.kind],
|
|
@@ -16915,13 +17364,7 @@ function formatAsset(asset) {
|
|
|
16915
17364
|
["content of revision", asset.contentRevision?.toString()],
|
|
16916
17365
|
["scope", scopeLabel(asset.scope)],
|
|
16917
17366
|
["default", asset.isDefault ? "yes" : void 0],
|
|
16918
|
-
[
|
|
16919
|
-
"available in",
|
|
16920
|
-
asset.availability && (asset.availability.mode === "all" ? "every workspace" : list([
|
|
16921
|
-
...asset.availability.personalWorkspaces ? ["personal workspaces"] : [],
|
|
16922
|
-
...asset.availability.collaborationWorkspaceIds
|
|
16923
|
-
]))
|
|
16924
|
-
],
|
|
17367
|
+
["available in", asset.availability && availabilityPhrase(asset.availability)],
|
|
16925
17368
|
["updated", asset.updatedAt]
|
|
16926
17369
|
];
|
|
16927
17370
|
const lines = facts.flatMap(
|
|
@@ -17040,12 +17483,19 @@ async function askBeforePublish(options, publish2) {
|
|
|
17040
17483
|
writeError(options, "Nothing was published.");
|
|
17041
17484
|
return "refused";
|
|
17042
17485
|
}
|
|
17043
|
-
|
|
17486
|
+
var OVERTAKEN_LINE = "If another version goes live before it is decided, this request is settled as superseded: it can do nothing then and never overwrites that version.";
|
|
17487
|
+
function isAlreadyLive(error) {
|
|
17488
|
+
return error instanceof ConfigApiError && error.status === 409 && isRecord(error.details) && error.details.reason === "already_live";
|
|
17489
|
+
}
|
|
17490
|
+
function alreadyLiveLine(kind, name2, revision) {
|
|
17491
|
+
return `Revision ${revision} of ${kind} '${name2}' is already live. Nothing to do: nothing was published and no request was filed.`;
|
|
17492
|
+
}
|
|
17493
|
+
function waitingPublishLine(run, approvalHint, note) {
|
|
17044
17494
|
const named = `${run.approvalRequestId === void 0 ? "" : `request ${run.approvalRequestId}, `}Operation Run ${run.id}`;
|
|
17045
17495
|
if (run.status === "pending_confirmation") {
|
|
17046
|
-
return `Waits in your Inbox for your confirmation; nothing has changed yet (${named}). Allow it there to publish, or deny it
|
|
17496
|
+
return `Waits in your Inbox for your confirmation; nothing has changed yet (${named}). Allow it there to publish, or deny it.${note ? ` ${note}` : ""}`;
|
|
17047
17497
|
}
|
|
17048
|
-
return `Waits for an approval on the instance; nothing has changed yet (${named}).${approvalHint ? ` ${approvalHint}` : ""}`;
|
|
17498
|
+
return `Waits for an approval on the instance; nothing has changed yet (${named}).${approvalHint ? ` ${approvalHint}` : ""}${note ? ` ${note}` : ""}`;
|
|
17049
17499
|
}
|
|
17050
17500
|
function agentPublishRefusalHint(error) {
|
|
17051
17501
|
if (!(error instanceof ConfigApiError) || error.status !== 403) return void 0;
|
|
@@ -17194,8 +17644,8 @@ async function pull(app, directory, values, options, kind) {
|
|
|
17194
17644
|
return EXIT.done;
|
|
17195
17645
|
}
|
|
17196
17646
|
async function push(directory, values, options, kind) {
|
|
17197
|
-
const
|
|
17198
|
-
const target = await openRepository(options, values,
|
|
17647
|
+
const state2 = await readRepositoryState(directory, kind);
|
|
17648
|
+
const target = await openRepository(options, values, state2, kind);
|
|
17199
17649
|
const registered = target.kinds.find((candidate) => candidate.kind === kind.kind);
|
|
17200
17650
|
if (registered === void 0) {
|
|
17201
17651
|
throw new Error(
|
|
@@ -17205,44 +17655,44 @@ async function push(directory, values, options, kind) {
|
|
|
17205
17655
|
const read2 = await readRepositoryFolder(
|
|
17206
17656
|
directory,
|
|
17207
17657
|
registered.limits,
|
|
17208
|
-
new Set(Object.keys(
|
|
17658
|
+
new Set(Object.keys(state2?.files ?? {})),
|
|
17209
17659
|
kind
|
|
17210
17660
|
);
|
|
17211
|
-
const name2 =
|
|
17212
|
-
if (
|
|
17661
|
+
const name2 = state2?.name ?? repositoryIdOf(read2.files, kind);
|
|
17662
|
+
if (state2 === void 0 && name2 === void 0) {
|
|
17213
17663
|
throw new RepositoryUsageError(
|
|
17214
17664
|
`${kind.manifest} names no \`id\`. The id is the ${kind.label}'s name on the instance: add \`id: <name>\` to ${kind.manifest}.`
|
|
17215
17665
|
);
|
|
17216
17666
|
}
|
|
17217
17667
|
const app = name2 ?? "";
|
|
17218
|
-
const declared =
|
|
17219
|
-
if (
|
|
17668
|
+
const declared = state2 === void 0 ? void 0 : declaredIdOf(read2.files, kind);
|
|
17669
|
+
if (state2 !== void 0 && declared !== void 0 && declared !== state2.name) {
|
|
17220
17670
|
throw new RepositoryUsageError(
|
|
17221
|
-
`${kind.manifest} names the id '${declared}', and '${directory}' holds the ${kind.label} '${
|
|
17671
|
+
`${kind.manifest} names the id '${declared}', and '${directory}' holds the ${kind.label} '${state2.name}'. ${kind.article} ${kind.label} keeps its id: set \`id: ${state2.name}\` again, or copy the files without ${APP_STATE_FILE} into a new folder to create the ${kind.label} '${declared}'.`
|
|
17222
17672
|
);
|
|
17223
17673
|
}
|
|
17224
|
-
const expectedRevision =
|
|
17225
|
-
if (
|
|
17674
|
+
const expectedRevision = state2?.revision ?? null;
|
|
17675
|
+
if (state2 !== void 0 && state2.workspaceId !== target.workspaceId) {
|
|
17226
17676
|
throw new RepositoryUsageError(
|
|
17227
|
-
`'${directory}' was pulled from workspace ${
|
|
17677
|
+
`'${directory}' was pulled from workspace ${state2.workspaceId}, and the command names ${target.workspaceId}.`
|
|
17228
17678
|
);
|
|
17229
17679
|
}
|
|
17230
|
-
if (kind.kind === "workflow" &&
|
|
17680
|
+
if (kind.kind === "workflow" && state2 !== void 0 && Object.keys(read2.hashes).length === Object.keys(state2.files).length && Object.entries(read2.hashes).every(([path, hash2]) => state2.files[path] === hash2)) {
|
|
17231
17681
|
const current = await target.api.read(
|
|
17232
17682
|
(client) => client.assets.get({
|
|
17233
17683
|
params: { kind: kind.kind, name: app },
|
|
17234
17684
|
query: { workspaceId: target.workspaceId }
|
|
17235
17685
|
})
|
|
17236
17686
|
);
|
|
17237
|
-
if ((current.draftRevision ?? current.revision) ===
|
|
17687
|
+
if ((current.draftRevision ?? current.revision) === state2.revision) {
|
|
17238
17688
|
writeOut(
|
|
17239
17689
|
options,
|
|
17240
17690
|
values.json ? JSON.stringify(
|
|
17241
|
-
{ revision:
|
|
17691
|
+
{ revision: state2.revision, unchanged: true, leftOut: read2.leftOut },
|
|
17242
17692
|
null,
|
|
17243
17693
|
2
|
|
17244
17694
|
) : [
|
|
17245
|
-
`Unchanged ${kind.label} '${app}' at draft revision ${
|
|
17695
|
+
`Unchanged ${kind.label} '${app}' at draft revision ${state2.revision}.`,
|
|
17246
17696
|
...read2.leftOut.length === 0 ? [] : [`Left out: ${read2.leftOut.join(", ")}`]
|
|
17247
17697
|
].join("\n")
|
|
17248
17698
|
);
|
|
@@ -17412,7 +17862,8 @@ async function publish(app, values, options) {
|
|
|
17412
17862
|
outcome.run,
|
|
17413
17863
|
values.json,
|
|
17414
17864
|
options,
|
|
17415
|
-
"If you are an instance approver, you can approve it in the Inbox."
|
|
17865
|
+
"If you are an instance approver, you can approve it in the Inbox.",
|
|
17866
|
+
OVERTAKEN_LINE
|
|
17416
17867
|
);
|
|
17417
17868
|
}
|
|
17418
17869
|
writeOut(
|
|
@@ -17431,18 +17882,18 @@ function startsWorkflows(config) {
|
|
|
17431
17882
|
return Array.isArray(manifest?.actions) && manifest.actions.some((action) => isRecord(action) && action.kind === "workflow");
|
|
17432
17883
|
}
|
|
17433
17884
|
async function status(app, directory, values, options, kind) {
|
|
17434
|
-
const
|
|
17435
|
-
if (directory !== void 0 &&
|
|
17885
|
+
const state2 = directory === void 0 ? void 0 : await readRepositoryState(directory, kind);
|
|
17886
|
+
if (directory !== void 0 && state2 === void 0) {
|
|
17436
17887
|
throw new RepositoryUsageError(
|
|
17437
17888
|
`'${directory}' holds no pulled ${kind.label} (no ${APP_STATE_FILE}).`
|
|
17438
17889
|
);
|
|
17439
17890
|
}
|
|
17440
|
-
if (
|
|
17891
|
+
if (state2 !== void 0 && state2.name !== app) {
|
|
17441
17892
|
throw new RepositoryUsageError(
|
|
17442
|
-
`'${directory}' holds the ${kind.label} '${
|
|
17893
|
+
`'${directory}' holds the ${kind.label} '${state2.name}', not '${app}'.`
|
|
17443
17894
|
);
|
|
17444
17895
|
}
|
|
17445
|
-
const target = await openRepository(options, values,
|
|
17896
|
+
const target = await openRepository(options, values, state2, kind);
|
|
17446
17897
|
const asset = await target.api.read(
|
|
17447
17898
|
(client) => client.assets.get({
|
|
17448
17899
|
params: { kind: kind.kind, name: app },
|
|
@@ -17458,7 +17909,7 @@ async function status(app, directory, values, options, kind) {
|
|
|
17458
17909
|
kind
|
|
17459
17910
|
);
|
|
17460
17911
|
const by = (revision) => revisions.find((entry) => entry.revision === revision);
|
|
17461
|
-
const local = directory === void 0 ||
|
|
17912
|
+
const local = directory === void 0 || state2 === void 0 ? void 0 : { directory, base: state2.revision, ...await localChanges2(directory, state2) };
|
|
17462
17913
|
const report = {
|
|
17463
17914
|
[kind.kind]: app,
|
|
17464
17915
|
workspaceId: target.workspaceId,
|
|
@@ -17560,19 +18011,19 @@ function formatReview(app, review) {
|
|
|
17560
18011
|
)
|
|
17561
18012
|
].join("\n");
|
|
17562
18013
|
}
|
|
17563
|
-
async function openRepository(options, values,
|
|
18014
|
+
async function openRepository(options, values, state2, kind) {
|
|
17564
18015
|
const manifest = await readManifestIfPresent(resolveWorkingDir(options));
|
|
17565
18016
|
const instance = await resolveInstance(manifest, {
|
|
17566
18017
|
...options,
|
|
17567
|
-
...options.instance === void 0 && manifest?.defaultInstance === void 0 &&
|
|
18018
|
+
...options.instance === void 0 && manifest?.defaultInstance === void 0 && state2 ? { instance: state2.instance } : {}
|
|
17568
18019
|
});
|
|
17569
18020
|
const { url } = instance;
|
|
17570
|
-
if (
|
|
18021
|
+
if (state2 !== void 0 && state2.instance !== url) {
|
|
17571
18022
|
throw new RepositoryUsageError(
|
|
17572
|
-
`The folder was pulled from ${
|
|
18023
|
+
`The folder was pulled from ${state2.instance}, and the command names ${url}. A folder belongs to one instance.`
|
|
17573
18024
|
);
|
|
17574
18025
|
}
|
|
17575
|
-
const workspaceId = values.workspace ??
|
|
18026
|
+
const workspaceId = values.workspace ?? state2?.workspaceId ?? instance.workspace;
|
|
17576
18027
|
if (workspaceId === void 0) {
|
|
17577
18028
|
throw new RepositoryUsageError(
|
|
17578
18029
|
`Name the workspace the ${kind.label} belongs to: --workspace <id>, or \`workspace: <id>\` in catalyst.yaml.`
|
|
@@ -17659,9 +18110,9 @@ function writeErr(target, text2) {
|
|
|
17659
18110
|
(target.stderr ?? ((value) => process.stderr.write(value)))(`${text2}
|
|
17660
18111
|
`);
|
|
17661
18112
|
}
|
|
17662
|
-
function pendingApproval(run, json2, options, hint) {
|
|
18113
|
+
function pendingApproval(run, json2, options, hint, note) {
|
|
17663
18114
|
if (json2) writeOut(options, JSON.stringify({ status: "pending_approval", run }, null, 2));
|
|
17664
|
-
else writeErr(options, waitingPublishLine(run, hint));
|
|
18115
|
+
else writeErr(options, waitingPublishLine(run, hint, note));
|
|
17665
18116
|
return EXIT.pending;
|
|
17666
18117
|
}
|
|
17667
18118
|
function readAudience(value) {
|
|
@@ -17722,7 +18173,7 @@ async function runFollowCommand(api, command, input, options) {
|
|
|
17722
18173
|
() => [
|
|
17723
18174
|
"ID STATUS SUMMARY DECISION",
|
|
17724
18175
|
...items.map(
|
|
17725
|
-
(request) => `${request.id} ${request.status} ${request.summary} ${request.decision?.decidedByLabel ?? ""}${request.decision?.comment ? `: ${request.decision.comment}` : ""}`
|
|
18176
|
+
(request) => `${request.id} ${request.status} ${request.summary} ${request.decision?.decidedByLabel ?? ""}${request.decision?.comment ? `: ${request.decision.comment}` : ""}${request.status === "superseded" ? ` ${supersededLine(request)}` : ""}`
|
|
17726
18177
|
)
|
|
17727
18178
|
].join("\n")
|
|
17728
18179
|
);
|
|
@@ -17730,6 +18181,12 @@ async function runFollowCommand(api, command, input, options) {
|
|
|
17730
18181
|
}
|
|
17731
18182
|
return EXIT2.done;
|
|
17732
18183
|
}
|
|
18184
|
+
function supersededLine(request) {
|
|
18185
|
+
const result = request.applyResult;
|
|
18186
|
+
const error = typeof result === "object" && result !== null && "error" in result ? result.error : void 0;
|
|
18187
|
+
const reason = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? ` ${error.message}` : "";
|
|
18188
|
+
return `Settled without a decision: it can do nothing, nothing of it ran or will run.${reason}`;
|
|
18189
|
+
}
|
|
17733
18190
|
|
|
17734
18191
|
// src/asset-help.ts
|
|
17735
18192
|
function formatAssetHelp(verbs) {
|
|
@@ -17849,8 +18306,8 @@ async function pushConfig(options) {
|
|
|
17849
18306
|
if (options.force) {
|
|
17850
18307
|
throw new Error(FORCE_REFUSED_MESSAGE);
|
|
17851
18308
|
}
|
|
17852
|
-
const
|
|
17853
|
-
const baseline =
|
|
18309
|
+
const state2 = await readStateFile(resolve6(workingDir, STATE_FILENAME));
|
|
18310
|
+
const baseline = state2.instances[instance.key] ?? {
|
|
17854
18311
|
lastPulledVersion: 0,
|
|
17855
18312
|
assets: {},
|
|
17856
18313
|
defaultAgentName: null
|
|
@@ -18274,7 +18731,10 @@ async function publishDrafts(api, drafts, input) {
|
|
|
18274
18731
|
return 1;
|
|
18275
18732
|
}
|
|
18276
18733
|
if (outcome.status === "pending_approval") {
|
|
18277
|
-
writeError(
|
|
18734
|
+
writeError(
|
|
18735
|
+
options,
|
|
18736
|
+
`${draft.key}: ${waitingPublishLine(outcome.run, void 0, OVERTAKEN_LINE)}`
|
|
18737
|
+
);
|
|
18278
18738
|
unpublished(index + 1);
|
|
18279
18739
|
return 3;
|
|
18280
18740
|
}
|
|
@@ -18660,9 +19120,9 @@ function filesRead(session2, from, files) {
|
|
|
18660
19120
|
].join("\n")
|
|
18661
19121
|
);
|
|
18662
19122
|
}
|
|
18663
|
-
function settle(session2, outcome, lines, approvalHint) {
|
|
19123
|
+
function settle(session2, outcome, lines, approvalHint, waitingNote) {
|
|
18664
19124
|
if (outcome.status === "pending_approval") {
|
|
18665
|
-
const text2 = waitingPublishLine(outcome.run, approvalHint);
|
|
19125
|
+
const text2 = waitingPublishLine(outcome.run, approvalHint, waitingNote);
|
|
18666
19126
|
if (session2.values.json)
|
|
18667
19127
|
writeOutput(
|
|
18668
19128
|
session2.options,
|
|
@@ -19241,6 +19701,7 @@ async function guardrailDryRunBeforePublish(session2, name2, revision) {
|
|
|
19241
19701
|
}
|
|
19242
19702
|
|
|
19243
19703
|
// src/asset-verbs/publish.ts
|
|
19704
|
+
var ALREADY_LIVE = /* @__PURE__ */ Symbol("already live");
|
|
19244
19705
|
var publishVerb = {
|
|
19245
19706
|
usage: "publish <name> --revision <n> [--yes] [--confirm <blocked>]",
|
|
19246
19707
|
summary: "Make one revision the one its users are served (assets.publish). A guardrail shows its dry run first; an App, a Workflow or a workspace's agent asks you first. A publish that hands a source's data to people who may not use the source waits in the Inbox until a person who may change the source approves it",
|
|
@@ -19317,10 +19778,21 @@ var publishVerb = {
|
|
|
19317
19778
|
}),
|
|
19318
19779
|
"It may have been applied: run 'show' before sending it again."
|
|
19319
19780
|
).catch((error) => {
|
|
19781
|
+
if (isAlreadyLive(error)) return ALREADY_LIVE;
|
|
19320
19782
|
const hint = agent ? agentPublishRefusalHint(error) : void 0;
|
|
19321
19783
|
if (hint === void 0) throw error;
|
|
19322
19784
|
throw new ExplainedRefusal(error, hint);
|
|
19323
19785
|
});
|
|
19786
|
+
if (typeof outcome === "symbol") {
|
|
19787
|
+
const line = alreadyLiveLine(session2.kind.kind, name2, revision);
|
|
19788
|
+
if (session2.values.json)
|
|
19789
|
+
writeOutput(
|
|
19790
|
+
session2.options,
|
|
19791
|
+
JSON.stringify({ status: "already_live", liveRevision: revision }, null, 2)
|
|
19792
|
+
);
|
|
19793
|
+
else writeOutput(session2.options, line);
|
|
19794
|
+
return EXIT3.done;
|
|
19795
|
+
}
|
|
19324
19796
|
return settle(
|
|
19325
19797
|
session2,
|
|
19326
19798
|
outcome,
|
|
@@ -19332,7 +19804,8 @@ var publishVerb = {
|
|
|
19332
19804
|
// An agent's first version without a draft replaces nothing: it is offered as made.
|
|
19333
19805
|
output.replacedRevision !== void 0 && (agent || session2.kind.kind === "skill") ? `Published draft revision ${output.draftRevision} of ${session2.kind.kind} '${name2}' as live revision ${output.publishedRevision}${output.replacedRevision === void 0 ? "" : ` in place of revision ${output.replacedRevision}`}.` : `Published revision ${output.publishedRevision} of ${session2.kind.kind} '${name2}'${output.replacedRevision === void 0 ? "" : ` in place of revision ${output.replacedRevision}`}.`
|
|
19334
19806
|
],
|
|
19335
|
-
asks ? "If you are an instance approver, you can approve it in the Inbox." : void 0
|
|
19807
|
+
asks ? "If you are an instance approver, you can approve it in the Inbox." : void 0,
|
|
19808
|
+
OVERTAKEN_LINE
|
|
19336
19809
|
);
|
|
19337
19810
|
};
|
|
19338
19811
|
}
|
|
@@ -19617,24 +20090,37 @@ async function setDefault(api, kind, name2, scope, defaultOf) {
|
|
|
19617
20090
|
}
|
|
19618
20091
|
|
|
19619
20092
|
// src/asset-verbs/set-availability.ts
|
|
20093
|
+
function isAvailabilityMode(mode) {
|
|
20094
|
+
return AGENT_AVAILABILITY_MODES.some((known) => known === mode);
|
|
20095
|
+
}
|
|
19620
20096
|
var setAvailabilityVerb = {
|
|
19621
|
-
usage: "set-availability <name> --mode all|selected [--personal] [--available-in <workspace-id>]...",
|
|
20097
|
+
usage: "set-availability <name> --mode all|selected|all_except [--personal] [--available-in <workspace-id>]... [--except <workspace-id>]...",
|
|
19622
20098
|
summary: "Set the workspaces one asset is offered in (assets.set_availability)",
|
|
19623
20099
|
named: true,
|
|
19624
20100
|
options: {
|
|
19625
20101
|
mode: { type: "string" },
|
|
19626
20102
|
personal: { type: "boolean", default: false },
|
|
19627
|
-
"available-in": { type: "string", multiple: true }
|
|
20103
|
+
"available-in": { type: "string", multiple: true },
|
|
20104
|
+
except: { type: "string", multiple: true }
|
|
19628
20105
|
},
|
|
19629
20106
|
prepare: (values, name2) => {
|
|
19630
|
-
const
|
|
19631
|
-
if (mode
|
|
19632
|
-
throw new UsageError("--mode is 'all' or '
|
|
20107
|
+
const mode = values.mode;
|
|
20108
|
+
if (!isAvailabilityMode(mode)) {
|
|
20109
|
+
throw new UsageError("--mode is 'all', 'selected' or 'all_except'.");
|
|
20110
|
+
}
|
|
20111
|
+
if (mode !== "selected" && values["available-in"]?.length) {
|
|
20112
|
+
throw new UsageError("--available-in goes with --mode selected.");
|
|
20113
|
+
}
|
|
20114
|
+
if (mode !== "all_except" && values.except?.length) {
|
|
20115
|
+
throw new UsageError("--except goes with --mode all_except.");
|
|
20116
|
+
}
|
|
20117
|
+
if (mode === "all" && values.personal) {
|
|
20118
|
+
throw new UsageError("--personal goes with --mode selected or all_except.");
|
|
19633
20119
|
}
|
|
19634
20120
|
const body = {
|
|
19635
|
-
mode
|
|
20121
|
+
mode,
|
|
19636
20122
|
personalWorkspaces: values.personal,
|
|
19637
|
-
collaborationWorkspaceIds: values["available-in"] ?? []
|
|
20123
|
+
collaborationWorkspaceIds: (mode === "all_except" ? values.except : values["available-in"]) ?? []
|
|
19638
20124
|
};
|
|
19639
20125
|
return async (session2) => {
|
|
19640
20126
|
const outcome = await setAvailability(
|
|
@@ -19645,7 +20131,7 @@ var setAvailabilityVerb = {
|
|
|
19645
20131
|
session2.scope
|
|
19646
20132
|
);
|
|
19647
20133
|
return settle(session2, outcome, (output) => [
|
|
19648
|
-
`${session2.kind.kind} '${name2}' is offered in ${output
|
|
20134
|
+
`${session2.kind.kind} '${name2}' is offered in ${availabilityPhrase(output)}.`
|
|
19649
20135
|
]);
|
|
19650
20136
|
};
|
|
19651
20137
|
}
|
|
@@ -20136,6 +20622,23 @@ async function setupCommand(options) {
|
|
|
20136
20622
|
return 1;
|
|
20137
20623
|
}
|
|
20138
20624
|
}
|
|
20625
|
+
async function refreshWrittenSkills(env) {
|
|
20626
|
+
const skill = await renderCatalystSkill();
|
|
20627
|
+
const paths = [
|
|
20628
|
+
...new Set(
|
|
20629
|
+
Object.keys(LOCAL_AGENT_TOOLS).filter(isLocalAgentTool).map((tool) => catalystSkillPath(tool, env))
|
|
20630
|
+
)
|
|
20631
|
+
];
|
|
20632
|
+
const refreshed = [];
|
|
20633
|
+
for (const path of paths) {
|
|
20634
|
+
const existing = await readSkillFile(path).catch(() => void 0);
|
|
20635
|
+
if (typeof existing === "string" && existing !== skill && writtenBySetup(existing)) {
|
|
20636
|
+
await replaceFile(path, skill);
|
|
20637
|
+
refreshed.push(path);
|
|
20638
|
+
}
|
|
20639
|
+
}
|
|
20640
|
+
return refreshed;
|
|
20641
|
+
}
|
|
20139
20642
|
var NOT_A_FILE = /* @__PURE__ */ Symbol("not a file");
|
|
20140
20643
|
async function readSkillFile(path) {
|
|
20141
20644
|
const entry = await lstat4(path).catch((error) => {
|
|
@@ -21014,7 +21517,7 @@ import yaml7 from "js-yaml";
|
|
|
21014
21517
|
import { readFile as readFile10 } from "fs/promises";
|
|
21015
21518
|
import { basename as basename5, resolve as resolve11 } from "path";
|
|
21016
21519
|
import { parseArgs as parseArgs5 } from "util";
|
|
21017
|
-
import { z as
|
|
21520
|
+
import { z as z71 } from "zod";
|
|
21018
21521
|
|
|
21019
21522
|
// src/connection-sign-in.ts
|
|
21020
21523
|
import { setTimeout as defaultSleep3 } from "timers/promises";
|
|
@@ -21143,11 +21646,11 @@ async function readSecret(input, prompt) {
|
|
|
21143
21646
|
}
|
|
21144
21647
|
|
|
21145
21648
|
// src/operation-commands.ts
|
|
21146
|
-
var requestSchema =
|
|
21147
|
-
params:
|
|
21148
|
-
query:
|
|
21149
|
-
body:
|
|
21150
|
-
file:
|
|
21649
|
+
var requestSchema = z71.strictObject({
|
|
21650
|
+
params: z71.record(z71.string(), z71.string()).optional(),
|
|
21651
|
+
query: z71.record(z71.string(), z71.union([z71.string(), z71.number(), z71.boolean()])).optional(),
|
|
21652
|
+
body: z71.unknown().optional(),
|
|
21653
|
+
file: z71.string().optional()
|
|
21151
21654
|
});
|
|
21152
21655
|
var UsageError2 = class extends Error {
|
|
21153
21656
|
};
|
|
@@ -21256,7 +21759,7 @@ async function runOperationCommand(argv, base) {
|
|
|
21256
21759
|
secret = value;
|
|
21257
21760
|
if (value.length === 0) throw new UsageError2("The secret must not be empty.");
|
|
21258
21761
|
if (values.test) {
|
|
21259
|
-
const
|
|
21762
|
+
const state3 = await api2.change(
|
|
21260
21763
|
(client, idempotencyKey2) => client.connections.set_test_credential({
|
|
21261
21764
|
params: { name: connectionName },
|
|
21262
21765
|
body: {
|
|
@@ -21277,10 +21780,10 @@ async function runOperationCommand(argv, base) {
|
|
|
21277
21780
|
);
|
|
21278
21781
|
return testCredential;
|
|
21279
21782
|
});
|
|
21280
|
-
writeOutput(options, JSON.stringify(
|
|
21783
|
+
writeOutput(options, JSON.stringify(state3, null, 2));
|
|
21281
21784
|
return 0;
|
|
21282
21785
|
}
|
|
21283
|
-
const
|
|
21786
|
+
const state2 = await api2.change(
|
|
21284
21787
|
(client, idempotencyKey2) => client.connections.set_secret({
|
|
21285
21788
|
params: { name: connectionName },
|
|
21286
21789
|
body: {
|
|
@@ -21296,7 +21799,7 @@ async function runOperationCommand(argv, base) {
|
|
|
21296
21799
|
throw error;
|
|
21297
21800
|
return (await api2.read((client) => client.connections.get({ params: { name: connectionName } }))).secret;
|
|
21298
21801
|
});
|
|
21299
|
-
writeOutput(options, JSON.stringify(
|
|
21802
|
+
writeOutput(options, JSON.stringify(state2, null, 2));
|
|
21300
21803
|
return 0;
|
|
21301
21804
|
}
|
|
21302
21805
|
if (verb === "connect") {
|
|
@@ -21870,7 +22373,7 @@ var initGroup = {
|
|
|
21870
22373
|
// src/knowledge-commands.ts
|
|
21871
22374
|
import { parseArgs as parseArgs10 } from "util";
|
|
21872
22375
|
import yaml11 from "js-yaml";
|
|
21873
|
-
import { z as
|
|
22376
|
+
import { z as z72 } from "zod";
|
|
21874
22377
|
var knowledgeHelpText = `Knowledge Base sources (draft changes take effect at publish):
|
|
21875
22378
|
knowledge-base source add <kb> --source <id> --connection <name> --folder <id>... [--include <glob>...] [--exclude <glob>...]
|
|
21876
22379
|
knowledge-base source list <kb>
|
|
@@ -21935,8 +22438,8 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
21935
22438
|
if (command === "add" || command === "remove" || command === "list") {
|
|
21936
22439
|
const asset = await api.getAsset("knowledge_base", name2);
|
|
21937
22440
|
if (!asset) throw new Error("The Knowledge Base is not available.");
|
|
21938
|
-
const config =
|
|
21939
|
-
const sources =
|
|
22441
|
+
const config = z72.record(z72.string(), z72.unknown()).parse(asset.config);
|
|
22442
|
+
const sources = z72.array(z72.record(z72.string(), z72.unknown())).parse(config.sources ?? []);
|
|
21940
22443
|
if (command === "list") result = sources;
|
|
21941
22444
|
else {
|
|
21942
22445
|
const remaining = sources.filter((s) => s.id !== values.source);
|
|
@@ -21974,7 +22477,7 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
21974
22477
|
const output = await call2(api, apiOperations["knowledge_bases.sources"], {
|
|
21975
22478
|
params: { knowledgeBase: name2 }
|
|
21976
22479
|
});
|
|
21977
|
-
const parsed2 =
|
|
22480
|
+
const parsed2 = z72.object({ sources: z72.array(z72.object({ id: z72.string() }).passthrough()) }).parse(output);
|
|
21978
22481
|
result = {
|
|
21979
22482
|
sources: values.source ? parsed2.sources.filter((s) => s.id === values.source) : parsed2.sources
|
|
21980
22483
|
};
|
|
@@ -22004,14 +22507,14 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
22004
22507
|
return 1;
|
|
22005
22508
|
}
|
|
22006
22509
|
}
|
|
22007
|
-
var reindexAnswerSchema =
|
|
22008
|
-
started:
|
|
22009
|
-
state:
|
|
22010
|
-
active:
|
|
22011
|
-
target:
|
|
22012
|
-
progress:
|
|
22013
|
-
statement:
|
|
22014
|
-
lines:
|
|
22510
|
+
var reindexAnswerSchema = z72.object({
|
|
22511
|
+
started: z72.boolean(),
|
|
22512
|
+
state: z72.string(),
|
|
22513
|
+
active: z72.object({ model: z72.string() }).passthrough().optional(),
|
|
22514
|
+
target: z72.object({ model: z72.string() }).passthrough().optional(),
|
|
22515
|
+
progress: z72.object({ embedded: z72.number(), total: z72.number() }).optional(),
|
|
22516
|
+
statement: z72.object({ confirmation: z72.string(), room: z72.boolean() }).passthrough().optional(),
|
|
22517
|
+
lines: z72.array(z72.string()).optional()
|
|
22015
22518
|
}).passthrough();
|
|
22016
22519
|
async function reindex(api, name2, confirm, options, json2) {
|
|
22017
22520
|
const raw = await call2(api, apiOperations["knowledge_bases.reindex"], {
|
|
@@ -23007,10 +23510,10 @@ async function listProviders(configFlag, json2, options) {
|
|
|
23007
23510
|
}
|
|
23008
23511
|
writeOutput(options, `Model providers of ${shownPath(options.cwd, path)}:`);
|
|
23009
23512
|
for (const provider of listed) {
|
|
23010
|
-
const
|
|
23513
|
+
const state2 = provider.instance === void 0 ? "" : provider.instance === "absent" ? " instance: not deployed" : ` instance: ${provider.instance.check.status === "failed" ? `failed (${provider.instance.check.errorClass})` : provider.instance.check.status.replace("_", " ")}${provider.instance.secrets.some((secret) => secret.state === "missing") ? ", secret missing" : ""}`;
|
|
23011
23514
|
writeOutput(
|
|
23012
23515
|
options,
|
|
23013
|
-
` ${provider.id} ${provider.provider}, region ${provider.region ?? "unset"}${provider.secret ? `, secret ${provider.secret}` : ""}, bindings: ${provider.bindings.length > 0 ? provider.bindings.join(", ") : "none"}${provider.priced ? "" : ", not priced"}${
|
|
23516
|
+
` ${provider.id} ${provider.provider}, region ${provider.region ?? "unset"}${provider.secret ? `, secret ${provider.secret}` : ""}, bindings: ${provider.bindings.length > 0 ? provider.bindings.join(", ") : "none"}${provider.priced ? "" : ", not priced"}${state2}`
|
|
23014
23517
|
);
|
|
23015
23518
|
}
|
|
23016
23519
|
return 0;
|
|
@@ -23589,12 +24092,22 @@ async function runCli(argv, runtime = {}) {
|
|
|
23589
24092
|
return group.run(argv, { ...runtime, cwd: runtime.cwd ?? process.cwd(), stdout, stderr });
|
|
23590
24093
|
}
|
|
23591
24094
|
var entryPath = process.argv[1];
|
|
23592
|
-
if (entryPath && import.meta.url === pathToFileURL(
|
|
24095
|
+
if (entryPath && import.meta.url === pathToFileURL(realpathSync2(entryPath)).href) {
|
|
24096
|
+
const env = readConfigCliEnv();
|
|
24097
|
+
if (env.CATALYST_CLI_UPDATED_FROM !== void 0) {
|
|
24098
|
+
const refreshed = await refreshWrittenSkills(env).catch(() => []);
|
|
24099
|
+
if (refreshed.length > 0) {
|
|
24100
|
+
process.stderr.write(`Updated the Catalyst skill at ${refreshed.join(" and ")}.
|
|
24101
|
+
`);
|
|
24102
|
+
}
|
|
24103
|
+
}
|
|
24104
|
+
enableSelfUpdate(process.argv.slice(2));
|
|
23593
24105
|
process.exitCode = await runCli(process.argv.slice(2));
|
|
23594
24106
|
}
|
|
23595
24107
|
export {
|
|
23596
24108
|
ApiKeyExchangeError,
|
|
23597
24109
|
CANONICAL_FORM_VERSION,
|
|
24110
|
+
CliVersionError,
|
|
23598
24111
|
ConfigApiError,
|
|
23599
24112
|
MANIFEST_FILENAME,
|
|
23600
24113
|
STATE_FILENAME,
|
|
@@ -23611,11 +24124,13 @@ export {
|
|
|
23611
24124
|
createSkillFileDiff,
|
|
23612
24125
|
createUnifiedDiff,
|
|
23613
24126
|
diffConfig,
|
|
24127
|
+
enableSelfUpdate,
|
|
23614
24128
|
guardrailAssetPath,
|
|
23615
24129
|
instanceFetch,
|
|
23616
24130
|
listConfig,
|
|
23617
24131
|
matchManifestFiles,
|
|
23618
24132
|
matchesManifestPath,
|
|
24133
|
+
npmCommand,
|
|
23619
24134
|
parseAgentYaml,
|
|
23620
24135
|
parseManifest,
|
|
23621
24136
|
parseSkillFile,
|
|
@@ -23628,6 +24143,8 @@ export {
|
|
|
23628
24143
|
readStateFile,
|
|
23629
24144
|
readWorkingCopy,
|
|
23630
24145
|
redactSecret,
|
|
24146
|
+
refreshWrittenSkills,
|
|
24147
|
+
releaseVersionOf,
|
|
23631
24148
|
removeStaleManifestAssets,
|
|
23632
24149
|
renderCatalystSkill,
|
|
23633
24150
|
resolveInstance,
|
|
@@ -23641,6 +24158,7 @@ export {
|
|
|
23641
24158
|
skillAssetPath,
|
|
23642
24159
|
toConfigApiError,
|
|
23643
24160
|
updateManifestDefaultAgent,
|
|
24161
|
+
updateToServerVersion,
|
|
23644
24162
|
validateConfig,
|
|
23645
24163
|
walkFiles,
|
|
23646
24164
|
writeStateFile
|