@madewithremy/admin 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -15,6 +15,145 @@ interface AdminContext {
15
15
  baseUrl: string;
16
16
  }
17
17
 
18
+ /**
19
+ * Response types for the v2 agent-chat thread log.
20
+ *
21
+ * Transcribed from youai-api:
22
+ * src/http/routes/V2Apps/manage/agentThreads.ts — routes
23
+ * src/http/routes/V2Apps/manage/_helpers/projectAgentMessages.ts — transcript shape
24
+ * src/common/Db/v2Apps/V2AgentThreadsDao.ts — list row shape
25
+ */
26
+ /** One tool the assistant asked for, with the arguments it chose. */
27
+ interface AgentToolCall {
28
+ id: string;
29
+ name: string;
30
+ input: Record<string, unknown>;
31
+ }
32
+ /** A platform/model failure that ended a turn instead of a reply. */
33
+ interface AgentTurnError {
34
+ message: string;
35
+ code?: string;
36
+ /** Milliseconds since epoch. */
37
+ at: number;
38
+ }
39
+ /**
40
+ * One message in a thread transcript.
41
+ *
42
+ * Roles are the stored conversation's own: `user` for a person's message AND
43
+ * for a tool result (which carries `toolCallId`), `assistant` for the agent.
44
+ */
45
+ interface AgentTranscriptMessage {
46
+ role: string;
47
+ content: string;
48
+ /** CDN URLs the user attached (user messages only). */
49
+ attachments?: string[];
50
+ /** Present on an assistant message that requested tools. */
51
+ toolCalls?: AgentToolCall[];
52
+ /** Present on a tool result — matches the `toolCalls[].id` it answers. */
53
+ toolCallId?: string;
54
+ /** The tool reported a failure. */
55
+ isToolError?: boolean;
56
+ /**
57
+ * Request-log id for a method tool call — `requests get <id>` for its input,
58
+ * output, stdout and error. Absent on client-tool results, which run in the
59
+ * browser and never reach the backend.
60
+ */
61
+ requestId?: string;
62
+ /** The turn ended in a platform/model failure rather than a reply. */
63
+ turnError?: AgentTurnError;
64
+ /**
65
+ * The model saw extracted document text from an attachment on top of
66
+ * `content`. Only its presence is reported — the text can run to megabytes.
67
+ */
68
+ hasProcessedContent?: true;
69
+ }
70
+ /** One item in the thread list (transcript excluded). */
71
+ interface AgentThreadListItem {
72
+ id: string;
73
+ /** Auto-generated from the first user message, or renamed by the user. */
74
+ title: string | null;
75
+ userId: string | null;
76
+ userName: string | null;
77
+ userEmail: string | null;
78
+ /** Browser identity — the only id an anonymous conversation has. */
79
+ visitorId: string | null;
80
+ /** True identifies a builder test conversation through the dev tunnel. */
81
+ devSession: boolean;
82
+ messageCount: number;
83
+ /** Tool results reported as failures — the conversations worth opening. */
84
+ toolErrorCount: number;
85
+ /** A turn broke (model error, rate limit, credits) rather than replying. */
86
+ hasTurnError: boolean;
87
+ /** ISO timestamp. */
88
+ dateCreated: string;
89
+ dateUpdated: string;
90
+ }
91
+ /** Full thread with transcript (single-thread GET). */
92
+ interface AgentThreadDetail {
93
+ id: string;
94
+ title: string | null;
95
+ userId: string | null;
96
+ userName: string | null;
97
+ userEmail: string | null;
98
+ visitorId: string | null;
99
+ devSession: boolean;
100
+ messageCount: number;
101
+ /** ISO timestamp. */
102
+ dateCreated: string;
103
+ dateUpdated: string;
104
+ messages: AgentTranscriptMessage[];
105
+ }
106
+ /** GET /_internal/v2/apps/:appId/agent-threads */
107
+ interface AgentThreadsListResult {
108
+ threads: AgentThreadListItem[];
109
+ nextCursor: string | null;
110
+ }
111
+ /** GET /_internal/v2/apps/:appId/agent-threads/:threadId */
112
+ type AgentThreadsGetResult = AgentThreadDetail;
113
+
114
+ interface ThreadsListParams {
115
+ /** Max threads per page (default 20, server clamps to 100). */
116
+ limit?: number;
117
+ /** Pagination cursor from a prior page's `nextCursor`. */
118
+ cursor?: string;
119
+ }
120
+ /**
121
+ * Every conversation the app's agent has had, newest activity first.
122
+ *
123
+ * Returns cursored pages; pass `nextCursor` from one page as `cursor` for the
124
+ * next. Transcripts are not included — fetch a thread with `threadsGet`.
125
+ *
126
+ * `toolErrorCount` and `hasTurnError` are how you find the conversations worth
127
+ * reading, and `devSession` separates your own test threads from real traffic.
128
+ *
129
+ * @example
130
+ * const { threads } = await admin.agent.threadsList({ limit: 20 });
131
+ * const broken = threads.filter((t) => t.toolErrorCount > 0 || t.hasTurnError);
132
+ */
133
+ declare function threadsList(ctx: AdminContext, params?: ThreadsListParams): Promise<AgentThreadsListResult>;
134
+ /**
135
+ * One thread with its full transcript: what the user said, what the agent
136
+ * replied, which tools it called with which arguments, and what came back.
137
+ *
138
+ * This is the primary tool for iterating on an agent's system prompt and tool
139
+ * descriptions — read what actually happened rather than guessing. Each method
140
+ * tool call carries a `requestId`; pass it to `requests.get()` for that call's
141
+ * input, output, stdout and error.
142
+ *
143
+ * @throws AdminApiError `thread_not_found` (404).
144
+ * @example
145
+ * const thread = await admin.agent.threadsGet('4f6c…');
146
+ * console.log(thread.messages);
147
+ */
148
+ declare function threadsGet(ctx: AdminContext, threadId: string): Promise<AgentThreadDetail>;
149
+
150
+ type agent_ThreadsListParams = ThreadsListParams;
151
+ declare const agent_threadsGet: typeof threadsGet;
152
+ declare const agent_threadsList: typeof threadsList;
153
+ declare namespace agent {
154
+ export { type agent_ThreadsListParams as ThreadsListParams, agent_threadsGet as threadsGet, agent_threadsList as threadsList };
155
+ }
156
+
18
157
  /**
19
158
  * Response types for the v2 analytics (insights) endpoints.
20
159
  *
@@ -875,6 +1014,7 @@ interface DataSourcesIngestUpdate {
875
1014
  };
876
1015
  contextual?: {
877
1016
  enabled?: boolean;
1017
+ modelId?: string;
878
1018
  };
879
1019
  images?: {
880
1020
  describe?: boolean;
@@ -5069,6 +5209,7 @@ declare function buildClient(ctx: AdminContext): {
5069
5209
  context: Readonly<AdminContext>;
5070
5210
  /** A sibling client for another app, sharing credentials. */
5071
5211
  forApp(appId: string): /*elided*/ any;
5212
+ agent: BoundOps<typeof agent>;
5072
5213
  analytics: BoundOps<typeof analytics>;
5073
5214
  crashes: BoundOps<typeof crashes>;
5074
5215
  cron: BoundOps<typeof cron>;
@@ -5149,4 +5290,4 @@ declare class AdminTimeoutError extends Error {
5149
5290
 
5150
5291
  declare const admin: AdminClient;
5151
5292
 
5152
- export { AdminApiError, type AdminClient, type AdminClientOptions, type AdminContext, AdminTimeoutError, type AnalyticsAiHostRow, type AnalyticsAiSourcesResult, type AnalyticsAiVendorRow, type AnalyticsBatchResult, type AnalyticsCrawlersOverviewResult, type AnalyticsCrawlersRecentResult, type AnalyticsCrawlersRecentRow, type AnalyticsCrawlersResult, type AnalyticsCrawlersTimeseriesBucket, type AnalyticsCrawlersTimeseriesResult, type AnalyticsLiveResult, type AnalyticsMapPoint, type AnalyticsMapResult, type AnalyticsMetric, type AnalyticsQueryResult, type AnalyticsQueryResultRow, type AnalyticsSourceRow, type AnalyticsSourcesResult, type AppCronJobStatus, type AppCronJobStatusReason, type AppCronRunState, type AppEmailSuppression, type AppSecretRow, type CrashGroup, type CrashOccurrenceRow, type CrashesGetResult, type CrashesListResult, type CrashesOccurrencesResult, type CrashesStatsBucket, type CrashesStatsResult, type CronJobDecorated, type CronOverviewResult, type CronRunResult, type CronRunSummary, type DashboardLiveRelease, type DashboardReleaseMethod, type DashboardResult, type DataLiftFromDevResult, type DataLiftFromLiveResult, type DataSourcesBuildProgress, type DataSourcesChunkingConfig, type DataSourcesConfigResult, type DataSourcesConfigUpdateResult, type DataSourcesDeleteResult, type DataSourcesDocument, type DataSourcesDocumentConfirmResult, type DataSourcesDocumentDeleteResult, type DataSourcesDocumentStatus, type DataSourcesDocumentsResult, type DataSourcesDropResult, type DataSourcesIngestConfig, type DataSourcesIngestUpdate, type DataSourcesListEntry, type DataSourcesListResult, type DataSourcesPromoteResult, type DataSourcesRetrievalConfig, type DataSourcesRetrievalUpdate, type DataSourcesRevectorizeResult, type DataSourcesSearchCitation, type DataSourcesSearchResult, type DataSourcesSearchResultItem, type DataSourcesUploadTokenResult, type DatasetFile, type DbQueryResult, type DiagnosticsAuditEnvironment, type DiagnosticsDashboardResult, type DiagnosticsFinding, type DiagnosticsLighthouseScores, type DiagnosticsPayload, type DiagnosticsReleaseResult, type DiagnosticsRuntimeFindings, type DomainsCheckResult, type DomainsCustomAddResult, type DomainsCustomCheckResult, type DomainsCustomHostnameUiStatus, type DomainsCustomHostnameView, type DomainsCustomListResult, type DomainsCustomRemoveResult, type DomainsCustomRetryResult, type DomainsDnsInstructions, type DomainsGetResult, type DomainsSetResult, type EmailBatchLifecycle, type EmailBatchResult, type EmailBatchSummary, type EmailBatchesResult, type EmailDomainBase, type EmailEffectiveSender, type EmailInboxResult, type EmailListResult, type EmailMessageKind, type EmailMessageResult, type EmailMessageStatus, type EmailSenderTier, type EmailSendingStatusResult, type EmailStatsResult, type EmailSummary, type EmailSuppressResult, type EmailSuppressionsResult, type EmailUnsuppressResult, type FilesDeleteResult, type FilesFileMeta, type FilesListEntry, type FilesListResult, type FilesLsResult, type FilesScanBadge, type FilesScanFlagged, type FilesScanStore, type FilesStatResult, type FilesStoreSummaryEntry, type FilesUploadUrlResult, type FilesUrlResult, type FrontendErrorType, type InboundDnsInstructions, type InboundEmailDomainAddResult, type InboundEmailDomainCheckResult, type InboundEmailDomainDeleteResult, type InboundEmailDomainUiStatus, type InboundEmailDomainVerifyResult, type InboundEmailDomainView, type InboundEmailDomainsListResult, type InboxEmailPreview, type IssueAuthorKind, type IssueCommentRow, type IssueEventType, type IssueKind, type IssueRow, type IssueStatus, type IssuesCommentResult, type IssuesCreateResult, type IssuesDeleteResult, type IssuesGetResult, type IssuesListResult, type IssuesUpdateResult, type JewelPairRow, type JewelPairSummaryRow, type JewelVerdict, type JewelsDatasetSummary, type JewelsDryrunResult, type JewelsExportResult, type JewelsGradeResult, type JewelsGrading, type JewelsOverviewResult, type JewelsPairResult, type JewelsPairsResult, type JewelsQueueResult, type JewelsResolveResult, type JewelsRunResult, type JewelsRunsResult, type JewelsTimeseriesBucket, type JewelsTimeseriesResult, type JewelsTrainResult, type LiftedDatabase, type MethodsInvokeResult, type OutboundDnsInstructions, type OutboundEmailDomainAddResult, type OutboundEmailDomainCheckResult, type OutboundEmailDomainDeleteResult, type OutboundEmailDomainUiStatus, type OutboundEmailDomainVerifyResult, type OutboundEmailDomainView, type OutboundEmailDomainsListResult, type PlatformSuppression, type PrerenderGetResult, type PrerenderInvalidateResult, type PrerenderPage, type PrerenderPagesResult, type PrerenderViewResult, type ReleaseFragment, type ReleasesByCommitResult, type ReleasesGetResult, type ReleasesListResult, type RequestsGetResult, type RequestsListResult, type RequestsListRow, type RequestsStatsMethodBucket, type RequestsStatsMethodResult, type RequestsStatsSummaryBucket, type RequestsStatsSummaryResult, type SecretsDeleteResult, type SecretsGetResult, type SecretsListResult, type SecretsSetResult, type SettingsResult, type SuppressionSource, type TrainingLogEntry, type TrainingRunRow, type TrainingRunStatus, type UserAuthProvider, type UserListItem, type UserRecord, type UsersCreateApiKeyResult, type UsersListResult, type UsersRevokeApiKeyResult, type UsersSetRoleResult, type V2AppSettings, type V2BuildLogEntry, type V2BuildStats, type V2CommitInfo, type V2EmailMessage, type V2ReleaseStatus, type VoiceAvailableNumber, type VoiceNumbersBuyResult, type VoiceNumbersListResult, type VoiceNumbersReleaseResult, type VoiceNumbersSearchResult, type VoiceNumbersSetNameResult, type VoicePhoneNumberStatus, type VoicePhoneNumberView, type VoiceResolvedPolicy, type VoiceSessionChannel, type VoiceSessionCost, type VoiceSessionCostLine, type VoiceSessionDetail, type VoiceSessionGetResult, type VoiceSessionListItem, type VoiceSessionSip, type VoiceSessionSpeechEntry, type VoiceSessionStatus, type VoiceSessionToolEntry, type VoiceSessionTranscriptEntry, type VoiceSessionsListResult, type VoiceSettingsCeilings, type VoiceSettingsGetResult, type VoiceSettingsOverrides, type VoiceSettingsSetResult, admin, createAdminClient, admin as default };
5293
+ export { AdminApiError, type AdminClient, type AdminClientOptions, type AdminContext, AdminTimeoutError, type AgentThreadDetail, type AgentThreadListItem, type AgentThreadsGetResult, type AgentThreadsListResult, type AgentToolCall, type AgentTranscriptMessage, type AgentTurnError, type AnalyticsAiHostRow, type AnalyticsAiSourcesResult, type AnalyticsAiVendorRow, type AnalyticsBatchResult, type AnalyticsCrawlersOverviewResult, type AnalyticsCrawlersRecentResult, type AnalyticsCrawlersRecentRow, type AnalyticsCrawlersResult, type AnalyticsCrawlersTimeseriesBucket, type AnalyticsCrawlersTimeseriesResult, type AnalyticsLiveResult, type AnalyticsMapPoint, type AnalyticsMapResult, type AnalyticsMetric, type AnalyticsQueryResult, type AnalyticsQueryResultRow, type AnalyticsSourceRow, type AnalyticsSourcesResult, type AppCronJobStatus, type AppCronJobStatusReason, type AppCronRunState, type AppEmailSuppression, type AppSecretRow, type CrashGroup, type CrashOccurrenceRow, type CrashesGetResult, type CrashesListResult, type CrashesOccurrencesResult, type CrashesStatsBucket, type CrashesStatsResult, type CronJobDecorated, type CronOverviewResult, type CronRunResult, type CronRunSummary, type DashboardLiveRelease, type DashboardReleaseMethod, type DashboardResult, type DataLiftFromDevResult, type DataLiftFromLiveResult, type DataSourcesBuildProgress, type DataSourcesChunkingConfig, type DataSourcesConfigResult, type DataSourcesConfigUpdateResult, type DataSourcesDeleteResult, type DataSourcesDocument, type DataSourcesDocumentConfirmResult, type DataSourcesDocumentDeleteResult, type DataSourcesDocumentStatus, type DataSourcesDocumentsResult, type DataSourcesDropResult, type DataSourcesIngestConfig, type DataSourcesIngestUpdate, type DataSourcesListEntry, type DataSourcesListResult, type DataSourcesPromoteResult, type DataSourcesRetrievalConfig, type DataSourcesRetrievalUpdate, type DataSourcesRevectorizeResult, type DataSourcesSearchCitation, type DataSourcesSearchResult, type DataSourcesSearchResultItem, type DataSourcesUploadTokenResult, type DatasetFile, type DbQueryResult, type DiagnosticsAuditEnvironment, type DiagnosticsDashboardResult, type DiagnosticsFinding, type DiagnosticsLighthouseScores, type DiagnosticsPayload, type DiagnosticsReleaseResult, type DiagnosticsRuntimeFindings, type DomainsCheckResult, type DomainsCustomAddResult, type DomainsCustomCheckResult, type DomainsCustomHostnameUiStatus, type DomainsCustomHostnameView, type DomainsCustomListResult, type DomainsCustomRemoveResult, type DomainsCustomRetryResult, type DomainsDnsInstructions, type DomainsGetResult, type DomainsSetResult, type EmailBatchLifecycle, type EmailBatchResult, type EmailBatchSummary, type EmailBatchesResult, type EmailDomainBase, type EmailEffectiveSender, type EmailInboxResult, type EmailListResult, type EmailMessageKind, type EmailMessageResult, type EmailMessageStatus, type EmailSenderTier, type EmailSendingStatusResult, type EmailStatsResult, type EmailSummary, type EmailSuppressResult, type EmailSuppressionsResult, type EmailUnsuppressResult, type FilesDeleteResult, type FilesFileMeta, type FilesListEntry, type FilesListResult, type FilesLsResult, type FilesScanBadge, type FilesScanFlagged, type FilesScanStore, type FilesStatResult, type FilesStoreSummaryEntry, type FilesUploadUrlResult, type FilesUrlResult, type FrontendErrorType, type InboundDnsInstructions, type InboundEmailDomainAddResult, type InboundEmailDomainCheckResult, type InboundEmailDomainDeleteResult, type InboundEmailDomainUiStatus, type InboundEmailDomainVerifyResult, type InboundEmailDomainView, type InboundEmailDomainsListResult, type InboxEmailPreview, type IssueAuthorKind, type IssueCommentRow, type IssueEventType, type IssueKind, type IssueRow, type IssueStatus, type IssuesCommentResult, type IssuesCreateResult, type IssuesDeleteResult, type IssuesGetResult, type IssuesListResult, type IssuesUpdateResult, type JewelPairRow, type JewelPairSummaryRow, type JewelVerdict, type JewelsDatasetSummary, type JewelsDryrunResult, type JewelsExportResult, type JewelsGradeResult, type JewelsGrading, type JewelsOverviewResult, type JewelsPairResult, type JewelsPairsResult, type JewelsQueueResult, type JewelsResolveResult, type JewelsRunResult, type JewelsRunsResult, type JewelsTimeseriesBucket, type JewelsTimeseriesResult, type JewelsTrainResult, type LiftedDatabase, type MethodsInvokeResult, type OutboundDnsInstructions, type OutboundEmailDomainAddResult, type OutboundEmailDomainCheckResult, type OutboundEmailDomainDeleteResult, type OutboundEmailDomainUiStatus, type OutboundEmailDomainVerifyResult, type OutboundEmailDomainView, type OutboundEmailDomainsListResult, type PlatformSuppression, type PrerenderGetResult, type PrerenderInvalidateResult, type PrerenderPage, type PrerenderPagesResult, type PrerenderViewResult, type ReleaseFragment, type ReleasesByCommitResult, type ReleasesGetResult, type ReleasesListResult, type RequestsGetResult, type RequestsListResult, type RequestsListRow, type RequestsStatsMethodBucket, type RequestsStatsMethodResult, type RequestsStatsSummaryBucket, type RequestsStatsSummaryResult, type SecretsDeleteResult, type SecretsGetResult, type SecretsListResult, type SecretsSetResult, type SettingsResult, type SuppressionSource, type TrainingLogEntry, type TrainingRunRow, type TrainingRunStatus, type UserAuthProvider, type UserListItem, type UserRecord, type UsersCreateApiKeyResult, type UsersListResult, type UsersRevokeApiKeyResult, type UsersSetRoleResult, type V2AppSettings, type V2BuildLogEntry, type V2BuildStats, type V2CommitInfo, type V2EmailMessage, type V2ReleaseStatus, type VoiceAvailableNumber, type VoiceNumbersBuyResult, type VoiceNumbersListResult, type VoiceNumbersReleaseResult, type VoiceNumbersSearchResult, type VoiceNumbersSetNameResult, type VoicePhoneNumberStatus, type VoicePhoneNumberView, type VoiceResolvedPolicy, type VoiceSessionChannel, type VoiceSessionCost, type VoiceSessionCostLine, type VoiceSessionDetail, type VoiceSessionGetResult, type VoiceSessionListItem, type VoiceSessionSip, type VoiceSessionSpeechEntry, type VoiceSessionStatus, type VoiceSessionToolEntry, type VoiceSessionTranscriptEntry, type VoiceSessionsListResult, type VoiceSettingsCeilings, type VoiceSettingsGetResult, type VoiceSettingsOverrides, type VoiceSettingsSetResult, admin, createAdminClient, admin as default };
package/dist/index.js CHANGED
@@ -58,16 +58,11 @@ function loadWorkspaceAppId(workspaceDir = WORKSPACE_DIR) {
58
58
  return result.value.appId;
59
59
  }
60
60
 
61
- // src/ops/analytics.ts
62
- var analytics_exports = {};
63
- __export(analytics_exports, {
64
- aiSources: () => aiSources,
65
- batch: () => batch,
66
- crawlers: () => crawlers,
67
- live: () => live,
68
- map: () => map,
69
- query: () => query,
70
- sources: () => sources
61
+ // src/ops/agent.ts
62
+ var agent_exports = {};
63
+ __export(agent_exports, {
64
+ threadsGet: () => threadsGet,
65
+ threadsList: () => threadsList
71
66
  });
72
67
 
73
68
  // src/errors.ts
@@ -168,7 +163,33 @@ async function tryCall(ctx, method, apiPath) {
168
163
  return { ok: res.ok, status: res.status, body: await readBody(res) };
169
164
  }
170
165
 
166
+ // src/ops/agent.ts
167
+ function threadsList(ctx, params = {}) {
168
+ return call(
169
+ ctx,
170
+ "GET",
171
+ `/_internal/v2/apps/${ctx.appId}/agent-threads${qs(params)}`
172
+ );
173
+ }
174
+ function threadsGet(ctx, threadId) {
175
+ return call(
176
+ ctx,
177
+ "GET",
178
+ `/_internal/v2/apps/${ctx.appId}/agent-threads/${seg(threadId)}`
179
+ );
180
+ }
181
+
171
182
  // src/ops/analytics.ts
183
+ var analytics_exports = {};
184
+ __export(analytics_exports, {
185
+ aiSources: () => aiSources,
186
+ batch: () => batch,
187
+ crawlers: () => crawlers,
188
+ live: () => live,
189
+ map: () => map,
190
+ query: () => query,
191
+ sources: () => sources
192
+ });
172
193
  function query(ctx, body) {
173
194
  return call(
174
195
  ctx,
@@ -1626,6 +1647,7 @@ function buildClient(ctx) {
1626
1647
  forApp(appId) {
1627
1648
  return buildClient({ ...ctx, appId });
1628
1649
  },
1650
+ agent: bindOps(agent_exports, ctx),
1629
1651
  analytics: bindOps(analytics_exports, ctx),
1630
1652
  crashes: bindOps(crashes_exports, ctx),
1631
1653
  cron: bindOps(cron_exports, ctx),