@stigmer/client 0.1.3 → 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/README.md +10 -0
- package/app-handover.d.ts +186 -0
- package/app-handover.d.ts.map +1 -0
- package/app-handover.js +630 -0
- package/app-handover.js.map +1 -0
- package/gen/agent.d.ts +2 -1
- package/gen/agent.d.ts.map +1 -1
- package/gen/agent.js +2 -0
- package/gen/agent.js.map +1 -1
- package/gen/organization.d.ts +2 -0
- package/gen/organization.d.ts.map +1 -1
- package/gen/organization.js +8 -0
- package/gen/organization.js.map +1 -1
- package/gen/run.d.ts +7 -1
- package/gen/run.d.ts.map +1 -1
- package/gen/run.js +23 -1
- package/gen/run.js.map +1 -1
- package/iam-principal.d.ts +11 -0
- package/iam-principal.d.ts.map +1 -1
- package/iam-principal.js +16 -0
- package/iam-principal.js.map +1 -1
- package/index.d.ts +11 -5
- package/index.d.ts.map +1 -1
- package/index.js +10 -3
- package/index.js.map +1 -1
- package/node.d.ts.map +1 -1
- package/node.js +12 -0
- package/node.js.map +1 -1
- package/package.json +9 -4
- package/platform.d.ts +41 -3
- package/platform.d.ts.map +1 -1
- package/platform.js +56 -3
- package/platform.js.map +1 -1
- package/run/format-elapsed.d.ts +10 -0
- package/run/format-elapsed.d.ts.map +1 -0
- package/run/format-elapsed.js +25 -0
- package/run/format-elapsed.js.map +1 -0
- package/run/step-words.d.ts +78 -0
- package/run/step-words.d.ts.map +1 -0
- package/run/step-words.js +316 -0
- package/run/step-words.js.map +1 -0
- package/run/tool-view.d.ts +49 -2
- package/run/tool-view.d.ts.map +1 -1
- package/run/tool-view.js +113 -17
- package/run/tool-view.js.map +1 -1
- package/run/turn-activity.d.ts +9 -7
- package/run/turn-activity.d.ts.map +1 -1
- package/run/turn-activity.js +24 -144
- package/run/turn-activity.js.map +1 -1
- package/run/turn-ending.d.ts +59 -0
- package/run/turn-ending.d.ts.map +1 -0
- package/run/turn-ending.js +405 -0
- package/run/turn-ending.js.map +1 -0
- package/run/turn-steps.d.ts +16 -0
- package/run/turn-steps.d.ts.map +1 -0
- package/run/turn-steps.js +65 -0
- package/run/turn-steps.js.map +1 -0
- package/session-events.d.ts +3 -1
- package/session-events.d.ts.map +1 -1
- package/session-events.js +1 -0
- package/session-events.js.map +1 -1
- package/src/app-handover.ts +777 -0
- package/src/gen/agent.ts +4 -1
- package/src/gen/organization.ts +7 -0
- package/src/gen/run.ts +21 -1
- package/src/iam-principal.ts +21 -0
- package/src/index.ts +55 -1
- package/src/node.ts +12 -0
- package/src/platform.ts +80 -3
- package/src/run/format-elapsed.ts +22 -0
- package/src/run/step-words.ts +360 -0
- package/src/run/tool-view.ts +133 -19
- package/src/run/turn-activity.ts +27 -146
- package/src/run/turn-ending.ts +487 -0
- package/src/run/turn-steps.ts +81 -0
- package/src/session-events.ts +4 -1
package/src/gen/agent.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { TagAgentVersionInputSchema, ListAgentVersionsInputSchema, ListAgentVers
|
|
|
14
14
|
import { HookFormat, HookHandlerSchema, HookGroupSchema, HookConfigSchema, type HookHandler, type HookGroup, type HookConfig } from "@stigmer/apis/ai/stigmer/agentic/plugin/v1/hooks_pb";
|
|
15
15
|
import { ServiceTier, ThinkingMode } from "@stigmer/apis/ai/stigmer/agentic/run/v1/enum_pb";
|
|
16
16
|
import { RunConfigSchema, type RunConfig } from "@stigmer/apis/ai/stigmer/agentic/run/v1/invocation_pb";
|
|
17
|
-
import { Harness } from "@stigmer/apis/ai/stigmer/agentic/session/v1/enum_pb";
|
|
17
|
+
import { Harness, Computer } from "@stigmer/apis/ai/stigmer/agentic/session/v1/enum_pb";
|
|
18
18
|
import { EnvVarDeclarationSchema, type EnvVarDeclaration } from "@stigmer/apis/ai/stigmer/agentic/vault/v1/declaration_pb";
|
|
19
19
|
import { ApiResourceKind } from "@stigmer/apis/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
20
20
|
import { ApiResourceVisibility } from "@stigmer/apis/ai/stigmer/commons/apiresource/enum_pb";
|
|
@@ -161,6 +161,7 @@ export interface AgentInput {
|
|
|
161
161
|
subagents?: ResourceRef[];
|
|
162
162
|
mcpServers?: AgentMcpServerInput[];
|
|
163
163
|
environmentRef?: ResourceRef;
|
|
164
|
+
computer?: Computer;
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
/** SDK input type for EnvVarDeclaration. */
|
|
@@ -315,6 +316,7 @@ export function buildAgentProto(input: AgentInput): Agent {
|
|
|
315
316
|
subagents,
|
|
316
317
|
mcpServers,
|
|
317
318
|
environmentRef,
|
|
319
|
+
computer: input.computer,
|
|
318
320
|
})),
|
|
319
321
|
}) as Agent;
|
|
320
322
|
}
|
|
@@ -417,5 +419,6 @@ export function toAgentInput(resource: Agent): AgentInput {
|
|
|
417
419
|
subagents: toResourceRefInputs(spec.subagents),
|
|
418
420
|
mcpServers: spec.mcpServers?.length ? spec.mcpServers.map(toAgentMcpServerInput) : undefined,
|
|
419
421
|
environmentRef: toResourceRefInput(spec.environmentRef),
|
|
422
|
+
computer: spec.computer || undefined,
|
|
420
423
|
};
|
|
421
424
|
}
|
package/src/gen/organization.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { IamRole } from "@stigmer/apis/ai/stigmer/iam/v1/enum_pb";
|
|
|
12
12
|
import { OrganizationSchema, type Organization } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/api_pb";
|
|
13
13
|
import { OrganizationCommandController } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/command_pb";
|
|
14
14
|
import { OrganizationIdSchema, UpdateOrganizationInputSchema, UpdateOrganizationPoliciesInputSchema, UpdateOrganizationEmbeddingInputSchema, ListMyOrganizationsInputSchema, OrganizationsSchema, OrganizationExternalLookupSchema, ListChildOrgsInputSchema, ChildOrgListSchema, type UpdateOrganizationPoliciesInput, type UpdateOrganizationEmbeddingInput, type ListMyOrganizationsInput, type Organizations, type OrganizationExternalLookup, type ListChildOrgsInput, type ChildOrgList } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/io_pb";
|
|
15
|
+
import { OnboardingProgressSchema, type OnboardingProgress } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/onboarding_pb";
|
|
15
16
|
import { OrganizationQueryController } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/query_pb";
|
|
16
17
|
import { OrganizationSpecSchema, OrganizationPreferencesSchema, OrganizationPoliciesSchema, OrganizationEmbeddingSchema, type OrganizationPreferences, type OrganizationPolicies, type OrganizationEmbedding } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/spec_pb";
|
|
17
18
|
|
|
@@ -118,6 +119,12 @@ export class OrganizationClient {
|
|
|
118
119
|
pageToken = page.nextPageToken;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
122
|
+
|
|
123
|
+
async getOnboarding(id: string): Promise<OnboardingProgress> {
|
|
124
|
+
try {
|
|
125
|
+
return await this.query.getOnboarding(create(OrganizationIdSchema, { value: id }));
|
|
126
|
+
} catch (e) { throw wrapError(e); }
|
|
127
|
+
}
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
/** Input for creating or applying an Organization. */
|
package/src/gen/run.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { RunCommandController } from "@stigmer/apis/ai/stigmer/agentic/run/v1/co
|
|
|
11
11
|
import { InteractionMode, ServiceTier, ThinkingMode } from "@stigmer/apis/ai/stigmer/agentic/run/v1/enum_pb";
|
|
12
12
|
import { EvalMockKind, EvalMockToolSchema, EvalMockPluginHomeSchema, EvalMockAgentHomeSchema, EvalMockServerSchema, EvalCaseContextSchema, type EvalMockTool, type EvalMockPluginHome, type EvalMockAgentHome, type EvalMockServer, type EvalCaseContext } from "@stigmer/apis/ai/stigmer/agentic/run/v1/eval_case_pb";
|
|
13
13
|
import { RunConfigSchema, type RunConfig } from "@stigmer/apis/ai/stigmer/agentic/run/v1/invocation_pb";
|
|
14
|
-
import { RunIdSchema, SendMessageResponseSchema, UpdateRunInputSchema, RunUpdateStatusInputSchema, UpdateStatusResponseSchema, TerminateRunInputSchema, RecoverRunInputSchema, PauseRunInputSchema, ResumeRunInputSchema, ListRunsRequestSchema, RunListSchema, ListRunsBySessionRequestSchema, GetArtifactDownloadUrlRequestSchema, GetArtifactDownloadUrlResponseSchema, GetArtifactContentRequestSchema, GetArtifactContentResponseSchema, GetRunUsageReportInputSchema, GetRunUsageReportOutputSchema, GetSessionUsageReportInputSchema, GetSessionUsageReportOutputSchema, GetAgentUsageReportInputSchema, GetAgentUsageReportOutputSchema, GetOrgUsageReportInputSchema, GetOrgUsageReportOutputSchema, GetRunSummaryRequestSchema, RunSummarySchema, type SendMessageResponse, type RunUpdateStatusInput, type UpdateStatusResponse, type TerminateRunInput, type RecoverRunInput, type PauseRunInput, type ResumeRunInput, type ListRunsRequest, type RunList, type ListRunsBySessionRequest, type GetArtifactDownloadUrlRequest, type GetArtifactDownloadUrlResponse, type GetArtifactContentRequest, type GetArtifactContentResponse, type GetRunUsageReportInput, type GetRunUsageReportOutput, type GetSessionUsageReportInput, type GetSessionUsageReportOutput, type GetAgentUsageReportInput, type GetAgentUsageReportOutput, type GetOrgUsageReportInput, type GetOrgUsageReportOutput, type GetRunSummaryRequest, type RunSummary } from "@stigmer/apis/ai/stigmer/agentic/run/v1/io_pb";
|
|
14
|
+
import { RunIdSchema, SendMessageResponseSchema, UpdateRunInputSchema, RunUpdateStatusInputSchema, UpdateStatusResponseSchema, TerminateRunInputSchema, RecoverRunInputSchema, PauseRunInputSchema, ResumeRunInputSchema, ListRunsRequestSchema, RunListSchema, ListRunsBySessionRequestSchema, ListRunsByAgentRequestSchema, GetArtifactDownloadUrlRequestSchema, GetArtifactDownloadUrlResponseSchema, GetArtifactContentRequestSchema, GetArtifactContentResponseSchema, GetRunUsageReportInputSchema, GetRunUsageReportOutputSchema, GetSessionUsageReportInputSchema, GetSessionUsageReportOutputSchema, GetAgentUsageReportInputSchema, GetAgentUsageReportOutputSchema, GetOrgUsageReportInputSchema, GetOrgUsageReportOutputSchema, GetRunSummaryRequestSchema, RunSummarySchema, type SendMessageResponse, type RunUpdateStatusInput, type UpdateStatusResponse, type TerminateRunInput, type RecoverRunInput, type PauseRunInput, type ResumeRunInput, type ListRunsRequest, type RunList, type ListRunsBySessionRequest, type ListRunsByAgentRequest, type GetArtifactDownloadUrlRequest, type GetArtifactDownloadUrlResponse, type GetArtifactContentRequest, type GetArtifactContentResponse, type GetRunUsageReportInput, type GetRunUsageReportOutput, type GetSessionUsageReportInput, type GetSessionUsageReportOutput, type GetAgentUsageReportInput, type GetAgentUsageReportOutput, type GetOrgUsageReportInput, type GetOrgUsageReportOutput, type GetRunSummaryRequest, type RunSummary } from "@stigmer/apis/ai/stigmer/agentic/run/v1/io_pb";
|
|
15
15
|
import { RunQueryController } from "@stigmer/apis/ai/stigmer/agentic/run/v1/query_pb";
|
|
16
16
|
import { RunSpecSchema, ConversationCatchupSchema, type ConversationCatchup } from "@stigmer/apis/ai/stigmer/agentic/run/v1/spec_pb";
|
|
17
17
|
import { Harness, ExecutionTarget, GitWriteBackMode } from "@stigmer/apis/ai/stigmer/agentic/session/v1/enum_pb";
|
|
@@ -131,6 +131,26 @@ export class RunClient {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
async listByAgent(input: MessageInitShape<typeof ListRunsByAgentRequestSchema>): Promise<RunList> {
|
|
135
|
+
try {
|
|
136
|
+
return await this.query.listByAgent(input);
|
|
137
|
+
} catch (e) { throw wrapError(e); }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Every entry of `listByAgent`, page after page: follows `nextPageToken`
|
|
142
|
+
* until the list ends. Breaking out of the loop stops the reads.
|
|
143
|
+
*/
|
|
144
|
+
async *listByAgentAll(input: MessageInitShape<typeof ListRunsByAgentRequestSchema>): AsyncGenerator<RunList["entries"][number]> {
|
|
145
|
+
let pageToken = input.pageToken ?? "";
|
|
146
|
+
for (;;) {
|
|
147
|
+
const page = await this.listByAgent(create(ListRunsByAgentRequestSchema, { ...input, pageToken }));
|
|
148
|
+
yield* page.entries;
|
|
149
|
+
if (page.nextPageToken === "") return;
|
|
150
|
+
pageToken = page.nextPageToken;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
134
154
|
async getArtifactDownloadUrl(input: MessageInitShape<typeof GetArtifactDownloadUrlRequestSchema>): Promise<GetArtifactDownloadUrlResponse> {
|
|
135
155
|
try {
|
|
136
156
|
return await this.query.getArtifactDownloadUrl(input);
|
package/src/iam-principal.ts
CHANGED
|
@@ -118,6 +118,27 @@ export function isAppUserAccount(
|
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Whether an access-list entry is a person who signed in to Stigmer itself:
|
|
123
|
+
* a person kind whose identity origin is `direct` (the deployment's own
|
|
124
|
+
* sign-in) or `federated` (an organization's own identity provider). App
|
|
125
|
+
* users and service accounts read `false`, and so does an entry the server
|
|
126
|
+
* could not resolve, which carries no origin, and a team. This is the
|
|
127
|
+
* positive rule for "someone joined the team", where reading everything
|
|
128
|
+
* that is not an app user or a service account would count an unresolved
|
|
129
|
+
* entry as a teammate.
|
|
130
|
+
*/
|
|
131
|
+
export function isPersonAccount(
|
|
132
|
+
view: Pick<ApiResourceRefView, "kind" | "identityOrigin">,
|
|
133
|
+
): boolean {
|
|
134
|
+
const mode = view.identityOrigin?.provisioningMode;
|
|
135
|
+
return (
|
|
136
|
+
view.kind === PERSON_KIND &&
|
|
137
|
+
(mode === IdentityAccountProvisioningMode.direct ||
|
|
138
|
+
mode === IdentityAccountProvisioningMode.federated)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
121
142
|
/**
|
|
122
143
|
* Whether an access-list entry is an organization's service account: a
|
|
123
144
|
* person kind whose identity origin is `service_account`. An entry the
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,31 @@ export {
|
|
|
40
40
|
buildEmbedSnippet,
|
|
41
41
|
} from "./chat-link.js";
|
|
42
42
|
|
|
43
|
+
// The code that puts an agent's chat in a builder's own app (token route and
|
|
44
|
+
// chat, per stack; framework-free)
|
|
45
|
+
export {
|
|
46
|
+
APP_HANDOVER_STACKS,
|
|
47
|
+
APP_TOKEN_ROUTE,
|
|
48
|
+
APP_API_KEY_VARIABLE,
|
|
49
|
+
APP_DEV_USER_VARIABLE,
|
|
50
|
+
APP_CHAT_COMPONENT,
|
|
51
|
+
APP_TOKEN_ROUTE_PORT,
|
|
52
|
+
APP_API_KEY_PLACEHOLDER,
|
|
53
|
+
APP_DEV_USER_PLACEHOLDER,
|
|
54
|
+
appSettingsText,
|
|
55
|
+
buildAppHandover,
|
|
56
|
+
} from "./app-handover.js";
|
|
57
|
+
export type {
|
|
58
|
+
AppHandover,
|
|
59
|
+
AppHandoverFile,
|
|
60
|
+
AppHandoverInput,
|
|
61
|
+
AppHandoverLanguage,
|
|
62
|
+
AppHandoverMode,
|
|
63
|
+
AppHandoverSource,
|
|
64
|
+
AppHandoverStack,
|
|
65
|
+
AppSettingsValues,
|
|
66
|
+
} from "./app-handover.js";
|
|
67
|
+
|
|
43
68
|
// References the server returned (a deleted target has an id and no slug)
|
|
44
69
|
export {
|
|
45
70
|
isDeletedReference,
|
|
@@ -114,6 +139,7 @@ export {
|
|
|
114
139
|
granteeFromView,
|
|
115
140
|
granteeKey,
|
|
116
141
|
isAppUserAccount,
|
|
142
|
+
isPersonAccount,
|
|
117
143
|
isServiceAccount,
|
|
118
144
|
} from "./iam-principal.js";
|
|
119
145
|
export {
|
|
@@ -164,6 +190,7 @@ export {
|
|
|
164
190
|
export {
|
|
165
191
|
PlatformClient,
|
|
166
192
|
type EnvironmentAvailability,
|
|
193
|
+
type HelpLink,
|
|
167
194
|
type NativeSignIn,
|
|
168
195
|
type ServerInfo,
|
|
169
196
|
} from "./platform.js";
|
|
@@ -396,12 +423,15 @@ export {
|
|
|
396
423
|
type ToolKind,
|
|
397
424
|
resolveToolKind,
|
|
398
425
|
resolveToolKindByName,
|
|
426
|
+
toolPublicName,
|
|
399
427
|
normalizeToolResult,
|
|
428
|
+
editAttemptOf,
|
|
400
429
|
SHELL_INTENT_ARG_FIELD,
|
|
401
430
|
extractShellIntent,
|
|
402
431
|
shellIntentFromArgs,
|
|
403
432
|
isSecretArgKey,
|
|
404
433
|
redactSecretArgs,
|
|
434
|
+
type FileLineRange,
|
|
405
435
|
type ToolResultView,
|
|
406
436
|
type ToolSearchMatch,
|
|
407
437
|
type ToolContentBlock,
|
|
@@ -423,13 +453,36 @@ export { isTerminalPhase, turnPhaseOf } from "./run/run-phases.js";
|
|
|
423
453
|
export {
|
|
424
454
|
activityPhrase,
|
|
425
455
|
describeTurnActivity,
|
|
426
|
-
|
|
456
|
+
SANDBOX_WAIT_PHRASE,
|
|
427
457
|
settledStepsPhrase,
|
|
428
458
|
stepsSpanMs,
|
|
429
459
|
type TodoProgress,
|
|
430
460
|
type TurnActivity,
|
|
431
461
|
type TurnProgress,
|
|
432
462
|
} from "./run/turn-activity.js";
|
|
463
|
+
export { formatElapsed } from "./run/format-elapsed.js";
|
|
464
|
+
export {
|
|
465
|
+
failureWords,
|
|
466
|
+
humanizeToolName,
|
|
467
|
+
lineRangeWords,
|
|
468
|
+
searchCountWords,
|
|
469
|
+
stepPhrase,
|
|
470
|
+
stepTense,
|
|
471
|
+
type StepPhrase,
|
|
472
|
+
type StepPhraseOptions,
|
|
473
|
+
type StepTense,
|
|
474
|
+
} from "./run/step-words.js";
|
|
475
|
+
export { turnSteps, type PlanItem, type TurnSteps } from "./run/turn-steps.js";
|
|
476
|
+
export {
|
|
477
|
+
describeTurnEnding,
|
|
478
|
+
type DescribeTurnEndingInput,
|
|
479
|
+
type TurnEnding,
|
|
480
|
+
type TurnEndingAct,
|
|
481
|
+
type TurnEndingLink,
|
|
482
|
+
type TurnEndingNames,
|
|
483
|
+
type TurnEndingTone,
|
|
484
|
+
type TurnEndingViewer,
|
|
485
|
+
} from "./run/turn-ending.js";
|
|
433
486
|
export { backgroundCommandText, backgroundEndingLine, backgroundEndingPhrase } from "./run/background-command.js";
|
|
434
487
|
// A session's events, folded: the one model every client reads a
|
|
435
488
|
// conversation from (@stigmer/session-log), and the helpers that follow a
|
|
@@ -481,6 +534,7 @@ export {
|
|
|
481
534
|
type TurnOpenOperation,
|
|
482
535
|
type TurnPhase,
|
|
483
536
|
type TurnStatus,
|
|
537
|
+
type TurnStopDetail,
|
|
484
538
|
type UserMessage,
|
|
485
539
|
type UserMessageItem,
|
|
486
540
|
} from "@stigmer/session-log";
|
package/src/node.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stigmer/client/node`: the client for a Node.js process (a server route,
|
|
3
|
+
* the CLI, a script), over `@connectrpc/connect-node`'s native transport
|
|
4
|
+
* instead of the browser transport the `.` entry uses.
|
|
5
|
+
*
|
|
6
|
+
* The transport is an optional peer of the client, and this is the only module
|
|
7
|
+
* that loads it: a browser app installs the client without it, and a Node app
|
|
8
|
+
* that imports this entry installs it beside the client
|
|
9
|
+
* (`npm install @stigmer/client @connectrpc/connect-node`). Without it, Node's
|
|
10
|
+
* own resolution error names the missing package; no guard here restates it.
|
|
11
|
+
* The transport needs Node 22, which is the client's declared floor.
|
|
12
|
+
*/
|
|
1
13
|
import { createGrpcTransport, createGrpcWebTransport } from "@connectrpc/connect-node";
|
|
2
14
|
import type { Transport, Interceptor } from "@connectrpc/connect";
|
|
3
15
|
import { Stigmer, type TokenProvider } from "./index.js";
|
package/src/platform.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import type {
|
|
9
9
|
GetLicenseStatusOutput,
|
|
10
10
|
GetServerInfoOutput,
|
|
11
|
+
HelpLink as HelpLinkProto,
|
|
11
12
|
ServerEdition,
|
|
12
13
|
} from "@stigmer/apis/ai/stigmer/platform/v1/server_info_pb";
|
|
13
14
|
import {
|
|
@@ -15,6 +16,8 @@ import {
|
|
|
15
16
|
ModelOnEngineSchema,
|
|
16
17
|
} from "@stigmer/apis/ai/stigmer/platform/v1/model_readiness_pb";
|
|
17
18
|
import type { GetModelReadinessOutput } from "@stigmer/apis/ai/stigmer/platform/v1/model_readiness_pb";
|
|
19
|
+
import { GetOnboardingFunnelInputSchema } from "@stigmer/apis/ai/stigmer/platform/v1/onboarding_funnel_pb";
|
|
20
|
+
import type { GetOnboardingFunnelOutput } from "@stigmer/apis/ai/stigmer/platform/v1/onboarding_funnel_pb";
|
|
18
21
|
import type { Harness } from "@stigmer/apis/ai/stigmer/agentic/session/v1/enum_pb";
|
|
19
22
|
import { wrapError } from "./gen/errors.js";
|
|
20
23
|
import {
|
|
@@ -75,6 +78,26 @@ export interface ServerInfo {
|
|
|
75
78
|
* offers no sign-in to an installed app.
|
|
76
79
|
*/
|
|
77
80
|
readonly nativeSignIn: NativeSignIn | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Where a person stuck on this server asks for help, as its operator set
|
|
83
|
+
* it: an address and the words to show for it. Show it on your own
|
|
84
|
+
* screens (sign-in, the page's chrome, every failure); never inside an
|
|
85
|
+
* app a builder made for their own users, whose help is the builder's.
|
|
86
|
+
*
|
|
87
|
+
* `undefined` when the operator set none, on a server released before
|
|
88
|
+
* the field, and when the server announced an address that is not an
|
|
89
|
+
* absolute `https:`, `http:` or `mailto:` one, which is never handed on:
|
|
90
|
+
* show no help link then, rather than a guess.
|
|
91
|
+
*/
|
|
92
|
+
readonly help: HelpLink | undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Where to ask for help, as {@link ServerInfo.help} reports it. */
|
|
96
|
+
export interface HelpLink {
|
|
97
|
+
/** An absolute `https:`, `http:` or `mailto:` address. */
|
|
98
|
+
readonly url: string;
|
|
99
|
+
/** The words to show for it, at most 40 characters; plain text, never markup. */
|
|
100
|
+
readonly label: string;
|
|
78
101
|
}
|
|
79
102
|
|
|
80
103
|
/** How an installed app signs in, as {@link ServerInfo.nativeSignIn} reports it. */
|
|
@@ -101,8 +124,38 @@ export interface EnvironmentAvailability {
|
|
|
101
124
|
readonly packages: boolean;
|
|
102
125
|
}
|
|
103
126
|
|
|
127
|
+
/** The schemes a help address may carry: a web page or a mail address. */
|
|
128
|
+
const HELP_LINK_SCHEMES: ReadonlySet<string> = new Set(["https:", "http:", "mailto:"]);
|
|
129
|
+
|
|
130
|
+
/** The longest label a server announces (the server's own limit). */
|
|
131
|
+
const HELP_LABEL_MAX = 40;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The announced help link, or undefined when there is none or it is not one
|
|
135
|
+
* a client may render: a server checks its operator's address at boot, and
|
|
136
|
+
* a client checks again because it meets servers it did not build. A label
|
|
137
|
+
* that is empty or too long is replaced by "Get help", the server's own
|
|
138
|
+
* default, rather than dropping a good address.
|
|
139
|
+
*/
|
|
140
|
+
function helpLinkOf(help: HelpLinkProto | undefined): HelpLink | undefined {
|
|
141
|
+
if (help === undefined) return undefined;
|
|
142
|
+
let parsed: URL;
|
|
143
|
+
try {
|
|
144
|
+
parsed = new URL(help.url);
|
|
145
|
+
} catch {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
if (!HELP_LINK_SCHEMES.has(parsed.protocol)) return undefined;
|
|
149
|
+
const label = help.label.trim();
|
|
150
|
+
return {
|
|
151
|
+
url: help.url,
|
|
152
|
+
label: label === "" || [...label].length > HELP_LABEL_MAX ? "Get help" : label,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
104
156
|
/**
|
|
105
|
-
* Client for platform-level queries (server info, capabilities, license
|
|
157
|
+
* Client for platform-level queries (server info, capabilities, license,
|
|
158
|
+
* the operator's onboarding count).
|
|
106
159
|
*
|
|
107
160
|
* The {@link getServerInfo} method is the authoritative source for
|
|
108
161
|
* deployment mode detection. It replaces URL-based hostname guessing
|
|
@@ -118,8 +171,8 @@ export class PlatformClient {
|
|
|
118
171
|
|
|
119
172
|
/**
|
|
120
173
|
* Retrieve the connected server's edition, version, authentication
|
|
121
|
-
* posture, how an installed app signs in,
|
|
122
|
-
* organization, and what an Environment does there. Answered before
|
|
174
|
+
* posture, how an installed app signs in, where to ask for help,
|
|
175
|
+
* whether it holds one organization, and what an Environment does there. Answered before
|
|
123
176
|
* sign-in: no credential is needed.
|
|
124
177
|
*
|
|
125
178
|
* Maps the proto {@link ServerEdition} to a {@link DeploymentMode}
|
|
@@ -147,6 +200,7 @@ export class PlatformClient {
|
|
|
147
200
|
audience: resp.nativeSignIn.audience,
|
|
148
201
|
clientId: resp.nativeSignIn.clientId,
|
|
149
202
|
},
|
|
203
|
+
help: helpLinkOf(resp.help),
|
|
150
204
|
singleOrg: resp.singleOrg,
|
|
151
205
|
environments:
|
|
152
206
|
resp.environments === undefined
|
|
@@ -208,4 +262,27 @@ export class PlatformClient {
|
|
|
208
262
|
throw wrapError(e);
|
|
209
263
|
}
|
|
210
264
|
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* How far the organizations made in a window got on the journey from a
|
|
268
|
+
* first agent to their users: how many were made, how many were left out
|
|
269
|
+
* as the operator's own, and how many have each of the six steps done.
|
|
270
|
+
* Counts only. A platform operator's read; anyone else is refused with
|
|
271
|
+
* PERMISSION_DENIED, and a server older than the read answers
|
|
272
|
+
* UNIMPLEMENTED.
|
|
273
|
+
*
|
|
274
|
+
* @param window.from - A UTC calendar day ("2026-11-01"), from its first
|
|
275
|
+
* instant, or an RFC 3339 instant; inclusive.
|
|
276
|
+
* @param window.to - A UTC calendar day, through its last instant, or an
|
|
277
|
+
* RFC 3339 instant; inclusive.
|
|
278
|
+
*/
|
|
279
|
+
async getOnboardingFunnel(window: { readonly from: string; readonly to: string }): Promise<GetOnboardingFunnelOutput> {
|
|
280
|
+
try {
|
|
281
|
+
return await this.platform.getOnboardingFunnel(
|
|
282
|
+
create(GetOnboardingFunnelInputSchema, { fromDate: window.from, toDate: window.to }),
|
|
283
|
+
);
|
|
284
|
+
} catch (e) {
|
|
285
|
+
throw wrapError(e);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
211
288
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// How long something took or has been going, as every surface says it (the
|
|
2
|
+
// session view, the terminal, the CLI). A module of its own, with nothing
|
|
3
|
+
// else in it, so a surface that only says a duration loads only this.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A span of time in at most two units, the larger first, the smaller always
|
|
7
|
+
* two digits so a ticking time keeps its width: "42s", "1m 05s", "15m 00s",
|
|
8
|
+
* "1h 03m", "2d 05h". Every surface that says how long something took or has
|
|
9
|
+
* been going says it this way (the session view, the terminal, the CLI).
|
|
10
|
+
* Seconds are floored, so a span never reads longer than it was; a negative
|
|
11
|
+
* span reads "0s".
|
|
12
|
+
*/
|
|
13
|
+
export function formatElapsed(ms: number): string {
|
|
14
|
+
const two = (n: number): string => String(n).padStart(2, "0");
|
|
15
|
+
const seconds = Math.max(0, Math.floor(ms / 1000));
|
|
16
|
+
if (seconds < 60) return `${seconds}s`;
|
|
17
|
+
const minutes = Math.floor(seconds / 60);
|
|
18
|
+
if (minutes < 60) return `${minutes}m ${two(seconds % 60)}s`;
|
|
19
|
+
const hours = Math.floor(minutes / 60);
|
|
20
|
+
if (hours < 24) return `${hours}h ${two(minutes % 60)}m`;
|
|
21
|
+
return `${Math.floor(hours / 24)}d ${two(hours % 24)}h`;
|
|
22
|
+
}
|